用于处理 Chrome 身份验证 Window 的 AutoIT 脚本

AutoIT Script to Handle Chrome Authentication Window

我有以下脚本基于以下 link:Here

If(Not IsArray($CmdLine) Or $CmdLine[0] < 2) Then
$user = InputBox ("User", "Please enter your user", "")
$pass = InputBox ("Password", "Please enter your password", "", "*M")
Else
$user = $CmdLine[1]
$pass = $CmdLine[2]
EndIf

WinWaitActive("", "Authentication Required", "120")
If WinExists("", "Authentication Required") Then
Send($user)
Send("{TAB}")
Send($pass)
Send("{ENTER}")
EndIf

这对我不起作用,当我 运行 对此进行测试时,用户名和密码字段中没有输入任何内容。我什至创建了一个脚本,我只是将一个字符串发送到用户名和密码字段,但它也不起作用。

(这已在评论中解决,但我将答案复制到此处以供将来的读者使用。)

看来 WinWaitActive 命令从未找到您正在寻找的登录提示。在 Windows 7 上的 Chrome 40 上,登录提示的唯一可见文本是 Chrome Legacy Window,而不是 Authentication Required(这正是您要找的)。

我建议使用 AutoIt 标配的 "AutoIt Window Info" 工具进行检查。打开 Chrome 身份验证框,冻结 Window 信息工具,然后检查 "Visible Text" 选项卡。