Auto Scripting - OnStartup command restrictions?

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

Moderator: Gurus

ryanafleming
Posts: 49
Joined: Thu Jul 26, 2012 4:11 am

Auto Scripting - OnStartup command restrictions?

Post by ryanafleming » Mon Nov 25, 2013 1:00 am

Hi Guys,

I have only recently started VBS scripting from a C++ background and while I still don't understand the basics of calling a member function from the classes in VBS from the list in the wiki. I was hoping I could clear something else up.

Is there actually restrictions on commands in auto-scripts? Or is it these scripts are ran before the mediamonkey initialisation script that is ran every startup and thus overwrites what I have added?

In the following example the MsgBox displays and the nodes do nothing. If I place these node operations into a Normal Script they work perfectly fine.

Code: Select all

Sub OnStartup
   Dim Tree
   Set Tree = SDB.MainTree
   Tree.Node_Web.Visible = True
   Tree.Node_Radio.Visible = True
   MsgBox "CallMe was called by the action defined in the Scripts.ini file."
End Sub
I am only doing this because I was looking to use a generic script for settings in the future. I have reinstalled MM on quite a few machines many times because of OS issues. I know I can backup the ini file and that has everything in it, though I only really wanted to change a few of the main stuff from the defaults on every PC.

Any ideas?
Click Here to see how Gullible you are.

trixmoto
Posts: 10024
Joined: Fri Aug 26, 2005 3:28 am
Location: Barton, UK
Contact:

Re: Auto Scripting - OnStartup command restrictions?

Post by trixmoto » Tue Nov 26, 2013 4:27 am

I don't know if it would help, but you can delay the running of the script until MM is running properly by doing something like this...

Code: Select all

Sub OnStartUp
  Call Script.RegisterEvent(SDB,"OnIdle","OnAppIdle")
End Sub

Sub OnAppIdle
  If SDB.IsRunning Then
    Call Script.UnRegisterHandler("OnAppIdle")
  
    '<---- your code goes here
  End If
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.
Send me BTC: 34VQPVsf9mCeR4nfhFvvBYZqQ7LkqNZ8Mn
Send me LTC: 3P1mzrfbyscdhbxRpXLgKz7tufGAU3SrEG
Send me DOGE: 9xPpYSqgF7P5yQiqvE1VqWb4UjxVCCLFJ6
Check out these great cryptocurrency faucets... BTC / LTC / DOGE

mcow
Posts: 820
Joined: Sun Sep 21, 2008 9:35 pm
Location: Cupertino, California

Re: Auto Scripting - OnStartup command restrictions?

Post by mcow » Sat Nov 30, 2013 12:07 am

In my experience, changes to the tree only work if the tree is expanded to show the affected nodes. And if you change tabs or otherwise refresh the view, those changes are lost; you need to re-apply them.

Post Reply