Reputation: 401
My AutoIt script:
$command = InputBox("Enter your command", "Enter your command")
Execute($command)
This works for single line commands like MsgBox(0, "Test", "Test")
. But multi line code (such as If
-statements) produce an error.
Is there a way to run AutoIt source code from a variable if it is a multi line script?
Upvotes: 1
Views: 757
Reputation: 1131
Yes, write it to a temporary script file and then execute that script. Since InputBox() doesn't accept multiline input, I'm using clipget() to grab the commands from the clipboard instead.
$command=clipget()
$tempfilename="tempscript.au3"
$tempscript=FileOpen($tempfilename,2)
FileWrite($tempscript,$command)
FileFlush($tempscript)
FileClose($tempscript)
RunWait(@AutoItExe & ' /AutoIt3ExecuteScript ' & $tempfilename)
FileDelete($tempfilename)
Upvotes: 2