[英]how to pass argument to autoIT script from python script
在我的python脚本中,我需要将命令行参数传递给AutoIt脚本。 因为在我的AutoIt脚本中,我正在获取命令行参数并对其进行处理。 我正在使用下面的AutoIt脚本来获取命令行参数,并且可以正常工作:
#include <Array.au3>
#include <WinAPIShPath.au3>
Local $aCmdLine = _WinAPI_CommandLineToArgv($CmdLineRaw)
_ArrayDisplay($aCmdLine)
现在,使用我的python脚本,我需要将命令行参数传递给上述autoIt脚本。
我尝试在Python脚本中使用:
import os
args = ("test","abc")
os.execv("test.au3",args)
但这是一个例外。
这应该为您工作。
在您的AutoIT脚本中,将这段代码放入
AutoIT的变量$ CMDLINE包含提供的参数。 变量$ PAR(随时更改其名称)将存储该参数以供以后使用。
$PAR = ''
If $CmdLine[0] > 0 Then
If $CmdLine[1] <> @ScriptName Then
$PAR = $CmdLine[1] ;Now, you can use the variable $PAR in your script.
Endif
Endif
把它放在你的Python脚本中
参数将是您要传递的参数
os.system("location/to/autoit/file.exe "+parameter )
我希望能解决您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.