Window expressions

When window is required as part of a macro command, you can use:

 

1) Window name. Window name can be partial, must match case. Must be enclosed in quotes, unless it is variable. QM searches only visible windows, unless run-time option opt hidden 1 is set. Examples:

 

act "Notepad"

str s = "Notepad"
act s

 

If name begins with $ (but not with $$), it is interpreted as regular expression. For example, act "$^A.*Notepad$" activates window whose name begins with "A" and ends with "Notepad". To do case insensitive search, use (?i). For example,

 

act "$(?i)^A.*Notepad$".

 

Empty string ("") in most cases is interpreted as active window.

 

2) Window class name. Must be full, case insensitive, with + prefix. QM searches all windows. Regular expresions are not allowed. Example:

 

act "+ieframe"

 

3) List of window names and/or +classnames, delimited by [] (new line). If first window not found, searches for second window, and so on. Example:

 

ifa "Window1[]$Window\d[]+Window3"
	out "One of three windows is active"

 

4) Window handle. Unlike window name and class, it can also be used with user-defined and dll functions. Window handle is integer value and is returned by functions win, id, child, WinC, FindWindow, etc. Examples:

 

int h = win("Notepad")
act h

act win("Notepad")

 

Window expression (handle or name, etc) also can be stored in a variable of type VARIANT.

 

With macro commands, if window (still) does not exist, QM waits max 0.5 second, unless speed (spe) is 0 or window handle (variable or function except win) is used.

 

A window name is text that is displayed in the title bar. For most child windows (controls) it is text of control (e.g., button's label or text of edit control).

 

Each window or child window belongs to some window class (e.g., "IEFrame", "Button", etc). Window class defines appearance and behavior of all windows that belong to it. Window class is set by software developer and cannot be changed. However, some windows are created with different class each time (e.g., those that begin with "Afx:"). You can see window name and class name in the QM status bar.

 

A window handle is an unique numeric value that the system assigns to each window and child window when creating it. The handle does not change until the window is destroyed.

 

A child window id is a numeric value that the developer assigns to it. In most cases, it is unique within its parent window. Sometimes id may be set at run time and it may be random value.

 

See also: window styles