Find child window (get handle); evaluate properties

Syntax1 - get specified object

int child(text [class] [window] [flags] [x y] [matchindex|array])
int childtest(hwnd text [class] [window] [flags] [x y])

 

Syntax2 - get specified object (include id)

int child(id [text] [class] [window] [flags] [x y] [matchindex|array])
int childtest(hwnd id [text] [class] [window] [flags] [x y])

 

Syntax3 - get object from point

int child(x y [window] [flags2])
int childtest(hwnd x y [window] [flags2])

 

Syntax4 - get object from mouse pointer position

int child(mouse)
int childtest(hwnd mouse)

 

Syntax5 - get object from accessible object

int child(acc)
int childtest(hwnd acc)

 

Syntax6 - get focused object

int child

 

Parts

text - child window text. By default, text can be partial and must match case. Underlined character must be preceded with &. Empty string ("") matches any text.

class - child window class name. Must be exact, case insensitive. Default: "" (any). You can see it in the QM status bar.

window - parent window. If omitted or "" - active window. The function searches only in the first found matching window.

flags - combination of values listed below. Default: 0.

1 text must match exactly or may contain wildcard characters (*?). String "*" matches child windows with no name. This flag cannot be used with flag 0x200 (regular expression).
2 text case insensitive
4 must be set for edit, rich edit and some other controls
8 x and y are coordinates in window client area
16 immediate child
32 x and y are screen coordinates
8|32 x and y are coordinates in the work area
128 x is style. Cannot be used with 0x8000.
0x100 y is extended style. Cannot be used with 0x8000.
0x200 text is is regular expression. Alternatively, use $ character at the beginnig. Flags 1, 16 and 0x200 cannot be used together.
0x400 must be visible.
0x800 use wildcard characters in class.
0x8000 use callback function

x, y - define a point in the parent window or screen (flag 32) that must belong to the child window. If x and y are 0, and followed by more arguments, they are not evaluated.

matchindex (QM 2.2.0) - 1-based index of matched child window in the parent window. Use when there are several child windows (in the parent window) that match other properties (text, class, flags, x, y, id). If 1, will find first matching child window; if 2, will find next matching child window, and so on. If omitted or 0, the function prefers visible child windows. Does not prefer visible child windows if matchindex is nonzero (QM 2.2.1).

array (QM 2.2.1) - variable of type ARRAY(int) that will receive handles of all matching child windows.

id - child window id.

 

flags2 - combination of values listed below. Default: 0.

8 x and y are coordinates in client area of window
16 immediate child
32 x and y are screen coordinates
8|32 x and y are coordinates in the work area

accobj - accessible object. Type - Acc or IAccessible.

hwnd - handle of child window to test.

 

Remarks

Finds a child window (control) in the specified window, and returns its handle. Returns 0 if not found. Error if parent window does not exist.

 

Syntax1 and 2: finds child window whose text and other properties match the specified properties.

 

Syntax3: Returns handle of child window from the specified point in its parent window. If window is omitted or "" - active window. If window is 0 (constant), parent can be any window (x and y are screen coordinates).

 

Syntax4: Returns handle of child window (except invisible) from mouse pointer position.

 

Syntax5: Returns handle of child or top-level window that matches or contains accessible object accobj.

 

Syntax6: Returns handle of child window that has focus. To get focused window of current thread, use GetFocus instead.

 

Function childtest evaluates child window (hwnd) properties, and returns 1 if they match, or 0 if not. If window is omitted or literal 0, parent window is not evaluated.

 

See also: id acc htm

 

Examples

act child("Hex" "Button" "Calculator")
if child("The text*" "Static" "Notepad" 1)
	bee
int h = child(100 100 "Notepad")
h = child(mouse)
if(childtest(h "OK" "Button")) but h