Command line parameters

Command line

Shortcut

Task Scheduler

Other programs

SendMessage

Command line

Other programs can launch QM macros using command line parameters. To format the command line to launch current macro, click the Cmdline button in Properties.

 

Syntax of QM command line:

 

[V] [E] [S] [Q c] [T] [N "networkfile"] [L[I] "file"] [M[S] "macro" ["command"]] [[C command] | [A[(sep)] arguments]]

 

Here used gray symbols aren't part of command line: [] encloses optional parameters; | is logic "or". Quotes are required. Parameters enclosed in quotes cannot contain quotes. Order of parameters is arbitrary, except C and A.

 

To pass command line parameters to QM, you should use qmcl.exe, not qm.exe. This small program quickly starts, relays the command line to QM and exits immediately. You can use qm.exe too, but some parameters (MS, N, T) are supported only by qmcl.exe.

 

V Show QM window.
E Exit QM when macro ends. Has no effect if QM is already running.
S Tells QM that it is started at Windows startup.
Q c Use character c (any character) instead of " to enclose strings. For example, instead of M "Macro" you can use Q ^ M ^Macro^.
L "file" Load specified QM macro list file. Use LI to import. See also: SilentImport.
M "macro" "command" Run macro and optionally pass some string (command) to it. The macro can access the string through _command variable.
MS "macro" "command" Run macro synchronously. Same as above, but qmcl.exe does not exit while macro is running. The exit code is macro's return value (ret).
C command Alternative way to pass command to macro. Here command isn't enclosed in quotes. It itself can contain quotes.
A arguments Pass arguments to macro. Macro receives them through the function statement. Use spaces to separate arguments. If an argument contains spaces, it must be enclosed in quotes or parentheses. An argument cannot contain quotes (unless it is enclosed in parentheses) and parentheses (unless it is enclosed in quotes). Numeric integer arguments can be numbers, named constants, global variables and expressions with operators. Expressions with operators are evaluated from left to right regardless of operator priority.
A(sep) arguments Alternative way to pass arguments. Here sep is some string that is used to separate arguments. Arguments can contain any characters, including "().
T Used with scheduled tasks.
N "networkfile"

Wait for a file (networkfile) that is on another computer on network and may be still unavailable. Local qmcl.exe waits for the file (max 5 minutes) and launches QM when the file becomes accessible.

 

If networkfile specifies qm.exe, it is launched. This is used when QM is not installed on this computer, and runs from another computer. If networkfile is some other file (e.g., a shared macro-list file on network), is launched local copy of qm.exe. This is used when QM is installed on this computer, but uses one or more shared files that are located on another computer.

 

If QM is already running, or is started while waiting, qmcl.exe exits without passing other command line parameters to qm.exe.

 

Examples:

 

M "Macro"
M "Macro" "some string"
M "Macro" C some string
E L "c:\program files\qm\list3.qml" M "Macro"
M "Macro" A "some string" 1 55.5
M "Macro" A(,,) some string,,1,,55.5

 

Alternatively, can be single parameter in quotes. It can be a macro or a file. If the file is not .qml, adds it as file link and opens in QM (QM 2.3.0). Special folders are not supported. File paths without spaces can be not in quotes. Can be several paths separated by spaces. Examples:

 

"Macro10"
"c:\program files\qm\list3.qml"
c:\Users\G\Desktop\test.txt

 

 

Disabled items don't run from command line trigger.

 

QM command line can be used with:

Shortcut

To create a shortcut to launch current macro, click the Shortcut button in the Properties dialog or in the Icons dialog. You can optionally assign a hot key to the shortcut. The hot key will work even when QM is not running (QM will start).

Task Scheduler

Quick Macros does not have its own scheduler. Instead, it uses Windows Task Scheduler service. It allows to run a macro even when QM is not running (QM will start). To create a scheduled task that runs current macro, click the Schedule button in the Properties dialog. It shows a dialog for that task. To get information about various fields in the dialog, click the ? button on the title bar.

 

Although this is external trigger, QM displays schedule times in the list of macros. Windows Task Scheduler tasks are saved as files in C:\Windows\Tasks folder. QM recognizes only scheduled tasks with filenames in format "QM - Macro Name". When you create a task through QM (click Schedule button in Properties), the task is saved in this format.

 

See also: temporarily unlock computer, Vista issues

Other programs

You can use other programs (scheduler, voice recognition, batch files, etc) to run macros using command line parameters. To copy the command line to the clipboard, click the Cmdline button in the Properties dialog.

SendMessage

Other programs or scripts can launch QM macros more efficiently, by sending a message to the QM main window. Syntax:

 

SendMessage(hwndQM, WM_SETTEXT, mode, commandline)

 

commandline - QM command line string. Don't forget to include quotes.

mode - one of the following values:

1 - run macro or other item asynchronously. QM launches macro and returns control to the calling application.

2 - run function or macro synchronously. SendMessage returns function's return value. This mode forces to run even if item is disabled, or QM command line triggers are disabled.

3 - similar as 2, but function runs in QM main thread. This is faster, because new thread is not created. Can also be used by a macro to call a function that must run in QM main thread. Be careful when creating macros that run in QM thread. Don't use wait commands and other long-running code, because QM may stop responding.

 

Don't use PostMessage or SetWindowText or wParam=0. SendMessageTimeout can be used.

 

Examples