If window is active/focused

Syntax

ifa[-] window
(tab)statements
(tab)...
[else
(tab)statements
(tab)...]

 

Can be single line:

ifa[-](window) statements
[else statements]

 

Parameters

window - top-level or child window.

 

Options:

- not.

 

Remarks

Similar to if.

 

If window exists and is active, executes statements after ifa and skips statements after else (if used). Else skips statements after ifa and executes statements after else (if used). If child window, tests whether it has focus.

 

QM 2.3.3. Can be used as function. Return 1 if the window is active, 0 if inactive or not found.

 

Tip: For "if window exists" use win and if. See the last example.

 

See also: wintest

 

Examples

ifa "Notepad"
	out "''Notepad'' is active"
	key Cv
else
	act "Notepad"
	bee

 use as function
if(ifa("Notepad") or ifa("WordPad")) out "Notepad or WordPad window is active."

 check if exists
int w=win("Notepad" "Notepad")
if w
	out "''Notepad'' exists"