Autoit无需关注即可启动应用

时间:2017-04-04 15:46:44

标签: autoit

使用AutoIt 3.3.14.2启动Entrust etunprot.exe应用程序。 Entrust应用程序启动,但没有焦点。应用程序启动后,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}")

2 个答案:

答案 0 :(得分:0)

尝试

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

答案 1 :(得分:0)

尝试此操作以获取进程的Windows。也许它会帮助你。

#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
相关问题