mac[+|-] [macro] [command] [a1 ...]
Can be used as function:
int mac([macro] [command] [a1 ...])
macro - QM item name (string) or id (integer). Default: "" - current item (in editor).
command - some string or number. How it is interpreted depends on item type. Default: "".
| If macro is | command is interpreted as |
|---|---|
| Macro or function | Something to be stored into the _command variable. |
| Toolbar | Window to be associated with the toolbar. Can be window name or handle. If the window does not exist, not error, and the toolbar will not be created. |
| Menu | Menu item label. Instead of showing menu, will execute that item. |
| Other | Not used. |
a1 ... - arguments for macro. It receives them through function statement.
| Default | Run macro. |
| + | Open macro in editor (don't run). |
| - | End this thread and run macro. |
Launches macro. Unlike function call, macro runs asynchronously, in separate thread.
Error if macro does not exist when mac is executed.
Supported QM item types: all except folders and member functions.
Two macros cannot run simultaneously. If both items (this thread and macro) are macros (not functions, etc), macro starts when this thread ends. If only macro is macro, is applied "If a macro is running" property.
mac can be used as function. The return value depends on item type.
| If macro is | mac returns |
|---|---|
| Macro or function | Thread handle. You can use it, for example, to wait until the macro exits. Don't close the handle.
If macro is macro (not function), mac returns 0 if macro cannot be launched now (because another macro is running). |
| Toolbar | Toolbar window handle. Read more. |
| Menu | If used as function (like variable=mac("menu")), mac waits until the menu is closed. It then returns a nonzero value if an item clicked, or 0 if not. If used like mac "menu", it does not wait. Read more. |
| File link | Thread handle of function that has "file link run" trigger for that file type. |
| Other | 0 |
To quickly insert mac command, you can drag and drop.
See also: functions, net, RunTextAsFunction, wait for macro, find macro, create macro.
mac "Macro5" ;;run macro "Macro5" mac "\Folder\Macro5" ;;run "Macro5" that is in "Folder" folder mac- "Macro5" "a" ;;end current macro and run "Macro5". Also, send string "a" as command. mac "Func" "" "some string" 1 55.5 ;;run function "Func" and send three arguments Get id of "Macro5" and run it: int i = qmitem("Macro5") mac i If window "Notepad" exists, create toolbar "TB" and attach it to the window: mac "TB" win("Notepad") Run function "Function" and wait until its thread ends: int hThread=mac("Function") wait 0 H hThread Call function Function (unlike mac, it does not create new thread): Function