Autoit 如何检查 window 是否出现并关闭

Auto it how to check if window appears and close

如何检查特定的 windoww 是否出现在 Autoit 中。

目前我正在运行 Auto it Adob​​e After Effects, 到目前为止一切顺利。

问题是如果用户没有安装 quick time 会弹出警告消息。

现在我想检查 window 是否出现并处于活动状态,然后将其关闭。

到目前为止我有这个但没有用:

    Local $iPID = Run("C:\Program Files\Adobe\Adobe After Effects CC 2015\Support Files\AfterFX.exe", "", @SW_SHOWMAXIMIZED)

    WinWait("[CLASS:AfterEffects]", "", 1000)

    Sleep(200000)

   ; if qicktime warning eror appears
   If WinExists ("DroverLord - Window Class", "") Then
      Send ("{ENTER}")
   EndIf

这有帮助吗?

Opt("WinDetectHiddenText", 1) ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase

#include<Date.au3>

Local $iPID = Run("C:\Program Files\Adobe\Adobe After Effects CC 2015\Support Files\AfterFX.exe", "", @SW_SHOWMAXIMIZED)
If @error Then
    ConsoleWrite('ERROR' & @CRLF)
    Exit(0)
EndIf

Global $end = False
Do
    ; if qicktime warning eror appears
    If WinExists("DroverLord - Window Class", "") Then
        ConsoleWrite('!FOUND ' & _NowTime() & @CRLF)
        Send("{ENTER}") ;close?
        WinClose("DroverLord - Window Class", "") ; this
        WinKill("DroverLord - Window Class", "") ; or this
        $end = True
    EndIf
Until $end

这是您要执行的操作的一些示例代码:

Local $fDiff
Local $sAfterFXPath = "C:\Program Files\Adobe\Adobe After Effects CC 2015\Support Files\AfterFX.exe"

If FileExists($sAfterFXPath) Then
    Local $iPID = Run($sAfterFXPath, "", @SW_SHOWMAXIMIZED)

;no need to call WinExists becuase you are waiting for it to exist and be active with WinActivate

Local $hTimer = TimerInit() ; Begin the timer and store the handle in a variable.

Do
    $fDiff = TimerDiff($hTimer)
Until WinActive("Title you are looking for") Or $fDiff >= 30000 ;<<<will exit loop when the window is active or after 30 seconds

If WinActive("Title you are looking for") Then
    ;Closes the window now that it is active
    WinClose("Title you are looking for")
Else
    MsgBox(0, "", "The window was never active.")
EndIf
Else
   MsgBox(0, "", "File path not found. Do something else...")
EndIf