Triggers: QM events

Launches the macro on certain Quick Macros events. To assign this trigger, use the Properties dialog.



These events occur when opening QM file, for example when QM started. If "Run synchronously" is checked, QM waits until the function ends, therefore it should be fast to avoid QM startup delay. The _command variable is "1" on file change, "2" on QM startup, "3" on Windows startup (QM started with command line parameter S). These events can occur in this sequence: file loaded, QM started, Windows started.


If exists a user-defined function named init2, it is called when opening QM file, before any other functions/macros, after initializing QM extensions. Don't need a trigger for it.



These events occur when closing QM file, for example before QM exits. The function runs synchronously and should be fast. The _command variable is "1" on file change, "2" on QM exit, "3" on Windows shutdown/restart/logoff. These events can occur in this sequence: Windows exits, QM exits, file unloading.


Tray icon

These events occur when you click the QM tray icon. These triggers disable default QM actions (show QM on left click, exit QM on Ctrl+left click, show menu on right click, disable/enable on middle click).


Trigger management

Used by user-defined triggers.


Add to a menu

QM items that have this trigger are added to the QM menu bar, to the New menu, or to the tray menu.


QM 2.2.0. Menu bar triggers launch the macro with two arguments, which are x and y coordinates where popup menu should be displayed.


QM 2.2.0. For macros and menus that have menu bar trigger, you can include & character in macro name. Then next character in menu bar will be underlined, and you can use the keyboard to show the menu.


File link run (QM 2.3.0)

Run when a QM item of type file link is launched. To run only for certain file types or files, specify a filename pattern. Can be used wildcard characters * (matches 0 or more characters) and ? (matches any single character). When you assign the trigger using the Properties dialog, it inserts code that provides file link item id and its file path.


End thread (QM 2.3.0)

Run when the user tries to end a thread in the Threads dialog or in the Running Items list. If the function returns 0, QM does not end the thread. The function, for example, can display a warning message box, or just silently deny the user's request, or correctly end the thread in a special way.


QM show/hide (QM 2.3.3)

QM show: Run when QM window is shown. For example, on tray icon click.


QM 2.4.1. Added option 'Run synchronously'. The function runs before showing QM window. If it returns not 0, QM window remains hidden. Example with password.

if(!inpp("p" "Password to show window" "Quick Macros")) ret 1


QM hide: Run when QM window is hidden. For example, on X button click. Not on QM exit.


Recording ended (QM 2.3.3)

Run when recording ends, except on Cancel. Must be function. Receives recorded macro string, and can change it.