Option 1: WinExist title, control_name
when inspecting with AU3_Spy.exe, you may find control name in text. In that case, just
IfWinExist
wintitle
, SunAwtCanvas1
will do.
Though I like functional syntax more, particularly because because Egyptian brackets available with it:
If (WinExist(wintitle, "SunAwtCanvas1")) {
// …
}
Option 2: ControlGet
If control name is not in text, or if it is in but may be invisible, and you want to know if it's visible, ControlGet can read some properties of the control.
If the control does not exist, ErrorLevel is set to 1 and OutputVar is made blank. Also, it will throw an exception inside Try {} block.
Also, some controls may be pre-created but invisible. So, to check if control is displayed:
ControlGet ctrlVisible, Visible,, SunAwtCanvas1
If (ctrlVisible) { // like IfControlVisible
// …
}
AFAIK there's no WinWait-like operators for controls, but simple loop will do:
// add IfWinExist or WinWait somewhere before to fill in LastWindowFound
Loop
{
ControlGet ctrlVisible, Visible,, SunAwtCanvas1
Sleep 100 ; to avoid high CPU load, and to allow app finish its operations in case control is found in middle of something (that's why it's after ControlGet, not before)
} Until ctrlVisible
In this example, ControlGet will wait for a control to appear in LastWindowFound. Or you can specify wintitle/wintext/excludetitle/excludetext right in ControlGet as parameters.