Triggers: window

Launches the macro when the specified window appears, disappears, is activated, etc.

 

To assign this trigger, use the Properties dialog. You can use the Drag tool to fill window name/class fields. While dragging, you can right-click to send window to bottom, or Ctrl+Shift+right-click to send child window to bottom.

 

You should always specify window class. If it isn't specified, QM ignores some windows, e.g. windows without caption.

 

You can also specify text/class of a control (child window) of the window. Accessible objects (e.g., objects in web pages) are not supported.

 

You can also specify window style - numeric value, or p (popup), or m (not popup).

 

Window name and control text can be partial. Must match case. If empty, matches any.

 

If "Use *" is checked, window name and control text must be full or with wildcard characters * and ?. For example, to tell that window name must end with " - Notepad", check "Use *" and enter "* - Notepad". To tell that window name must be exactly "Notepad", check "Use *" and enter "Notepad". String "*" matches windows with no name.

 

In the window name field, you can use regular expression. First character must be $. For example, $Word.*\.(?i)rtf$ matches window name that contains "Word" and ends with ".rtf" or ".RTF" (the first $ tells that you use regular expression, .* means any number of any characters, \. means literal ., (?i) sets "case insensitive" option, the last $ means end of window name). Regular expression can be used to identify more than one window. Example: $(Notepad|Calc). When using regular expression, "Use *" is not applied to window name.

 

Class names must be full. Can contain wildcard characters, regardless of the "Use *" option (QM 2.3.4). If empty, matches any.

 

To launch macro when window is created (appears first time), you should select "Created & active". If window is shown but not activated, select "Created & visible". To launch macro each time when window is activated, select "Activated". You can use "Activated" with toolbars (this does not create more instances of the same toolbar on the same window). To launch macro each time when window name is changed and matches the specified name, select "Name changed".

 

If "When idle" is checked, the macro starts only when the window is not busy and is ready to receive user input. However, the macro may not run with some windows, for example if the window is busy (uses CPU) all the time.

 

Several items can have same "Window" trigger. For example, a window can have several toolbars.

 

A window-triggered macro receives that window handle through _command variable. To get it, you can use val(_command) or TriggerWindow.

 

The "destroyed" trigger is unreliable with 64-bit windows. Also if checked "Other" in Options -> Triggers -> Low level hooks. Instead use a function that gets window handle and waits until it is destroyed. Example:

 

 trigger: window created
int hwnd=TriggerWindow
wait 0 -WC hwnd
out "window destroyed"

 

 

See also: Properties