Pop-up menu

Pop-up menus are used to launch macros, files, and to execute any other commands. To create new menu, click menu File -> New -> New Menu.

 

The following information applies to pop-up menus and toolbars (syntax is almost identical). For example, "menu item" in most cases also means "toolbar button".

Menu items

Each line in menu text creates one menu item. Syntax:

 

[label ]:statements[ * icon]

 

label - menu item's text. Optional. Can contain escape sequences.

statements - one or more commands. If several commands are used, use semicolon to separate.

icon - icon file.

 

There are also two simpler forms:

 

1. Run macro:

Macro[ * icon]

 

2. Run file:

[label ]"file"[ * icon]

 

Here Macro is macro name, which also is menu item's label; file is file name (ful path or filename) or ITEMIDLIST string.

 

Lines that begin with space or semicolon can be used for comments.

 

Menu items can be added using dialogs from the floating toolbar. Also, you can drag and drop macros, files and Internet links.

 

Menu example:

My Macro :mac "My Macro"
IE :run "iexplore.exe"
Select All :key Ca * text.ico
Arial italic :spe; men 57696 "WordPad"; key "Arial" TPDY
:mes "Label is optional"
-
 comments
My Macro
IE "iexplore.exe"

 

Separators

-  horizontal separator (for toolbars, it can be vertical or horizontal).

-digits wide separator (for toolbars only). Digits is separator width.

|  vertical separator (for menus).

Submenus

Submenus are created using > and < characters, as in the example below. Line that begins with > opens submenu. Line containing only < ends the submenu. Submenus in toolbars are not supported. Example:

 

Macro1
>Submenu
	Macro2
	Macro3
	<
Macro4

Expanding file folders (QM 2.2.0)

In menu Properties you can set to expand file folders, ie automatically create submenus of files. Use the following syntax to create an expandable folder item:

 

Label "folder" ["folder2" ...][ * icon]

 

Label usually is folder name, although can be any text. Folder can be folder path or ITEMIDLIST string. If several folders are specified (max 10), they are merged.

 

Example menu:

 

 /expandfolders
Start "$start menu$" "$common start menu$"
Desktop ":: "
My Computer ":: 14001F50E04FD020EA3A6910A2D808002B30309D"
C:\ "C:\"

 

 

If the menu contains only single expandable folder item and no other items, the folder is expanded in the main popup menu, otherwise it creates submenu.

 

In Include/Exclude fields (in Properties), you can specify one or more patterns of files to be included or/and excluded. If both fields are empty, included are all files. Read more.

Special characters in menu item labels

To create keyboard shortcut (underlined letter) for a menu item, insert & before the letter. Example: L&abel. Use && for simple &. Also, you can select an item with arrow keys and execute with Enter. Use Esc to close the menu or current submenu.

 

QM 2.2.0. To append hotkey name or some other text aligned at the right, insert tab. It can be literal tab, or several tabs, or [9]. Example: Label[9]Ctrl+Shift+U.

How to show a menu from code

To show a menu from code (e.g. from a macro, another menu or toolbar) use mac. If used as function (like variable=mac("menu")), mac waits until the menu is closed. It then returns 1-based index of selected line, or 0. Note that lines not necessary match visible menu items, because menu can have comments, separators, etc. If used like mac "menu", it does not wait.

 

QM 2.2.0. For expanded folder items, mac returns -1. To get last clicked item info, use function GetLastSelectedMenuItem after mac. The function also can be used to get info of other items.

 

QM 2.2.0. In Properties you can set to not run the command/file/macro when a menu item is clicked. The macro for example could get file path using GetLastSelectedMenuItem and do some other action.

 

QM 2.2.0. While mac waits until the menu is closed, it processes messages. In previous versions, mac did not process messages, and therefore showing menus from dialogs did not work well.

 

If menu is launched with a command (e.g., mac "Menu" "command"), the command is interpreted as menu item label, and, instead of showing menu, that item is executed.

 

QM 2.2.0. Menu position can be specified:

 

mac "Menu" "" x y flags

 

Here flags are TrackPopupMenuEx flags, e.g. TPM_RIGHTALIGN. To use default position, x and y can be "".

 

See also: menu bar triggers

Sub-functions

Sub-functions can be used in menus, as well as in QM items of other types. The first #sub directive ends menu text. Use sub-functions for menu items that have multiple code lines and you don't want to create separate macros for them.

 

Example menu:

 

A :out sub.Add(3 1)
B :sub.Sub1

#sub Add
function# a b
out __FUNCTION__
ret a+b

#sub Sub1 m
 With m attribute, this sub-function is used as menu item text, not called as function.
out __FUNCTION__

 

Like in all functions, default speed (spe) in sub-functions is 0. In sub-functions with m attribute it is like in macros and menu items, default 100.

The right-click menu (QM 2.2.0)

When you right-click a menu item, pops up another small menu. You can use it to quickly open the menu in QM, open the target macro, or open the folder of the target file. To right-click an item that opens a submenu, at first press Esc to close the submenu.

 


See also: menu and toolbar icons, menu options, hybrid paste, DynamicMenu, ShowMenu, ListDialog, ShowDropdownList.