[英]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.