Automating a script when click on tab

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

Moderators: Gurus, Addon Administrators

martinstephenbanks
Posts: 28
Joined: Thu Apr 26, 2012 10:34 am

Automating a script when click on tab

Post by martinstephenbanks »

Hi All,

I know you can automate scripts on opening MM by putting them in the auto folder but is it possible to have them run automatically when you do something specific?

I'll explain why I ask and that may help you to answer better: I leave open multiple tabs so that I don't have to wait for some of them to rebuild (I have a large collection) each time, one of which is a playlist I made that shows me all the songs that have ever played but have not been rated (simply playlist count > 0 AND Rating = Unknown). However, each time I go to the tab I have to refresh it. Is there a way to have MM detect that I have clicked on this tab and run a refresh automagically?

For example, does it keep some kind of log of my movements that I could have it detect this tab within? Or can the tab itself be given some code to perform on 'Got Focus'?

Thanks for all your help and brain cells :)
Martin Banks
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Automating a script when click on tab

Post by trixmoto »

There are a number of application events but not one specifically for changing tabs. When you change tabs I suspect it would fire OnTrackListFilled though, so you could check which tab is focused at this point and do a refresh - although you'd need to be careful to avoid an infinite loop, as the refresh would cause this event to fire as well. Maybe OnChangedSelection would be better - this fires when you click on a different node, but I don't know if it fires when changing tabs or not.
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.
martinstephenbanks
Posts: 28
Joined: Thu Apr 26, 2012 10:34 am

Re: Automating a script when click on tab

Post by martinstephenbanks »

Thanks Trixmoto, whilst it sounds like there is no easy answer to this, you appear to have some possibilities I can explore. Not sure if I mentioned but working with MM I am very new at :)

So, do you know how I could test to see if the OnChangedSelection fires when I click this particular tab? Like is there a log I could watch or anything like that? If I can see it firing I can hopefully run an IF to see if this tab has the focus and run a refresh.

Many thanks,
Martin Banks
Peke
Posts: 13794
Joined: Tue Jun 10, 2003 7:21 pm
Location: Serbia
Contact:

Re: Automating a script when click on tab

Post by Peke »

It would be nice and helpful that you create new Topic/Mantis BUG with list of events that could be added in 4.1 as we are approaching beta period.

So it is right time for this.
Best regards,
Peke
MediaMonkey Team lead QA/Tech Support guru
Admin of Free MediaMonkey addon Site HappyMonkeying
Image
Image
How to add SCREENSHOTS to forum
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Automating a script when click on tab

Post by trixmoto »

The best way to test would probably be to register a function which has a MsgBox in it, so that you get a popup. Or you could write your own logfile - or use OutputDebugStringMM if you're using a debug version of MM.
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: Automating a script when click on tab

Post by Nanya »

It would be nice and helpful that you create new Topic/Mantis BUG with list of events that could be added in 4.1 as we are approaching beta period.

So it is right time for this.
Peke, perhaps you should take a look at the wishlist, as much of this still hasn't been implemented: http://www.mediamonkey.com/forum/viewto ... f=2&t=7973
Nor even added to the "Official" list... http://www.mediamonkey.com/forum/viewtopic.php?t=7978
trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Hull, UK
Contact:

Re: Automating a script when click on tab

Post by trixmoto »

By the way, when I create my own debug file, I typically do it with a procedure like this...

Code: Select all

Sub out(str)
  Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
  Dim loc : loc = SDB.TemporaryFolder&"\Scriptname.log"
  Dim txt : txt = SDB.ToAscii(str)
  Dim logf : Set logf = fso.OpenTextFile(loc,8,True)
  If Err.Number <> 0 Then
    logf.WriteLine("["&Err.Number&"] "&Err.Description&" ("&Err.Source&")")
    Err.Clear
  End If
  Call logf.WriteLine(Time&" "&txt)
  Call logf.Close
End Sub
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.
Post Reply