You can create simple popup menus and replace the default system tray menus
for DesktopX and widgets with scripting.
To create a popup menu use DesktopX.CreatePopupMenu.
I.e.
Dim menu
Set menu = DesktopX.CreatePopupMenu
menu.AppendMenu 0, 1, "Item1"
menu.AppendMenu 0, 2, "Item2"
Dim result
res = m.TrackPopupMenu(0, System.CursorX, System.CursorY)
Note: popup menus cannot be used by scripts that run in a separated thread.
Syntax as follow:
AppendMenu
AppendMenu flags, ID, text
ID is the item identifier. When the menu is shown and the user selects an
item, TrackPopupMenu will return the ID of the item.
Text is simply the text.
Flags let you specify the following options you can combine:
&H00000800 – Menu separator
&H00000001 – Grayed
&H00000002 – Disabled
&H00000008 – Checked
&H00000010 – Popup
&H00000020 – Menu bar break
&H00000040 – Menu break
&H00000080 – Hilite
Popup (&H00000010) let you add a submenu. You can do like this:
Dim submenu
Set submenu = DesktopX.CreatePopupMenu
submenu.AppendMenu 0, 1, "Item in submenu"
Dim menu
Set menu = DesktopX.CreatePopupMenu
menu.AppendMenu &H00000010, submenu.MenuID, "Sub menu"
menu.AppendMenu 0, 2, "Item in main menu"
TrackPopupMenu
Result = TrackPopupMenu(flags, posx, posy)
It let you open the menu. It returns the ID of the selected item.
Posx and posy are the screen coordinates where the menu should open.
Flags let you specify some options:
&H00000004 – Center align
&H00000008 – Right align
&H00000010 – Vertical center align
&H00000020 – Bottom align
Example:
res = m0.TrackPopupMenu(0, System.CursorX, System.CursorY)