April 11, 200620 yr Is it possible to call an AutoIT script with parameters?I think, that I read the manual very extensive, but didn't find a wayThanks in advance
April 11, 200620 yr If you need more help, then let us know.http://www.autoitscript.com/autoit3/docs/i...htm#CommandLine
April 11, 200620 yr $CmdLineyou have to make the instructions in the script itselfie: if $CmdLine[1] = "/?" then msgbox("help")and the variable i are separated by spacesie: autoittest.exe log userthis would make $CmdLine[1] = "log" and $CmdLine[2] = "user"search the manual im sure theres some help there.
April 11, 200620 yr A simple exampleIf $CMDLINE[0] = 2 Then $vanilla = $CMDLINE[1] $chocolate = $CMDLINE[2] MsgBox(0x40000, 'CMDLINE', $vanilla & @CRLF & $chocolate)EndIf
April 12, 200620 yr If $CMDLINE[0] And $CMDLINE[1] = '/?' Then MsgBox(0x40000, 'Help', 'Not a problem;)') ExitEndIf
June 23, 200620 yr I've written an AutoIt script to make Nero portable. It works great, except for one problem. I need to have the script (compiled of course) pass a single parameter (/w) to the Nero executable via shortcut. This will allow me to select Nero Express without having to go through Nero's main interface, or if I use a shortcut for Nero.exe, it loads the main interface.I've spent literally hours searching the AutoIt forum and help file, google and here without results. There is not one clear explanation of how to pass a parameter easily.Here's the line that runs Nero.RunWait(@ScriptDir & "\Nero\Nero.exe")It should be as simple as adding $1 or %1 like this (like every other language on the planet): RunWait(@ScriptDir & "\Nero\Nero.exe" & $1)But of course that doesn't work. The genius that wrote AutoIt removed that nice feature from the latest version.I don't understand $CmdLine at all. It makes no sense.
June 23, 200620 yr It should be as simple as adding $1 or %1 like this (like every other language on the planet)(.../...)I don't understand $CmdLine at all. It makes no sense. $CmdLine[0] lets you test the number or space-delimited arguments$CmdLine (where i is an integer lower or equal to $CmdLine[0]) returns you the i-th argument.In other words : your $1 or %1 becomes $CmdLine[1] Thus, your script becomes (this is a very bad-written sample) :If Not $CmdLine[0] Then RunWait(@ScriptDir & "\Nero\Nero.exe")Else RunWait(@ScriptDir & "\Nero\Nero.exe" & " " & $CmdLine[1])EndIfAs you can see, the genius who wrote $CmdLine thing forces you to write error-trapping code...++
June 23, 200620 yr Thank you very much, Delprat. It may be badly coded but it works great. It's also the best explanation I've seen yet.
Create an account or sign in to comment