我的 AutoIt 脚本:
WinWaitActive("User Authentication","","10")
If WinExists("User Authentication") Then
; Enter a username.
Send("prabu{TAB}")
Send("{TAB}")
;Enter a Password.
Send("Password")
Send("{TAB}")
Send("{SPACE}")
;Press Authenticate button.
Send("{TAB} {ENTER}")
EndIf
我将其“编译”为 .exe 文件,并使用 Selenium 执行它:
Runtime.getRuntime().exec("C:\\Users\\Prabu\\Documents\\ds.exe");
但我希望它每次都输入不同的用户名和密码。我打算使用命令行参数(如果愿意,可以使用参数)将这些提供给脚本。
是否可以将参数传递给 AutoIt 脚本?如果是这样,应该如何完成以及如何访问提供给我的脚本的参数/参数?
对 AutoIt 脚本的更改:
$username = $CmdLine[1]
$password=$CmdLine[2]
Send($username)
Send($password)
在爪哇中:
String command="C:\\Users\\Prabu\\Documents\\ds.exe \"username1\" \"password1\"";
Runtime.getRuntime().exec(command);
参考:
https://www.autoitscript.com/autoit3/docs/intro/running.htm#CommandLine http://seleniumocean.blogspot.in/2014/11/its-time-for-autoit-parameterizing.html