scdxorange Posted September 17, 2008 Posted September 17, 2008 Does AutoIt support "fun.exe -parameter"? For example, I have a "fun.au3" and generated a "fun.exe". If I double click "fun.exe", it then could execute. But I want add some parameter after "fun.exe", for example, I want to run it in "cmd.exe", and use this command "fun.exe -parameter". Does AutoIt support this? How to? Thanks!
dbzfanatic Posted September 17, 2008 Posted September 17, 2008 Search the helpfile for $cmdLine. Just for kicks... Command Line Parameters The special array $CmdLine is initialized with the command line parameters passed in to your AutoIt script. Note the scriptname is not classed as a parameter; get this information with @ScriptName instead. A parameter that contains spaces must be surrounded by "double quotes". Compiled scripts accept command line parameters in the same way. $CmdLine[0] is number of parameters $CmdLine[1] is param 1 (after the script name) $CmdLine[2] is param 2 etc ... $CmdLine[$CmdLine[0]] is one way to get the last parameter... So if your script is run like this: AutoIt3.exe myscript.au3 param1 "this is another param" $CmdLine[0] equals... 2 $CmdLine[1] equals... param1 $CmdLine[2] equals... this is another param @ScriptName equals... myscript.au3 In addition to $CmdLine there is a variable called $CmdLineRaw that contains the entire command line unsplit, so for the above example: $CmdLineRaw equals... myscript.au3 param1 "this is another param" If the script was compiled it would have been run like this: myscript.exe param1 "this is another param" $CmdLineRaw equals... param1 "this is another param" Note that $CmdLineRaw just return the parameters. Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line. Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote]
scdxorange Posted September 17, 2008 Author Posted September 17, 2008 Search the helpfile for $cmdLine. Just for kicks...Thanks!
scdxorange Posted September 22, 2008 Author Posted September 22, 2008 I tried the following example but failed.The script is:func startnotepad (ByRef $i)While $i>0 run("notepad") $i=$i-1WEndEndFuncAnd I run the following command in "cmd.exe"startnotepad.exe 5Nothing happened after I executed the command.What should I do?Thanks!
dbzfanatic Posted September 22, 2008 Posted September 22, 2008 You have to actually use the array. If $CmdLine[0] > 0 Then If $CmdLine[1] <> "" Then $sent = $CmdLine[1] EndIf EndIf Startnotepad($sent) func startnotepad (ByRef $i) While $i>0 run("notepad") $i=$i-1 WEnd EndFunc Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote]
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