我正在尝试运行的SDK首先准备安装步骤,然后显示下一个按钮。所以我等到我看到按钮。
当下一个按钮出现时,ConsolWrite会在循环中写入。但是我无法点击按钮。也尝试发送(“!n”),它不起作用。
#include <GUIConstantsEx.au3>
Global $hCtrl = 0, $Waiting = True
$wintitle = "SigCaptureWeb SDK - InstallShield Wizard"
ShellExecute("C:\SigCaptureWeb.exe")
; your GUI loop
While (1)
If $Waiting And WinExists($wintitle) Then
$hCtrl = ControlGetHandle($wintitle, "", "[CLASS:Button; TEXT:&Next >]")
If $hCtrl Then
; we got the handle, so the button is there
; now do whatever you need to do
ConsoleWrite("in the loop")
ControlClick($wintitle,"", "[CLASS:Button; TEXT:&Next >]","{ENTER}")
$Waiting = False
EndIf
EndIf
$iMsg = GUIGetMsg()
Switch $iMsg
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
您可能需要以管理员身份运行脚本以与以管理员身份运行的安装程序进行交互。
使用ShellExecute
测试AutoIt安装程序允许脚本检测窗口,但单击按钮不起作用,因为脚本运行时不是admin。这可以被视为操作系统的安全功能,以保护管理进程。
这可能对你有用。我不知道为什么你有gui代码等所以我要把它留下来。
; This is a compile directive to make the compiled script run as admin.
#pragma compile(ExecLevel, requireAdministrator)
; This directive is for uncompiled script to run as admin.
#RequireAdmin
$wintitle = "SigCaptureWeb SDK - InstallShield Wizard"
Run("C:\SigCaptureWeb.exe")
WinWait($wintitle)
; Wait for Next button to become visible.
While Not ControlCommand($wintitle, "", "&Next >", "IsVisible", "")
Sleep(250)
WEnd
ControlClick($wintitle, "", "&Next >")
作为InstallShield安装程序,它可能具有可以传递给可执行文件的参数,以启动静默安装,这可以使其更容易。你可以调查一下。