When you start AutoIt you will be asked to open a script file. A script file is a simple text file containing AutoIt keywords and functions that tell AutoIt what you want it to do. Script files are created in a simple text editor such as notepad.exe or a much better alternative.
Although AutoIt v3 scripts are just plain-text files they are usually given the file extension .au3 to help tell the difference between a script and a text file. If you used the full installer to install AutoIt you can execute an AutoIt script simply by double-clicking it. There are also various options to open, edit, or compile a script if you right-click on the .au3 file.
Here is an example script. Notice that ; is used for comments (much like REM in DOS batch files):
; This is my first script
MsgBox(0, "My First Script!", "Hello World!")
More complicated scripts may use functions, which are usually placed at the end of a script. Here is a similar script using functions:
; This is my second script (with functions)
MsgBox(0, "My second script!", "Hello from the main script!")
TestFunc()
Func TestFunc()
MsgBox(0, "My Second Script!", "Hello from the functions!")
EndFunc
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"