Doc Symbiosis Posted April 11, 2006 Share Posted April 11, 2006 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 Link to comment Share on other sites More sharing options...
MHz Posted April 11, 2006 Share Posted April 11, 2006 If you need more help, then let us know.http://www.autoitscript.com/autoit3/docs/i...htm#CommandLine Link to comment Share on other sites More sharing options...
IceBlackIce Posted April 11, 2006 Share Posted April 11, 2006 $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. Link to comment Share on other sites More sharing options...
MHz Posted April 11, 2006 Share Posted April 11, 2006 A simple exampleIf $CMDLINE[0] = 2 Then $vanilla = $CMDLINE[1] $chocolate = $CMDLINE[2] MsgBox(0x40000, 'CMDLINE', $vanilla & @CRLF & $chocolate)EndIf Link to comment Share on other sites More sharing options...
Doc Symbiosis Posted April 12, 2006 Author Share Posted April 12, 2006 Thanks a lot for the explanation.Doc Link to comment Share on other sites More sharing options...
MHz Posted April 12, 2006 Share Posted April 12, 2006 If $CMDLINE[0] And $CMDLINE[1] = '/?' Then MsgBox(0x40000, 'Help', 'Not a problem;)') ExitEndIf Link to comment Share on other sites More sharing options...
SyntaxError Posted June 23, 2006 Share Posted June 23, 2006 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. Link to comment Share on other sites More sharing options...
Delprat Posted June 23, 2006 Share Posted June 23, 2006 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...++ Link to comment Share on other sites More sharing options...
SyntaxError Posted June 23, 2006 Share Posted June 23, 2006 Thank you very much, Delprat. It may be badly coded but it works great. It's also the best explanation I've seen yet. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now