2017-04-04 24 views
0

使用AutoIt 3.3.14.2啓動Entrust etunprot.exe應用程序。委託申請開始,但沒有重點。應用程序啓動後,AutoIt腳本應該輸入密碼,但不是因爲沒有焦點。當我點擊應用程序以使其焦點集中時,輸入密碼並且腳本繼續併成功完成。我最初使用WinWaitActive並將其替換爲WinWait和WinActivate以嘗試解決該問題。下面是代碼:自動啓動應用程序,無焦點

; Terminate script if no command-line arguments 
If $CmdLine[0] = 0 Then Exit (1) 

Run("C:\Program Files\Entrust\Password Unprotect\etunprot.exe " & $CmdLine[1]) 

WinWait("Entrust Password Unprotect", "OK") 
WinActivate("Entrust Password Unprotect", "OK") 

; Enter the password text 
Send("password") 
; Submit the password 
Send("{ENTER}") 

WinWait("Entrust Password Unprotect", "Enter name of output folder") 
WinActivate("Entrust Password Unprotect", "Enter name of output folder") 

; Enter the name of the output folder 
Send($CmdLine[2]) 
; Unprotect the enp file 
Send("{ENTER}") 

回答

0

嘗試

WinWait("Entrust Password Unprotect", "") 
WinActivate("Entrust Password Unprotect", "") 
+0

試過這個想法,但行爲是一樣的。謝謝。 –

0

試試這個讓你的程序的窗口。也許它可以幫助你。

#include <Array.au3> 
$re = ProcessGetWindow(ProcessExists('Greenshot.exe')) 
_ArrayDisplay($re) 


Func ProcessGetWindow($PId) 
    $PId = ProcessExists($PId) 
    If $PId = 0 Then 
     SetError(1) 
    Else 
     Local $WinList = WinList() 
     Local $WindowTitle[1][2] 
     Local $x = 0 
     For $i = 1 To $WinList[0][0] 
      If WinGetProcess($WinList[$i][1], "") = $PId And $WinList[$i][0] <> "" Then 
       ReDim $WindowTitle[$x + 1][2] 
       $WindowTitle[$x][0] = $WinList[$i][0] 
       $WindowTitle[$x][1] = $WinList[$i][1] 
       $x += 1 
      EndIf 
     Next 
     Return $WindowTitle 
    EndIf 
EndFunc ;==>ProcessGetWindow