How can I return to previous view after a refresh?

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderators: Gurus, Addon Administrators

Nanya
Posts: 21
Joined: Wed Oct 03, 2012 8:04 pm

How can I return to previous view after a refresh?

Post by Nanya »

If I use "SDB.MainTracksWindow.Refresh" in a script, how can I return to the previous view afterward? I.e., back to the same albums and tracks that were selected?
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: How can I return to previous view after a refresh?

Post by trixmoto »

Well if you've refreshed then the same tracks might not be there, but I guess you could store a list of all the track IDs before calling refresh, and then select all the ones with those IDs afterwards.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Nanya
Posts: 21
Joined: Wed Oct 03, 2012 8:04 pm

Re: How can I return to previous view after a refresh?

Post by Nanya »

Yeah, I tried this code: (Tracks is a SDBSongList)

Code: Select all

SDB.MainTracksWindow.Refresh
Dim oShell
Set oShell = CreateObject("WScript.Shell")
oShell.SendKeys "^a"
SDB.UI.MainWindowFocus = 2
SDB.MainTracksWindow.RemoveSelectedTracks
For a = 0 to Tracks.Count - 1
  SDB.MainTracksWindow.AddTrack(Tracks.Item(a))
  SDB.MainTracksWindow.Selected(a) = true
Next
SDB.MainTracksWindow.FinishAdding
Problem is, oShell.SendKeys "^a" tries to execute before the refresh is finished, so it gets nothing. Putting a timer or sleep doesn't work, it just postpones the refresh. The only way to get it to select everything is to have a messagebox to pop up and the user closes it. I'm not sure what I'm doing wrong.
Post Reply