我正在尝试使用AutoIt自动化应用程序,我需要等待控件在自动化开始之前出现在应用程序中.应用程序启动后不久会加载此控件,但不会更改窗口标题.我如何等待控件出现?
要获取另一个GUI上的控件句柄,您需要使用AutoIt窗口信息工具来识别该控件.要获取控件的类名,请转到"控件"选项卡,然后查找"ClassnameNN"的值.现在您可以像我在下面的示例中那样使用此值.
当然,您需要替换"Button1"从AutoIt信息工具获得的信息并相应地修改窗口标题.
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
Run Code Online (Sandbox Code Playgroud)