如何从python脚本将参数传递给autoIT脚本
问题描述:
在我的python脚本中,我需要将命令行参数传递给AutoIt脚本。因为在我的AutoIt脚本中,我获得了命令行参数并对其进行了处理。下面AutoIt脚本我使用得到命令行参数,它是工作的罚款:如何从python脚本将参数传递给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)
我希望固定您的问题的参数。
异常类型和消息会告诉你到底是什么问题。你为什么忽略它? –