Page 1 of 1

Cannot Programmatically Add Items to Scripts Menu

Posted: Sun Oct 19, 2014 4:36 am
by tj_junk
Running MM4.1.5.1714 on Windows Vista:

You cannot add separators, submenus, or menuitems to the Scripts menu (SDB.UI.Menu_Scripts) from a script OnStartUp() method.

Try adding the code below to the OnStartUp() method of any auto-script. It should add two separators, a submenu, and a menuitem to the Scripts menu, but none of those items appear anywhere in the MM menu system, even after restart. However, if you change the ParentMenuItem to any other menu (e.g., Menu_Tools, Menu_Help, Menu_View, Menu_Pop_TrackList), it works exactly as expected.

Code: Select all

' Menu_Scripts seems to not be supported here
' (But, if you replace 'Menu_Scripts' with 'Menu_Tools' or 'Menu_Pop_Tracklist', it will work as expected)

' Add separator to scripts menu
SDB.UI.AddMenuItemSep SDB.UI.Menu_Scripts, 0, 0  

' Add submenu to scripts menu
Dim MySubMenu
Set MySubMenu = SDB.UI.AddMenuItemSub(SDB.UI.Menu_Scripts,0,0) 
MySubMenu.Caption = "XXX submenu (within Scripts)..." 

' Add menuitem to new submenu
Dim MySubMenuItem
Set MySubMenuItem = SDB.UI.AddMenuItem(MySubMenu, 0, 0) 
MySubMenuItem.Caption = "YYY MenuItem in XXX submenu (within Scripts)" 
MySubMenuItem.UseScript = Script.ScriptPath 
MySubMenuItem.OnClickFunc = "RunSomeMethod" 

' Add another separator to scripts menu
SDB.UI.AddMenuItemSep SDB.UI.Menu_Scripts, 0, 0

' Add menuitem to scripts menu
Dim MySubMenuItem2
Set MySubMenuItem2 = SDB.UI.AddMenuItem(SDB.UI.Menu_Scripts, 0, 0) 
MySubMenuItem2.Caption = "ZZZ MenuItem (within Scripts)" 
MySubMenuItem2.UseScript = Script.ScriptPath 
MySubMenuItem2.OnClickFunc = "RunSomeMethod" 
Am i doing something wrong? Or, it is because the Scripts menu is dynamically generated from the Scripts.ini?

If this is NOT a bug or a programmer error, then please update the help wiki to inform developers that Menu_Scripts cannot be used a ParentMenuItem for the AddMenuItemSep, AddMenuItemSub, and AddMenuItem commands, and please add a request to the wishlist that Menu_Scripts be supported as a ParentItem for those commands.