I'm attempting to automate an application using AutoIt, and I need to wait for a control to appear within the application before the automation can begin. This control loads shortly after the application starts, but it does not change the window title. How do I wait for the control to appear?
To get a handle to a control on another GUI you need to use the AutoIt Window Info Tool to identify that control. To get the classname of the control go to the tab "Control" and look up the value for "ClassnameNN". Now you can use this value as I did in the example below.
Of course you need to replace "Button1"
with the information you got from the AutoIt Info Tool and modify the window titles accordingly.
Global $hCtrl = 0, $Waiting = True
; your GUI loop
While (1)
If $Waiting And WinExists("Title of OtherApp.exe") Then
$hCtrl = ControlGetHandle("Title of OtherApp.exe", "", "Button1")
If $hCtrl Then
; we got the handle, so the button is there
; now do whatever you need to do
GUICtrlCreateLabel("Button is there!", 10, 10)
$Waiting = False
EndIf
EndIf
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With