Set local run-time options

Syntax

opt option value

 

Parameters

option - one of words specified in the table.

value - one of values specified in the table. Default value is 0. To inherit the option from the caller (macro or function that directly called the current function), use value -1. Error if the specified value is not supported.

option When QM uses it value
    0 (default) other
hidden When in macro commands is specified only window name (class is not specified). Search only visible windows. 1 - Search all windows. Hidden windows are always searched when class is specified, also with hid-.
err On run-time error. End macro. Show error. 1 - Continue macro. Don't show error.
end On error, end, etc. Only when in a callback function. Read more in remarks.

End macro softly.

1 - End macro immediately.

waitmsg When waiting (wait, autodelay, etc). Read more in remarks. Completely block thread execution.

1 - Allow to receive Windows messages and COM events.

2 - The same as 1, but sets this option for current thread (not only for current function).

clip Clipboard commands (outp, str.getsel, str.setsel). Preserve (restore) clipboard text. 1 - Do not preserve clipboard text.
waitcpu Autodelay. Read more in remarks. Apply only simple autodelay. 1 - Also apply "wait for CPU" autodelay (Options -> If opt waitcpu ...).
slowmouse Mouse commands. Use to make mouse movements slower, and possibly more reliable in some windows. Immediately move the mouse pointer to the specified point. 1 - Slowly move the mouse pointer. The speed depends on the macro speed (spe) and on the distance.
slowkeys key. Use to make it slower and possibly more reliable. Do not insert delays between keys. Delays may be inserted only if the target window is busy. 1 - Insert a delay after each key event. The speed depends on the macro speed (spe). Particularly, after each key down and up event is inserted delay equal to autodelay/5.
keymark (QM 2.2.0) key. Read more in remarks. Use correct scancodes.

1 - Use modified scancodes.

 

QM 2.3.3. This is default in TS menus.

keysync (QM 2.2.1) key. Use to make it either faster or more reliable.

Use default synchronization method.

 

The macro waits when sent keys are actually received by the target window. Since there is no completely reliable way to know this, it waits only for a limited time period. It also waits while the window is busy. This method is fast and reliable in most cases. However in certain conditions it may be slower.

 

In exe, uses method 2 instead. Waiting until the target window actually receives sent keys is not supported in exe, because it is too expensive (uses hooks in dll).

 

Here "in exe" actually means "in exe, if QM is not running". If QM is running, all synchronization methods work in exe like in QM.

 

Waiting until the target window actually receives sent keys is not supported if the target window is a console window, except in some cases. Instead is used method 2.

 

A special synchronization method is used if the target window belongs to the same thread.

1 - Don't use synchronization. The keys are sent without waiting until the window actually receives them. Fastest. Should not be used if not using low level hooks (unless in exe), because it can create problems with keyboard triggers.

 

2 - Use minimal synchronization. This method is used by default in exe. The macro only waits while the target window is busy. The synchronization does not work well (keys may be sent too fast) with some windows and in stress conditions (low memory, busy CPU, etc). Slowest in most cases (about 20-100 %). Should not be used if not using low level hooks (unless in exe), because it can create problems with keyboard triggers.

 

3 - Use maximal synchronization. The macro indefinitely waits until the key is received by the target window. Since there is no completely reliable way to know this, in some windows this can force the macro to wait indefinitely. Therefore this method should not be used in macros designed to work in any window. Exe uses method 2 instead.

hungwindow (QM 2.3.0) With key and clipboard functions, when the active window is hung. While the window is hung, waits and shows a message box with Abort and Ignore buttons. On Abort the macro would end (error). On Ignore the macro would continue (don't wait).

Don't show a message box.

 

1 - wait indefinitely while the window is hung.

 

2 - abort. Same as if the user would click Abort.

 

3 - ignore. Same as if the user would click Ignore.

nowarnings

(QM 2.3.3)

On run-time warning. Warnings can be generated by some QM functions and user-defined functions (end). Show warnings. 1 - don't show warnings.

keychar

(QM 2.3.3)

With key, when using "text" or string variable. Use to type exact text.

Send normal keys. The active window receives WM_KEYx messages with usual virtual-key codes. In some rare conditions the typed text may be not exactly the same as in macro, because it depends on keyboard state. Send keys as characters. The active window receives WM_KEYx messages where virtual-key code is VK_PACKET. The typed text will always be as in macro. However in some windows it may not work.

 

Remarks

Changes a run-time option locally (only for current instance of running function or macro).

 

If used as function, opt is identical to getopt (returns current value).

 

opt waitmsg 1 should be used if you use wait commands (explicit or implicit, e.g. autodelay or clipboard commands) in thread (running macro) that has a window (or dialog). While waiting, window must process messages. Without this option, it cannot process messages. This causes various anomalies, such as window not responding, etc. This option also is often necessary when working with COM, especially with events.

 

Macro that contains opt waitcpu 1 or "wait for CPU" commands, with some processor-hungry programs may run very slowly or produce "wait timeout" errors. Some programs constantly or occasionally use 100% CPU, even when they are ready for input.

 

To see CPU usage, use Windows Task Manager or perfmon.exe. You can also use GetCPU function.

 

opt end 1 can be used in callback function if an "end macro" command (end, mes-, etc) does not work (it is rare, and can occur if callback's caller handles all exceptions). QM also uses it on run time errors (including end "error"). Ending macro when this option is set may cause memory leak, because local composite variables of callback's caller functions cannot be destroyed. Thread variables are always destroyed. Functions registered by atend are always called.

 

About opt keymark 1: For keyboard triggers and some other features, QM uses keyboard hooks to intercept keyboard events. QM processes QM-pressed (injected) keys differently than user-pressed (real) keys. For example, a macro cannot trigger a hot-key macro using the key command. However, when the user presses or releases a key simultaneously with the key command, QM processes the key event like generated by the key command (there is no reliable way to distinguish real and injected keys, unless you use low level hook). If it is a trigger-key, the trigger will not work. If it is a wait-key (wait 0 K), the macro will not stop waiting. Also, user-pressed keys may be inserted (typed) between QM-pressed keys. There are two ways to avoid all these problems: 1. Use low level keyboard hook. 2. Insert opt keymark 1 before key. However then in some windows some keys may not work as expected. When using low level keyboard hook, opt keymark 1 does not change anything (everything works well with or without it).

 

See also: hid err end Errors wait wait for outp str.getsel key getopt Options->Run time

 

Example

 set local run-time option "search hidden windows"
opt hidden 1