Draygoes Posted December 18, 2007 Share Posted December 18, 2007 I know that there is a way to give your program command line parameters, but im unsure how to do it. Ive read the help file information, but its very confusing. Could someone please post an example script that I could learn from? Thx Spoiler "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist. Link to comment Share on other sites More sharing options...
Developers Jos Posted December 18, 2007 Developers Share Posted December 18, 2007 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. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Draygoes Posted December 22, 2007 Author Share Posted December 22, 2007 I read that in the help file. But thats what is confusing. All i need is a simple example that would be a little easyer to understand. Spoiler "If a vegetarian eats vegetables,What the heck does a humanitarian eat?" "I hear voices in my head, but I ignore them and continue on killing." "You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring." An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist. Link to comment Share on other sites More sharing options...
qube Posted December 22, 2007 Share Posted December 22, 2007 you mean batch file or dos command ? Call me "Queen of Pain" :) Link to comment Share on other sites More sharing options...
Developers Jos Posted December 22, 2007 Developers Share Posted December 22, 2007 (edited) This is the commandline lexing I have in AutoIt3Wrapper ... maybe that helps you ? expandcollapse popupFor $x = 1 To $CMDLINE[0] $T_Var = StringLower($CMDLINE[$x]) ;MsgBox( 1, "debug", "argument: " & $t_var,1) $Parameter_Mode = 1 Select Case $T_Var = "/Watcher" ; when AutoIt3Wrapper is lanched as watcher to see if the original AutoIt3Wrapper is canceled. $H_Cmp = $CMDLINE[$x + 1] $H_au3 = $CMDLINE[$x + 2] While ProcessExists($H_Cmp) And ProcessExists($H_au3) Sleep(500) WEnd Sleep(500) If ProcessExists($H_au3) Then ProcessClose($H_au3) _RefreshSystemTray() EndIf Exit Case $T_Var = "/?" Or $T_Var = "/help" MsgBox(1, "Compile Aut2EXE", "Compile an AutoIt3 Script." & @LF & "commandline argument: " & $T_Var & @LF & $V_Arg) Exit Case $T_Var = "/in" $x = $x + 1 $ScriptFile_In = $CMDLINE[$x] Case $T_Var = "/out" $x = $x + 1 $ScriptFile_Out = $CMDLINE[$x] Case $T_Var = "/icon" $x = $x + 1 $INP_Icon = $CMDLINE[$x] $DebugIcon = $DebugIcon & "/icon: " & $INP_Icon & @CRLF Case $T_Var = "/pass" $x = $x + 1 ;~ $INP_PassPhrase = $CMDLINE[$x] ;~ $INP_PassPhrase2 = $CMDLINE[$x] ;~ $INP_Allow_Decompile = "y" Case $T_Var = "/compress" Or $T_Var = "/comp" $x = $x + 1 $INP_Compression = Number($CMDLINE[$x]) Case $T_Var = "/nodecompile" ;~ $INP_Allow_Decompile = "n" Case $T_Var = "/run" $Option = "Run" Case $T_Var = "/debug" $Debug = 1 Case $T_Var = "/au3check" $Option = "AU3Check" Case $T_Var = "/compiledefaults" ; $Option2 = "defaults"; Obsolete Case $T_Var = "/beta" $INP_AutoIT3_Version = "Beta" Case $T_Var = "/prod" $INP_AutoIT3_Version = "Prod" Case $T_Var = "/Autoit3Dir" $x = $x + 1 $INP_AutoitDir = $CMDLINE[$x] Case $T_Var = "/UserParams" $s_CMDLine = StringTrimLeft($CMDLINERAW, StringInStr($CMDLINERAW, "/UserParams") + 11) ExitLoop Case Else ; when /run then optional parameters are allowed If $Option = "Compile" Then MsgBox(1, "Compile Aut2EXE", "Wrong commandline argument: " & $T_Var & @LF & $V_Arg) Exit EndIf ; Build the other params used for running autoit $s_CMDLine = $s_CMDLine & " " & $T_Var EndSelect Next Edited December 22, 2007 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. 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