【问题标题】:how to pass argument to autoIT script from python script如何从 python 脚本将参数传递给 autoIT 脚本
【发布时间】:2016-07-06 10:04:37
【问题描述】:

在我的 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)

但它给出了一个例外。

【问题讨论】:

  • 异常类型和消息会告诉你究竟是什么问题。为什么你在问题中省略了它?

标签: python autoit


【解决方案1】:

这应该适合你。

在您的 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 )

我希望这解决了您的问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-23
    • 2010-10-26
    • 2015-05-13
    • 1970-01-01
    • 2016-09-02
    相关资源
    最近更新 更多