Page 1 of 1

How to add Script to Context menu?

Posted: Sat Jan 11, 2014 7:00 pm
by dtsig
I am looking for a sample 'stub' script which adds its name to the Context menu (right-click) and then can be executed. Anyone know of one?
Thanks

Re: How to add Script to Context menu?

Posted: Mon Jan 13, 2014 4:11 am
by trixmoto
Yeah, some of my scripts definitely do this, but I can't think of one of the top of my head. I'll have a look later and let you know.

Re: How to add Script to Context menu?

Posted: Mon Jan 13, 2014 7:42 am
by trixmoto
My "Randomise Playlist" script adds an item to the tree's context menu, and uses a it's own "ShowMenu" function to determine whether or not it should be visible...

Code: Select all

    Set itm = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_Tree,1,0)
    itm.Caption = "Randomise Playlist"
    itm.OnClickFunc = "ItmClick"
    itm.UseScript = Script.ScriptPath
    itm.IconIndex = 25  
    itm.Visible = False
    Set SDB.Objects("RandomisePlaylistMenu") = itm
    Call Script.RegisterEvent(SDB,"OnChangedSelection","ShowMenu")

Re: How to add Script to Context menu?

Posted: Mon Jan 13, 2014 7:45 am
by trixmoto
My "Previewer" script adds an item to the Now Playing list's context menu and the main window's context menu...

Code: Select all

    Dim itm1 : Set itm1 = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_NP,0,0)
    itm1.Caption = "Previewer"
    itm1.OnClickFunc = "Toolbar"
    itm1.UseScript = SDB.ApplicationPath&"Scripts\Previewer.vbs"
    itm1.IconIndex = IconIndex
    Set SDB.Objects("Previewer-Menu1") = itm1
    Dim itm2 : Set itm2 = SDB.UI.AddMenuItem(SDB.UI.Menu_Pop_TrackList,0,0)
    itm2.Caption = "Preview this track"
    itm2.OnClickFunc = "Toolbar"
    itm2.UseScript = SDB.ApplicationPath&"Scripts\Previewer.vbs"
    itm2.IconIndex = IconIndex
    Set SDB.Objects("Previewer-Menu2") = itm2

Re: How to add Script to Context menu?

Posted: Mon Jan 13, 2014 11:40 am
by dtsig
Great .. thanks man. I will start studying these.