ShowMenu

ShowMenu(MenuDef,  
MenuName = "",
Sub = "",
Sep = "`n",
r = 0)

Show menu from the text string.

Parameters

MenuDefTextual menu definition.
MenuNameMenu to show.  Label with the same name as menu will be launched on item selection.  “” means that first menu will be shown (default).
FunMenu handler.  If Empty, defaults to the menu name + “On” prefix.
SepSeparator char used for menu items in menu definition, by default new line.

Returns

Message describing error if it ocured or new line separated list of created menus.  If return value is blank, ShowMenu just displayed menu already created in one of previous calls.

Remarks

You must have in the code label with the same name as that given to the menu, otherwise ShowMenu returns “No Label” error (unless you used “sub” parameter in which case the same applies to that subroutine).  There must be no white space between menu name and start of the line.  Set each menu item on new line, use “-” to define separator.  To create submenu, use “item = [submenu]” notation where submenu must exist in the textual menu definition.  While referencing any particular menu as submenu multiple times will work correctly, circular references will produce unexpected results.  You can use = after item to store some custom data there.  If text after = doesn’t contain valid submenu reference, it will just be removed before item is displayed.  To make menu definition more compact use something else then new line as item separator for instance “|” :

MenuDef=
(LTrim
    [MenuName1]
    item1|item2|item3|-|item4=[MenuName2]|item5
    [MenuName2]
    menu21 = menu21|menu22|menu23|menu24
)

You can then use this command to show the menu :

ShowMenu(MenuDef, "MenuName1", "", "|")                     ;use | as item separator.

About

v2.0 by majkinetor.  See: http://www.autohotkey.com/forum/topic23138.html

Close