gpt4 book ai didi

AutoIt 等待控制元素出现

转载 作者:行者123 更新时间:2023-12-04 14:30:31 24 4
gpt4 key购买 nike

我正在尝试使用 AutoIt 自动化一个应用程序,我需要等待一个控件出现在应用程序中,然后才能开始自动化。此控件在应用程序启动后不久加载,但不会更改窗口标题。如何等待控件出现?

最佳答案

要获得另一个 GUI 上的控件的句柄,您需要使用 AutoIt Window Info Tool以识别该控件。要获取控件的类名,请转到“Control”选项卡并查找“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

关于AutoIt 等待控制元素出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14571668/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com