运行 来自变量的多行脚本
Run a multi line script from a variable
我的 AutoIt 脚本:
$command = InputBox("Enter your command", "Enter your command")
Execute($command)
这适用于像 MsgBox(0, "Test", "Test")
这样的单行命令。但是多行代码(例如 If
语句)会产生错误。
如果变量是多行脚本,是否有办法 运行 AutoIt 源代码?
是的,将其写入临时脚本文件,然后执行该脚本。由于 InputBox() 不接受多行输入,我正在使用 clipget() 从剪贴板获取命令。
$command=clipget()
$tempfilename="tempscript.au3"
$tempscript=FileOpen($tempfilename,2)
FileWrite($tempscript,$command)
FileFlush($tempscript)
FileClose($tempscript)
RunWait(@AutoItExe & ' /AutoIt3ExecuteScript ' & $tempfilename)
FileDelete($tempfilename)
我的 AutoIt 脚本:
$command = InputBox("Enter your command", "Enter your command")
Execute($command)
这适用于像 MsgBox(0, "Test", "Test")
这样的单行命令。但是多行代码(例如 If
语句)会产生错误。
如果变量是多行脚本,是否有办法 运行 AutoIt 源代码?
是的,将其写入临时脚本文件,然后执行该脚本。由于 InputBox() 不接受多行输入,我正在使用 clipget() 从剪贴板获取命令。
$command=clipget()
$tempfilename="tempscript.au3"
$tempscript=FileOpen($tempfilename,2)
FileWrite($tempscript,$command)
FileFlush($tempscript)
FileClose($tempscript)
RunWait(@AutoItExe & ' /AutoIt3ExecuteScript ' & $tempfilename)
FileDelete($tempfilename)