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

时间:2015-02-03 19:52:53

标签: google-chrome autoit

我根据以下链接提供以下脚本: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

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

1 个答案:

答案 0 :(得分:1)

(这已在评论中得到解决,但我正在为未来的读者复制答案。)

WinWaitActive命令似乎永远找不到您要查找的登录提示。在Windows 7上的Chrome 40上,登录提示的唯一可见文字是Chrome Legacy Window,而不是Authentication Required(这就是您要查找的内容)。

我建议使用AutoIt标配的“AutoIt窗口信息”工具进行检查。打开Chrome身份验证框,冻结“窗口信息”工具,然后选中“可见文本”选项卡。