Window expressions

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

 

1. 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 the active window.

 

2. Window class name. Must be full or with wildcard characters (QM 2.3.4), case insensitive, with + prefix. QM searches all windows. 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. It is an integer value and is returned by functions win, id, child and some other. 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.

 

Window name is text that is displayed in the title bar.

 

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 QM status bar.

 

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

 

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