将命令行参数/参数传递给 AutoIt 可执行文件

问题描述 投票:0回答:1

我的 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 脚本?如果是这样,应该如何完成以及如何访问提供给我的脚本的参数/参数?

selenium-webdriver autoit
1个回答
5
投票

对 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

© www.soinside.com 2019 - 2024. All rights reserved.