Window前面没有activating/appearing

Window not activating/appearing in front

我有一个脚本可以打开一个网页,登录,然后打开一个程序,应该把程序带到最前面并全屏显示。它会打开 window,但并不总是将其置于最前面,也不会全屏显示。谁能提供任何帮助?这是我的代码:

; Closes last dialog if still open
Sleep(5000)
Send("{ENTER}")
Sleep(500)

; Wait for program to open
WinWait("[CLASS: Program example]","", 5)

;Brings Program to front
if WinExists("[CLASS: Program example]") Then
   WinActivate("[CLASS: Program example]")
EndIf

Sleep(500)

; Sets program fullscreen
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE)

我添加了 WinWait 以查看是否有帮助,但没有帮助。 window 只是留在后面,一动不动。感谢您提供的任何帮助。

有时 AutoIt 不执行某些任务,因为同时发生的事情干扰了命令。确保事情正常进行的最好方法是始终检查任务是否已执行,如果没有执行则重试。这个循环将解决你的问题。

;Brings Program to front
While Not WinActive("[CLASS: Program example]")
    WinActivate("[CLASS: Program example]")
    Sleep(1000) ; Wait one second (or any seconds you want)
WEnd