AutoIT Wait for the control to appear.

I am trying to automate the application using AutoIt, and I need to wait for the control to appear in the application before starting automation. This control loads soon after starting the application, but it does not change the window title. How to wait for a control to appear?

+5
source share
2 answers

To get a control handle for another GUI, you need to use the AutoIt Window Info Tool to identify this control. To get the class name of the control, go to the "Management" tab and find the value for "ClassnameNN". Now you can use this value, as in the example below.

Of course, you need to replace the "Button1"information obtained from the AutoIt Info Tool and change 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
+7
source

I would like to add an answer to Mott. For example, I'm trying to get a moment when the name inside the black oval is already visible, i.e.

But here is the first stage of the launch, when it is $hCtrlclearly NOT displayed

$hCtrl = ControlGetHandle("Title of OtherApp.exe", "", "Static13") ad-hoc TRUE (- <HWnd>0x000...192 ..)

, () ControlGetHandle:

ControlGetHandle("Title of OtherApp.exe", "", "Static13") 
-1

All Articles