Jump to content

Script parameters


Recommended Posts

  • Developers

from the helpfile:

AutoIt3.exe myscript.au3 param1 "this is another param"

$CmdLine[0]= 2

$CmdLine[1] = "param1"

$CmdLine[2] = "this is another param"

Script example from the CompileAU3.au3 script:

$V_ARG = "Valid Arguments are:" & @LF
$V_ARG = $V_ARG & "    /in  ScriptFile " & @LF
$V_ARG = $V_ARG & "    /out Targetfile " & @LF
$V_ARG = $V_ARG & "    /icon IconFile " & @LF
$V_ARG = $V_ARG & "    /pass passphrase " & @LF
$V_ARG = $V_ARG & "    /comp 0 to 4  (Lowest to Highest) " & @LF
For $X = 1 To $CMDLINE[0]
   $T_VAR = StringLower($CMDLINE[$X])
   Select
      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]
      Case $T_VAR = "/pass"
         $X = $X + 1
         $INP_PASSPHRASE = $CMDLINE[$X]
         $INP_PASSPHRASE2 = $CMDLINE[$X]
      Case $T_VAR = "/compress" or $T_VAR = "/comp"
         $X = $X + 1
         $INP_COMPRESSION = Number($CMDLINE[$X])
         If $INP_COMPRESSION < 0 Or $INP_COMPRESSION > 4 Then $INP_COMPRESSION = ""
      Case $T_VAR = "/nodecompile"
         $INP_ALLOW_DECOMPILE = 0
      Case Else
         MsgBox(1, "Compile Aut2EXE", "Wrong commandline argument: " & $T_VAR & @LF & $V_ARG)
         Exit
   EndSelect
Next

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

  • Developers

Its not that difficult...

Here's a basic one.... create the below script and compile it...

Msgbox(0,'param1',cmdline[1])

Msgbox(0,'param2',cmdline[2])

Then run it from the commandprompt:

yourscript.exe param1 param2

ok ? :D

Edited by JdeB

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

  • Developers

yes it should be with the $ .... :D

I just typed it online since he asked for a simple example....

You also ofcource need to make sure that 2 parameters are passed or else you get an error...

Edited by JdeB

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...