测试窗口是否响应



我有这个脚本来运行在线游戏,点击启动屏幕,为我输入我的密码。 然而,自从最新的补丁以来,%MWOStartupTime%变得相当不可预测,这不再可靠地工作。我怀疑游戏正在触发一些早期的网络请求。什么的。

所以这里有一个问题:我是否可以以某种方式测试给定的窗口是否不仅存在而且响应迅速,而不是等待固定的时间?这样我就可以循环,等待响应窗口并开始"点击"。

我也对其他想法/解决方案感到高兴。如果事实证明我需要使用 WinAPI,我也可以用真正的编程语言重写它。

Run, MWOClient.exe, %MWODirectory%
; Wait for the Client to launch
WinWait, MechWarrior Online,, 20
WinActivate, MechWarrior Online
; Wait until the window is responsive
Sleep, %MWOStartupTime%
; Press Escape a few times to skip the loading screens
Loop %MWOScreenLoops% {
WinActivate, MechWarrior Online
Sleep, %MWOScreenTime%
SendInput {Esc}
}
; Click the password textbox
WinActivate, MechWarrior Online
Click %MWOPasswordBoxXCoord%, %MWOPasswordBoxYCoord%
Sleep 500
; Type the password
WinActivate, MechWarrior Online
SendInput %MWOPassword%
Sleep 500
; Copy the password to the clipboard in case the 
; password input fails
clipboard = %MWOPassword%
; Click login
Click %MWOPlayButtonXCoord%, %MWOPlayButtonYCoord%

您是否尝试过使用 WinWaitActive 关注 WinActivate ?您应该能够删除"睡眠"命令。

WinActivate, MechWarrior Online WinWaitActive, MechWarrior Online

https://www.autohotkey.com/docs/commands/WinWaitActive.htm

最新更新