Command line parameters

Command line

Shortcut

Task Scheduler

SendMessage

Command line

Other programs can run QM macros using command line parameters. To create command line for 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:

 

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, 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, if QM was not running.

 

Tip: instead you can craete exe from the macro and run it with a command line.

S Indicates that QM started at Windows startup. QM uses it for trigger 'Windows started'.
Q c Use character c instead of " to enclose strings. For example, instead of M "Macro" you can use Q ^ M ^Macro^.
L "file"

Open specified QM file.

  • Use LI to import.
  • See also: SilentImport.
  • Opens in the File Viewer if LI or if the file is unknown (not in the recent files list in the File menu).
M "macro" "command"

Run macro.

  • Can be macro name or GUID.
  • You can pass some string (command) to the macro. It will be in variable _command.
  • Use MS to run synchronously. Qmcl.exe waits while macro is running and returns its return value (ret).
  • QM 2.4.0: Not supported with L and LI.
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. Qmcl.exe waits for the file (max 5 minutes) and launches QM when the file becomes accessible. If QM is already running, or is started while waiting, qmcl.exe exits and does not pass command line to QM.

 

Examples:

 

M "Macro"
M "Macro" "some string"
M "Macro" C some string
M "Macro" A "some string" 1 55.5
M "Macro" A(,,) some string,,1,,55.5

 

Or whole command line 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. 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 desktop shortcuts, Task Scheduler and other programs that can launch programs with a command line.

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 hotkey 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 or edit a scheduled task that runs current macro, click the Schedule button in the Properties dialog.

 

Although this is an external trigger, QM displays schedule times in the list of macros.

 

QM 2.4.2. Creates and manages scheduled tasks configured for Windows Vista and later. Also supports previously created XP tasks.

 

See also: unlock computer

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:

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 wParam=0. Can use SendMessageTimeout. Can use FindWindow("QM_Editor", 0) to get QM window handle.

 

Example in QM: SendMessage(_hwndqm WM_SETTEXT 3 "M ''func''")