Variablen beim Skriptaufruf mitgeben

  • Hallo,

    hab da mal ne Anfängerfrage:

    Wenn ich ein AutoIT Skript aus einer DOS Box aufrufen möchte, kann ich dann Parameter mit angeben die ich als Variablen im ansprechen kann.

    Z.B. Aufruf:

    c:\testskript.exe Wert1 Wert2 Wert3

    Bei DOS Batchs kann ich diese Werte mit %1 %2 und %3 ansprechen, geht das auch irgendwie bei dem AutoIT Skript ?

    Wenn ja -> Wie ?

    Vielen Dank für eine kurze Hilfe

    Grüße
    Christian

  • Hi Basler,

    jaaaa, das geht ;)

    [helpfile]
    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"


    Note : only 63 parameters can be return by $CmdLine[...], but $CmdLineRaw will always returns the entire command line.

    [/helpfile]

    • Offizieller Beitrag

    Hallo!

    Hier mal von Scite die Abrevation von cmdlineselect:

    Spoiler anzeigen


    und hier cmdlineselect2

    Spoiler anzeigen

    Mfg Spider

  • Hi ,

    vielen Dank für die zahlreichen Tipps.

    Meine ersten versuche mit "$CmdLine" haben schon geklappt.

    Grüße
    Christian