【问题标题】:Autoit starts app without focusAutoit 在没有焦点的情况下启动应用程序
【发布时间】:2017-04-04 15:46:44
【问题描述】:

使用 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}")

【问题讨论】:

    标签: autoit


    【解决方案1】:

    试试

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

    【讨论】:

    • 试过这个想法,但行为是一样的。谢谢。
    【解决方案2】:

    试试这个来获得你的进程的窗口。也许对你有帮助。

    #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
    

    【讨论】:

      猜你喜欢
      • 2015-01-28
      • 2019-02-19
      • 2012-04-03
      • 2017-09-06
      • 2016-05-01
      • 1970-01-01
      • 2011-08-28
      • 2012-06-10
      • 2011-01-08
      相关资源
      最近更新 更多