Version 2.51 - (C)1999, 2000 Jonathan Bennett

(Email: support@hiddensoft.com)

AutoIt Homepage

Quick Command Reference

[AdlibOn] [AdlibOff] [BlockInput] [Break] [DetectHiddenText] [Exit] [EndRepeat] [EnvAdd] [EnvSub] [FileAppend] [FileReadLine] [Gosub] [Goto] [HideAutoItWin] [IfInString] [IfNotInString] [IfWinExist] [IfWinNotExist] [IfWinActive] [IfWinNotActive] [IfEqual] [IfNotEqual] [IfGreater] [IfGreaterOrEqual] [IfLess] [IfLessOrEqual] [IfExist] [IfNotExist] [IfMsgBox] [IniRead] [IniWrite] [IniDelete] [InputBox] [LeftClick] [LeftClickDrag] [MouseGetPos] [MouseMove] [MsgBox] [Random] [RegRead] [RegWrite] [RegDelete] [Return] [RightClick] [RightClickDrag] [Run] [RunWait] [Repeat] [Send] [SetEnv] [SetKeyDelay] [SetTitleMatchMode] [SetWinDelay] [Shutdown] [Sleep] [SplashTextOn] [SplashTextOff] [StringCaseSense] [StringLeft] [StringRight] [StringMid] [StringLen] [StringReplace] [StringTrimLeft] [StringTrimRight] [WinGetActiveTitle] [WinKill] [WinWait] [WinWaitClose] [WinWaitActive] [WinWaitNotActive] [WinHide] [WinRestore] [WinShow] [WinMinimize] [WinMaximize] [WinActivate] [WinClose] [WinMinimizeAll] [WinMove] [WinSetTitle

Table of Contents

1. Introduction

2. Intended Use

3. License

4. Year 2000 Statement

5. Document Conventions

6. Running AutoIt

7. Aut2Exe - Convert Scripts To .Exes

8. Script File Syntax

9. Window Titles and Window Text

10. DOS Environment Variables

11.The Clipboard Variable

12.Special Variables

13. Script Commands

14. Send Command Syntax

15. The [ADLIB] Section

16. Examples

17. AutoIt History

18. The Wish List

19. Thanks To....

Introduction

AutoIt is an automation tool. It can be used to automate any simple windows or DOS based task. It was primarily designed to assist in automatically installing software that cannot be automatically installed by other means. This is most useful during a PC rollout where hundreds or thousands of client machines need to be automatically installed. Many programs such as MS Office, Mcafee, IE4, etc. feature their own automated installation routines. Far too many programs, however, feature no way of automatic installation. That's where AutoIt comes in. AutoIt can also be used to automate small tasks on your machine.

When AutoIt is executed, it reads a specified script file. This script file allows AutoIt to perform a number of functions, these include

Best of all, its small (self contained .exe, no DLL's, no registry entries) and FREE! (And it will stay free).

New from version 2.1 onwards is Aut2Exe.  This program will create a standalone executable from an AutoIt script!

New from version 2.21 onwards, you can now send decimal ASCII codes, like when using using the ALT key and the numeric keypad (e.g. ALT+65 = 'A').  Very useful for sending characters that don't usually work (e.g. '~' on an Italian keyboard)

Still needed, non-English versions of this file! (In any format, as long as you are willing to help maintain) - Check the non-English downloads at the AutoIt Homepage to see what languages have currently been done.

Back to Contents

Intended Use

This program is intended for performing simple automation tasks in Windows. It is not intended as the "be-all and end-all" of scripting. When performing complex tasks (registry manipulation, text file parsing, complex loops, etc.) I would recommend using AutoIt in conjunction with a fully-fledged scripting language (such as WSH or Kixtart - both free) and using AutoIt to "fill in the gaps". The current ethos of AutoIt is "If it can't be done on a single line - it's probably too complicated". This approach has worked well so far, and helped to keep the size of AutoIt down (it is a tiny executable!).

I personally use AutoIt for large PC rollouts. I use Kixtart/WSH as a "back-end" to copy files, run files, edit the registry and then use it to call AutoIt when I need to perform configurations that can only be usually achieved by manual input (software installation, configuring control panel, changing drive letters, etc.).

Back to Contents

License

See License.txt included in this archive.

Back to Contents

Year 2000 Statement

AutoIt is to the best of the authors knowledge, Y2K compliant. However, see the license for standard disclaimers.

Back to Contents

Conventions

Parameters are shown in angled brackets, optional parameters are shown in square brackets.

e.g.
<cmd>, <parameter1> [,<parameter2>]

This is a command, followed by a comma and parameter1, optionally followed by a comma and parameter2.

i.e.
<cmd>, <parameter1>

OR

<cmd>, <parameter1>, <parameter2>

Back to Contents


Running AutoIt

AutoIt can be executed from the command line, or by double-clicking on its icon from the Windows Explorer.

>>> N.B.  The ONLY file that is necessary for AutoIt to run is "AutoIt2.exe", putting this file in the path on any PC will allow you to run AutoIt scripts on that PC using the command line syntax below. <<<

Command Line Syntax

AutoIt is executed from the command line in the two following ways (make sure AutoIt2.exe is in your path, or you run the commands from the directory that AutoIt is installed):

AutoIt2.exe /reveal

OR

AutoIt2.exe <filename of script file>


Reveal Mode

When in "reveal" mode, the AutoIt window will stay topmost. As you click on other windows to make them active, AutoIt will display their window titles, the mouse coordinates relative to that window, and any other text on the window that may help to distinguish it from other windows of the same title. As with MS ScriptIt, not all text on a window can be "seen" - experiment!

Information on the AutoIt reveal screen can be highlighted with the mouse and copied to the clipboard with "CTRL-C", this can then be pasted into another program / text editor.

Script Mode

AutoIt will execute the script filename given on the command line. The file can have any extension (if you use the installation routine, .aut will be automatically registered. Right clicking on a .aut file will enable you to run or edit the script).

Using Command Line Parameters

Parameters can be passed to the AutoIt script from the command line when using the following syntax:

AutoIt2.exe <filename of script file> /p param1 param2 param3........param3

These parameters are usable from the script file as the ENV variables %1%, %2%, %3%, etc.  

If a parameter needs to contain spaces, then enclose it in double quotes, e.g.:

AutoIt2.exe testscript.aut /p "D:\A long pathname" var2

%1% would equal D:\A long pathname

%2% would equal var2

Back to Contents

Aut2Exe - Convert Scripts To .Exes

Aut2Exe can be installed along with AutoIt (full setup only).  This program will take an AutoIt script and convert it to an executable.  This executable can then be run without any of the original AutoIt programs being installed.  It is possible to define an icon for the resulting executable, this must be an icon file that is 32 by 32 pixels in 16 colours (the file should have a length of 766 bytes).

The script is visible near the end of the resulting executable, but it has been encrypted to protect your script from prying eyes!  (N.B. The encryption is not very complicated, but it will prevent the majority of "would-be-hackers" from getting access to your scripts.  I know that I wouldn't be able to crack it, but then I'm no expert... :) ).

Future versions may cater for pass phrases so that encrypted scripts can be decrypted (for the moment, don't lose your original scripts!! ;) ).

N.B. You can still pass command line variables to the resulting exe file by running "myscript.exe /p param1 param2.....".

Back to Contents

Script File Syntax

The script file is a standard text file that can be given any extension (although .aut is the preferred extension). Each line can contain either a command, a comment, a label, or be left blank.  

N.B. The maximum number of characters per line is 1024.  Any extra characters will be ignored.

; Start of script
; Comments are indicated by a semi-colon

<Cmd>, <Cmd Parameters>
<Cmd2>, <Cmd2 Parameters>
<Cmd3>, <Cmd3 Parameters>

; This is a label, it must end with a colon (:) and it is used for commands such as Gosub and Goto.
label:

; End of script
Exit

; Start of the ADLIB section
[ADLIB]
<Title>, <Text>, <Cmd>, <Cmd Parameters>

Back to Contents

Special Characters

The slash'\', comma ',' and percent '%' are treated as special characters, and you must be careful when using them.

',' is used to separate parameters in the script file.
'%' is used to indicate DOS variables.

If you wish to use any of this characters literally, you must precede them with the slash '\' character, i.e. "\," or "\%". If you wish to use a literal '\' you must precede this also, i.e. "\\".

The "\n" and "\t" sequences can be used to denote new lines and tabs in the AutoIt output functions MsgBox and InputBox.

Back to Contents

Window Titles and Text

A number of script commands have "Window Title" and "Window Text" as parameters.
"Window Title" is text that appears in the windows title bar.
"Window Text" is any other text on that window, e.g. text on buttons such as "OK" and "Cancel".

Having "Window Text" allows you to distinguish between multiple windows that have the same title.

Neither the title nor text needs to be completely specified.
i.e. "Untitled - No" will match a window with the title "Untitled - Notepad".
See the text on the SetTitleMatchMode command for additions to this.

Use the "/reveal" mode to see what text is present on a window.

N.B. Windows titles and text are CASE SENSITIVE!!!!!

Back to Contents

DOS Environment Variables

You can use DOS environment variables anywhere in an AutoIt script. As in DOS batch files, just include the variable enclosed in percent (%) symbols.

For example, if you want to send the current DOS path to the notepad window you could do:

Run, notepad.exe
WinWaitActive, Untitled - Notepad
Send, This is the DOS path %PATH%


e.g. This example sets the variable test and then outputs it in a messagebox.
SetEnv, test, This is some output
MsgBox, 0, Example, %test%


N.B. Because of its special status, if you want to actually use a percent sign without it being changed into a variable, you must use the escape character '\' first.
e.g.
Send, This will send a single percent sign \%

You can also use "SetEnv" to set variables, but these changes will not be visible from DOS - the value will only be valid in the current script.

N.B. Many AutoIt commands specifically state that they take a variable as a parameter, in these cases the % symbol is NOT used.  A number of the examples that come with AutoIt demonstrate this.


Back to Contents

The Clipboard Variable

The variable %CLIPBOARD% is special, and when used will be substituted for the text contents of the clipboard.  For example, if you copy the text "Hello!" to the clipboard and then run the following script:

MsgBox, 0, Example, The contents of the clipboard is: %clipboard%

The text "The contents of the clipboard is: Hello!" will be output to the screen.

Similarly, if you want to send text to the clipboard you can use the SetEnv command.  E.g. To put the text "I'm some pasted text" into the clipboard you can run:

SetEnv, clipboard, I'm some pasted text


Back to Contents

Special Variables

There are a number of special variables in AutoIt these are described below:

AutoIt Variable Contains
A_OSTYPE The type of Operating System being run.  Either "WIN32_WINDOWS" or "WIN32_NT".
A_SCRIPTNAME The current script name, e.g. "myscript.aut".
A_SCRIPTDIR The directory that the current script resides in.
A_SCRIPTFULLPATH The full pathname of the current script, e.g. "C:\Windows\Scripts\myscript.aut".
A_WORKINGDIR The current working directory.
   
A_SEC Seconds after the minute (00-59)
A_MIN Minutes after the hour (00-59)
A_HOUR Hours after midnight (00-23)
A_MDAY Day of the month (01-31)
A_MON Month of the year (01-12)
A_YEAR The current year (4 digit format, e.g. 2000)
A_WDAY Day of the week (1-7)
A_YDAY Day of the year (1-366)

Script Commands

The following commands are currently recognized (commands are not case sensitive):

AdlibOn
AdlibOff

BlockInput, <on | off>
Break, <on | off>
DetectHiddenText, <on | off>
Exit
EndRepeat
Gosub, <label>
EnvAdd, <Variable>, <Value>
EnvSub, <Variable>, <Value>

FileAppend, <Text>, <Filename>
FileReadLine, <Variable>, <Filename>, <Line>
Goto, <label>
HideAutoItWin, <on | off>
IfInString, <String Variable>, <Search String>, <Command>
IfNotInString, <String Variable>, <Search String>, <Command>

IfWinExist, <Window Title>, [<Window Text>], <Command>
IfWinNotExist, <Window Title>, [<Window Text>], <Command>
IfWinActive, <Window Title>, [<Window Text>], <Command>
IfWinNotActive, <Window Title>, [<Window Text>], <Command>

IfEqual, <Variable>, <Text>, <Command>
IfNotEqual, <Variable>, <Text>, <Command>

IfGreater, <variable>, <number>, <Command>
IfGreaterOrEqual, <variable>, <number>, <Command>
IfLess, <variable>, <number>, <Command>
IfLessOrEqual, <variable>, <number>, <Command>

IfExist, <file or directory>, <Command>
IfNotExist, <file or directory>, <Command>

IfMsgBox, <return value>, <Command>
IniRead, <Variable>, <Filename>, <Section>, <Key>
IniWrite, <Value>, <Filename>, <Section>, <Key>
IniDelete, <Filename>, <Section>, <Key>
InputBox, <Variable>, <title>, <message>
LeftClick, <x>, <y>
LeftClickDrag, <x1>, <y1>, <x2>, <y2>
MouseGetPos, <x Variable>, <y Variable>
MouseMove, <x pos>, <y pos>
MsgBox, <display mode>, <title>, <message>
Random, <Output Variable>, <Min Value>, <Max Value>
RegRead, <Variable>, <ValueType>, <RegKey>, <RegSubkey>, <ValueName>
RegWrite, <ValueType>, <RegKey>, <RegSubKey>, <ValueName>, <Value>
RegDelete, <RegKey>, <RegSubKey>, <ValueName>
Repeat, <Count>
Return
RightClick, <x>, <y>
RightClickDrag, <x1>, <y1>, <x2>, <y2>
Run, <Program path and name> [,<Working directory>]
RunWait, <Program path and name> [,<Working directory>]
Send, <Series of key presses>
SetEnv, <variable>, <value>
SetKeyDelay, <milliseconds>
SetTitleMatchMode, <mode>
SetWinDelay, <milliseconds>
Shutdown, <Flag>
Sleep, <milliseconds>
SplashTextOn, <Width>, <Height>, <Title>, <Message>
SplashTextOff
StringCaseSense, <On | Off>
StringLeft, <Output Variable>, <Input Variable>, <Number of chars to extract>
StringRight, <Output Variable>, <Input Variable>, <Number of chars to extract>
StringMid, <Output Variable>, <Input Variable>, <Start char>, <Number of chars to extract>
StringLen, <Output Variable>, <Input Variable>
StringReplace, <Output Variable> , <Input Variable>, <Search String>, <Replace String>
StringTrimLeft, <Output Variable>, <Input Variable>, <Number of chars to trim>
StringTrimRight, <Output Variable>, <Input Variable>, <Number of chars to trim>
WinGetActiveTitle, <Variable>
WinKill, <Window Title> [,<Window Text>]
WinWait, <Window Title> [,<Window Text>]
WinWaitClose, <Window Title> [,<Window Text>]
WinWaitActive, <Window Title> [,<Window Text>]
WinWaitNotActive, <Window Title> [,<Window Text>]
WinHide, <Window Title> [,<Window Text>]
WinRestore, <Window Title> [,<Window Text>]
WinShow, <Window Title> [,<Window Text>]

WinMinimize, <Window Title> [,<Window Text>]
WinMaximize, <Window Title> [,<Window Text>]
WinActivate, <Window Title> [,<Window Text>]
WinClose, <Window Title> [,<Window Text>]

WinMinimizeAll
WinMove, <Window Title>, [<Window Text>], <X>, <Y>, <Width>, <Height>
WinSetTitle, <Window Title>, [<Window Text>], <New Title>

The syntax of these script commands are given below:

Back to Contents

AdlibOn
AdlibOff


This will enable/diable processing of the [ADLIB] section.


BlockInput, <on | off>

This command with disable both mouse and keyboard input.  This only works on various operating system configurations as indicated below:

Operating System "BlockInput" Results
   
Windows 95 No effect.
Windows 98 User input is blocked but AutoIt is also unable to simulate input.
Windows NT 4 (Without ServicePack 6) No effect.
Windows NT 4 (With ServicePack 6) User input is blocked and AutoIt can simulate input.
Windows 2000 User input is blocked and AutoIt can simulate input.

Input will be automatically enabled when the script closes.


Break, <on | off>

This command tells AutoIt whether or not the user can close AutoIt.  Default is "on" (i.e. user can close AutoIt)

e.g.
Break, On


DetectHiddenText, <on | off>

Some programs use hidden windows and hidden text on windows (e.g. Backup Exec) this can cause problems when trying to script them.  This command allows you to tell AutoIt whether or not to detect this hidden text.  Default is "off".


Exit

This command will end the script.


EnvAdd, <Variable>, <Value>
EnvSub, <Variable>, <Value>


Allows you to add and subtract with Env variables.  If the variable or value is not numeric, it will be taken to be zero (0).

e.g.
SetEnv, test, 20
EnvAdd, test, 20
MsgBox, 0, Example, %test%

This will output "40" to the screen.  


FileAppend, <Text>, <Filename>

This command will append "Text" to the end of a file.  If the file does not exist, it will be created.

e.g.
FileAppend, This is line 1\nThis is line 2\n, myfile.txt

This will append two lines of text to "myfile.txt", note the use of "\n" to indicate a newline is required.

If the command is successful %ERRORLEVEL% is set to 0, otherwise it is set to 1.


FileReadLine, <Variable>, <Filename>, <Line>

This command will read a line from a file of text into a variable.  Line 1 is taken to be the first line.

e.g.
FileReadLine, test, myfile.txt, 1

Will read the first line of "myfile.txt" into the %test% variable.

If the command is successful %ERRORLEVEL% is set to 0, otherwise it is set to 1.


Gosub,<label>
Return

Just like the old BASIC commands. Gosub will branch to a specified label. Return will return to the line after the Gosub command.

e.g.
SetEnv, MyMessage, This is the first message!
Gosub, mysubroutine
SetEnv, MyMessage, This is the second message!
Gosub, mysubroutine
SetEnv, MyMessage, This is the third message!
Gosub, mysubroutine
Exit

mysubroutine:
MsgBox, 0, AutoIt, %MyMessage%
Return


Goto, <label>

Script execution will continue at the specified label.

e.g.
; This script will loop forever
myloop:
Sleep, 10
Goto, myloop


HideAutoItWin, <on | off>

This command can be used to completely hide the AutoIt window from the user.  Useful for "silent" installs.

e.g.
HideAutoItWin, On


IfInString, <String Variable>, <Search String>, <Command>
IfNotInString, <String Variable>, <Search String>, <Command>

Checks to see if the contents of the <Search String Variable> is/is not present in the string <String>.  If the condition is met, <Command> will be executed.

e.g. To check if the word "Hello" is in the string "Hello this is a string"
SetEnv, search, Hello this is a string
IfInString, search, Hello, MsgBox, 0, Matched, Yes, the search string was found

(This will output "Yes, the search string was found)

 


IfWinExist, <Window Title>, [<Window Text>], <Command>
IfWinNotExist ,<Window Title>, [<Window Text>], <Command>
IfWinActive, <Window Title>, [<Window Text>], <Command>
IfWinNotActive, <Window Title>, [<Window Text>], <Command>

If the condition is met (i.e. the window title and text exists, is active, doesn't exist, is inactive) then the script will execute the <Command>.
N.B. If no window text is to be given you MUST include the extra comma.
e.g.
IfWinExist, Win Title, Win Text, Goto, label1
IfWinExist, Win Title,, Goto, label1


IfEqual,<variable>,<text>, <Command>
IfNotEqual,<variable>, <text>, <Command>

Will compare the DOS variable <variable> with <text> and branch depending on the result.

e.g.
InputBox, MyVar, AutoIt, Please enter the word: WOMBLE
IfEqual, MyVar, WOMBLE, Goto, match
MsgBox, 0, AutoIt, You didnt type the correct word!
Exit
match:
MsgBox, 0, AutoIt, Well done! You typed in the correct word!


IfGreater, <variable>, <number>, <Command>
IfGreaterOrEqual, <variable>, <number>, <Command>
IfLess, <variable>, <number>, <Command>
IfLessOrEqual, <variable>, <number>, <Command>

Will compare the DOS variable <variable> with <number> and branch depending on the result.  If the parameters are not numeric they will be treated as being zero.


IfExist,<file or directory>,<Command>
IfNotExist,<file or directory>,<Command>

Will cause the script to execute <Command> if the specified file or directory exists/doesn't exists.

e.g.
IfExist, C:\\COMMAND.COM, Goto, fileexist
Exit
fileexist:

; Script will get to here if C:\COMMAND.COM DOES exist.
MsgBox, 0, AutoIt, File exists


IfMsgBox, <return value>, <Command>

Use this to execute a command  based on the button the user pressed in the MsgBox command. Valid return values from MsgBox are:
ABORT, CANCEL, IGNORE, NO, OK, RETRY, YES

e.g. To put up a dialog box, with OK and CANCEL buttons, then branch if
the user selects CANCEL:

; Example Script
MsgBox, 1, AutoIt, This is a test message
IfMsgBox, CANCEL, Goto, cancellabel
Exit
cancellabel:
; If the script gets to here, user pressed cancel
MsgBox, 0, AutoIt, The user pressed cancel


IniRead, <Variable>, <Filename>, <Section>, <Key>
IniWrite, <Value>, <Filename>, <Section>, <Key>

IniDelete, <Filename>, <Section>, <Key>

Allows reading and writing of standard windows .ini files., i.e. the following format.  

[SectionName]
KeyName=Value

e.g. To read the value of "mykey" from the "mysection" part of an ini file, into the variable "%result%":
IniRead, result, c:\\mypath\\myfile.ini, mysection, mykey

e.g. To write the text "womble" into the same section and key:
IniWrite, womble, c:\\mypath\\myfile.ini, mysection, mykey

e.g. To write the DOS path information into the same section and key:
IniWrite, %path%, c:\\mypath\\myfile.ini, mysection, mykey

e.g. To delete the DOS path information into the same section and key:
IniDelete, c:\\mypath\\myfile.ini, mysection, mykey

NB. The full path and filename of the .ini file must be given.


InputBox,<variable>, <title>, <message> [,hide]

Will cause a dialog box with <message> to appear. The user can enter text, press OK, and the text will be stored in the DOS variable <variable>.  If the "hide" parameter is used, input will be masked (eg. for passwords).

e.g.
InputBox, MyMessage, AutoIt, Please - Enter some text to display!
MsgBox, 0, AutoIt, %MyMessage%

e.g.
InputBox, password, AutoIt, Please enter your password (input is hidden), hide


LeftClick, <x>, <y>
RightClick, <x>, <y>

Simulates a left or right mouse button click. The X and Y co-ordinates are relative to the currently active window. Run AutoIt in reveal mode to determine the required co-ordinates of a window.
To perform a double-click, simply run the command twice :)


LeftClickDrag, <x1>, <y1>, <x2>, <y2>
RightClickDrag, <x1>, <y1>, <x2>, <y2>


Drags the mouse pointer from x1,y1 to x2,y2 with the relevant mousebutton held down.  The co-ordinates are relative to the current active window.


MouseGetPos, <x Variable>, <y Variable>

This command will get the current position of the mouse cursor into the 'x' and 'y' variables.  The co-ords are relative to the active window.

e.g.
MouseGetPos, xpos, ypos
MsgBox, 0, Examples,  The mouse is at position %xpos% %ypos%


MouseMove, <x pos>, <y pos>

This command will move the mouse cursor to the position <xpos>, <ypos>.  The co-ords are relative to the active window.


MsgBox, <display mode>, <title>, <message>

Displays a dialog box with the specified message. Different display modes will give different results (appearance, number of buttons). A list of modes is given below, add up the numbers of the display modes you want.

e.g. To display "Hello" with just an "OK" button:
MsgBox, 0, AutoIt, Hello

e.g. To display "Hello" with an exclamation box and OK and Cancel:
MsgBox, 49, AutoIt, Hello
(1=OKCANCEL, 48=Exclamation, = 49)

Function AutoIt Value
MB_OK 0
MB_OKCANCEL 1
MB_ABORTRETRYIGNORE 2
MB_YESNOCANCEL 3
MB_YESNO 4
MB_RETRYCANCEL 5
   
MB_ICONHAND 16
MB_ICONQUESTION  32
MB_ICONEXCLAMATION 48
MB_ICONASTERISK 64
   
MB_APPLMODAL 0
MB_SYSTEMMODAL 4096
MB_TASKMODAL 8192

 


Random, <Output Variable>, <Min Value>, <Max Value>

This command produces a random number between <Min Value> and <Max Value>.  (These values must be between 0 and 32767).

e.g. To produce a random number between 1 and 200
Random, output, 1, 200
MsgBox, 0, Result, %output%

(This would output the random number between 1 and 200)


RegRead, Variable, ValueType, RegKey, RegSubkey, ValueName

This command allows you to read REG_SZ and REG_DWORD values from the regsitry.  If the command is successful %ERRORLEVEL% is set to 0, otherwise it is set to 1.

RegKey must be either "HKEY_LOCAL_MACHINE", "HKEY_CURRENT_USER", "HKEY_USERS", "HKEY_CURRENT_CONFIG" or "HKEY_CLASSES_ROOT".
ValueType must be "REG_DWORD" or "REG_SZ".

e.g. To read the location of the "Program Files" directory into the variable "TestKey":
RegRead, TestKey, REG_SZ, HKEY_LOCAL_MACHINE, Software\\Microsoft\\Windows\\CurrentVersion, ProgramFilesDir
MsgBox, 0, Example, Program Files are located in %TestKey%


RegWrite, ValueType, RegKey, RegSubKey, ValueName, Value

Similar to the RegRead command, this command will allow you to create or modify a registry key.  If the command is successful %ERRORLEVEL% is set to 0, otherwise it is set to 1.

e.g. To change the wallpaper of the current user:
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\\Desktop, Wallpaper, C:\\Mycrazybitmap.bmp


RegDelete, RegKey, RegSubKey, ValueName

This command will delete a regsitry value. If the command is successful %ERRORLEVEL% is set to 0, otherwise it is set to 1.

e.g. To delete the wallpaper value of the current user (not particularly recommended :) ):
RegDelete, HKEY_CURRENT_USER, Control Panel\\Desktop, Wallpaper


Run, <Program path and name> [,<Working directory> [,<max | min | hide>]]

Executes a given program and proceeds to the next line of the script. N.B. The program to run and the working directory are separated by a comma ','. The working directory is optional.

>>>>> N.B. Because the '\' character is special you must use '\\' when specifying paths! <<<<<

e.g.
Run, notepad.exe, C:\\WINDOWS
Run, C:\\Program Files\\Microsoft Office\\Office\\WinWord.exe

The first command runs notepad and sets the working directory to "C:\WINDOWS".
The second command runs MS Word in the current directory.

You can also run command interpreter commands line Echo, Copy, etc.

e.g.
Run, COMMAND.COM /C Echo Hello > C:\\Hello.txt
OR
Run, %COMSPEC% /C Echo Hello > C:\\Hello.txt

Creates a file called C:\Hello.txt containing the word "Hello".


RunWait, <Program path and name> [,<Working directory> [,<max | min | hide>]]

Same as the Run command but waits for the program to finish before continuing (recommended when running DOS commands such as copy, md, del, etc.).  

This command will also set the variable %ERRORLEVEL% to the return code of the program.


Repeat, <Count>
EndRepeat

This will repeat a section of the script up to the following "EndRepeat" command a total of <Count> times.  If <Count> is zero, the loop will be infinite.  Repeat statements can be nested.

e.g.
Repeat, 10
MsgBox, 0, Example, This will be output ten times!
EndRepeat


Send, <Series of key presses>

Sends a set of keystrokes to the currently active window. (The syntax of these keystrokes can be found in the following section).

e.g 
Send, This is a line of text#{ENTER}


SetEnv, <variable>, <value>

This command will set an environment variable to the specified value.
N.B. This variable only exists within AutoIt you will not be able to access it from DOS.

e.g. To set the Env variable "ERROR" to "There has been an error":
SetEnv, ERROR, There has been an error.

To use this variable, use the percent symbol:

e.g. After running the previous command, this will output "There has been an error":
MsgBox, 1, AutoIt, %ERROR%


SetKeyDelay, <milliseconds>

Changes the delay between keystrokes in milliseconds. Max is 32767.
Default is 20ms. 1000 milliseconds = 1 second.


SetTitleMatchMode, <mode>

Changes the way that window titles are matched against the script.
Valid modes are "1" and "2" - the default is "1". This mode affects most of the commands within AutoIt that have any sort of window title and text in the command, i.e. WinWait, WinWaitActive, IfWinActive, etc.

e.g.
; Script using mode 1 (default)
SetTitleMatchMode, 1

; Script using mode 2
SetTitleMatchMode, 2

mode 1

In the script you specify the start of a window title to match. i.e. for the notepad.exe window (Untitled - Notepad), valid matches would be:
"Untitled", "Untitled -", "Unt" and "Untitled - Notepad".

mode 2

In the script you can specify ANY substring of the window title you want to match. Again for the notepad.exe window valid matches would be:
"Untitled", "Untitled - Notepad", "Notepad", "No".


SetWinDelay, <Milliseconds>

This changes the time that AutoIt pauses after carrying out a window related function (waiting for, minimizing, restoring, etc.) before continuing.  This is useful on very slow machines, or when you have things like window animation enabled.  The default is 500 milliseconds.

e.g.
SetWinDelay, 2000
Run, Notepad.exe
WinWaitActive, Untitled - Notepad
Send, Hello

In this example there would be a pause of 2000 milliseconds (2 seconds) after notepad has started until the words "Hello" appear.


Shutdown, <Flag>

This command allows you to perform various forms of shutdown.  The type is determined by <Flag>.  The flag can be a combination from the table below:

Function

Flag
Log off the current user 0
Shutdown the workstation 1
Reboot the workstation 2
Force closing of applications (may lose unsaved work) 4
Shutdown and power off (if supported) 8

e.g. To shutdown and force applications to close without saving = Shutdown + Force = 1 + 4 = 5:
Shutdown, 5


Sleep, <milliseconds>

Halts execution of the script for the given number of milliseconds. Max is 32767.
1000 milliseconds = 1 second.


SplashTextOn, <Width>, <Height>, <Title>, <Message>

This command brings up a window the specified message and title.  The window stays topmost without interfering with windows behind it.  Useful for automation when you can bring up a "Don't Touch" message for the user without affecting other windows.


SplashTextOff

Removes the splash text screen from view.


StringCaseSense, <On | Off>

This command will turn case sensitivity on or off for the commands: IfEqual, IfNotEqual, IfInString, IfNotInString, and StringReplace.

Default is off (i.e. comparisons are NOT case sensitive)


StringLeft, <Output Variable> , <Input Variable>, <Number of chars to extract>
StringRight, <Output Variable> , <Input Variable>, <Number of chars to extract>

This command takes the contents of <Input Variable>, extracts a number of characters and places the result in <Output Variable>.

e.g. To extract the leftmost 5 characters of a string
SetEnv, test, Hello this is a test string
StringLeft, output, test, 5
MsgBox, 0, AutoIt, The resulting string is %output%

(The output would be "Hello")

e.g. To extract the rightmost 6 characters of a string
SetEnv, test, Hello this is a test string
StringRight, output, test, 5
MsgBox, 0, AutoIt, The resulting string is %output%

(The output would be "string")


StringMid, <Output Variable> , <Input Variable>, <Start char>, <Number of chars to extract>

This command takes the contents of <Input Variable>, extracts a number of characters starting from <Start char>  and places the result in <Output Variable>.

e.g. To extract 6 characters starting from character 3
SetEnv, test, Hello this is a test string
StringMid, output, test, 7, 4
MsgBox, 0, AutoIt, The resulting string is %output%

(The output would be "this")


StringLen, <Output Variable> , <Input Variable>

This command takes the contents of <Input Variable> and puts the number of characters in the string into <Output Variable>.

e.g. 
SetEnv, test, Hello this is a test string
StringLen, output, test
MsgBox, 0, AutoIt, The string length is %output%

(The output would be "27")


StringReplace, <Output Variable> , <Input Variable>, <Search String>, <Replace String>

This command will search for the <Search String> in the contents of the variable <Input Variable>.  The search string will be replace by <Replace String> and the result will be placed in the variable <Output Variable>.  If the search string cannot be found, the contents of <Output Variable> will be the same as <Input Variable>

e.g. 
SetEnv, teststring, Hello this is a test string
StringReplace, output, teststring, test, testing testing 1 2 3
MsgBox, 0, AutoIt, %output%

(The output would be "Hello this is a testing testing 1 2 3 string")


StringTrimLeft, <Output Variable> , <Input Variable>, <Number of chars to trim>
StringTrimRight, <Output Variable> , <Input Variable>, <Number of chars to trim>

This command takes the contents of <Input Variable>, trims a number of characters and places the result in <Output Variable>.

e.g. To trim the leftmost 6 characters of a string
SetEnv, test, Hello this is a test string
StringLeft, output, test, 6
MsgBox, 0, AutoIt, The resulting string is %output%

(The output would be "this is a test string")

e.g. To trim the rightmost 7 characters of a string
SetEnv, test, Hello this is a test string
StringRight, output, test, 7
MsgBox, 0, AutoIt, The resulting string is %output%

(The output would be "Hello this is a test")


WinGetActiveTitle, <Variable>

This command gets the title of the active window and puts it in the DOS variable <Variable>

e.g.
Sleep, 2000
WinGetActiveTitle, myvar
MsgBox, 0, AutoIt, The active window was %myvar%


WinGetActiveTitle, <Variable>

This command gets the title of the active window and puts it in the DOS variable <Variable>

e.g.
Sleep, 2000
WinGetActiveTitle, myvar
MsgBox, 0, AutoIt, The active window was %myvar%


WinKill, <Window Title> [,<Window Text>]

Similar to WinClose, but if the window has not closed after a couple of seconds (Asking to save, crashed, etc.) the window will be forcibly terminated.


WinWait, <Window Title> [,<Window Text> [,<Timeout>]]

Stops script execution until the specified window exists. The window does not need be active. 

If specified the "Timeout" is in seconds.  After the line has executed the Env variable %ERRORLEVEL% will be set to 0 if the function completed normally, or 1 if the wait timed out.  The maximum value of Timeout is 32767 seconds.

e.g.  Wait forever for the notepad window
WinWait, Untitled - Notepad

e.g.  Wait for five seconds for the notepad window
WinWait, Untitled - Notepad,, 5


WinWaitClose, <Window Title> [,<Window Text> [,<Timeout>]]

Stops script execution until the specified window ceases to exist.

If specified the "Timeout" is in seconds.  After the line has executed the Env variable %ERRORLEVEL% will be set to 0 if the function completed normally, or 1 if the wait timed out.

e.g.
WinWaitClose, Untitled - Notepad


WinWaitActive, <Window Title> [,<Window Text> [,<Timeout>]]

Stops script execution until the specified window to exists and is active.

If specified the "Timeout" is in seconds.  After the line has executed the Env variable %ERRORLEVEL% will be set to 0 if the function completed normally, or 1 if the wait timed out.


WinWaitNotActive, <Window Title> [,<Window Text> [,<Timeout>]]

Stops script execution until the specified window ceases to be active.

If specified the "Timeout" is in seconds.  After the line has executed the Env variable %ERRORLEVEL% will be set to 0 if the function completed normally, or 1 if the wait timed out.


WinHide, <Window Title> [,<Window Text>]
WinShow, <Window Title> [,<Window Text>]
WinRestore, <Window Title> [,<Window Text>]
WinMinimize, <Window Title> [,<Window Text>]
WinMaximize, <Window Title> [,<Window Text>]
WinActivate, <Window Title> [,<Window Text>]
WinClose, <Window Title> [,<Window Text>]

If the window exists, the relevant command (i.e. minimizing, hiding, activating, etc.) will be performed.


WinMove, <Window Title>, [<Window Text>], <X>, <Y>, <Width>, <Height>

If the window in Title and Text exists, it is moved to <X>, <Y> and resized to <Width>, <Height>

e.g.

Run, notepad.exe
WinWaitActive, Untitled - Notepad
WinMove, Untitled - Notepad,, 0, 0, 100, 100

This moves the notepad window to 0,0 and changes the size of the window to 100,100

Remember to include the comma if you don't specify Window text.  "default" can be used in place of Width and Height if you don't want to change the size of the window

e.g.
WinMove, Untitled - Notepad,, 0, 0, default, default


WinSetTitle, <Window Title>, [Window Text], <New Title>

Use this command to rename a window.

e.g.
Run, notepad.exe
WinWaitActive, Untitled - Notepad
WinSetTitle, Untitled - Notepad,, Renamed Notepad!


WinMinimizeAll

Simply, this command minimizes all windows.


Back to Contents

"Send" Command Syntax

The "Send" command syntax is similar to that of ScriptIt and the Visual Basic "SendKeys" command. Characters are sent as written with the exception of the following characters:

'!'
This tells AutoIt to send an ALT keystroke, therefore "Send,This is text!a" would send the keys "This is text" and then press "ALT+a". 

N.B. Some programs are very choosy about capital letters and ALT keys, i.e. "!A" is different to "!a". The first says ALT+SHIFT+A, the second is ALT+a. If in doubt, use lowercase!

'+'
This tells AutoIt to send a SHIFT keystroke, therefore "Send,Hell+o" would send the text "HellO". "Send,!+a" would send "ALT+SHIFT+a".

'^'
This tells AutoIt to send a CONTROL keystroke, therefore "Send,^!a" would send "CTRL+ALT+a".

N.B. Some programs are very choosy about capital letters and CTRL keys, i.e. "^A" is different to "^a". The first says CTRL+SHIFT+A, the second is CTRL+a. If in doubt, use lowercase!

'#'
The hash is used as a key delimiter to make a line easier to read.  i.e. "Send, H#e#l#l#o" is the same as "Send,Hello".


Certain special keys can be sent and should be enclosed in braces:

N.B.  Windows does not allow the simulation of the "CTRL-ALT-DEL" combination!

Send Command

Resulting Keypress

{!}!
{#}#
{+}+
{^} ^
{{}{
{}}}
{SPACE} SPACE
{ENTER} ENTER
{ALT} ALT
{BACKSPACE} or {BS} BACKSPACE
{DELETE} or {DEL} DELETE
{UP} Cursor up
{DOWN} Cursor down
{LEFT} Cursor left
{RIGHT} Cursor right
{HOME} HOME
{END} END
{ESCAPE} or {ESC} ESCAPE
{INSERT} or {INS} INS
{PGUP} PGUP
{PGDN} PGDN
{F1} - {F12} Function keys
{TAB} TAB
{PRINTSCREEN} PRINTSCR
{LWIN} Left Windows key
{RWIN} Right Windows key
{NUMLOCK} NUMLOCK
{CTRLBREAK} Ctrl+break
{PAUSE} PAUSE
{CAPSLOCK} CAPSLOCK
{NUMPAD0} - {NUMPAD 9} Numpad digits
{NUMPADMULT} Numpad Multiply
{NUMPADADD} Numpad Add
{NUMPADSUB} Numpad Subtract
{NUMPADDIV} Numpad Divide
{NUMPADDOT} Numpad period
{APPSKEY} Windows App key
{ALTDOWN} Holds the ALT key down until {ALTUP} is sent
{SHIFTDOWN} Holds the SHIFT key down until {SHIFTUP} is sent
{CTRLDOWN} Holds the CTRL key down until {CTRLUP} is sent
{ASC nnnn} Send the ALT+nnnn key combination


To send the ASCII value A (same as pressing ALT+65 on the numeric keypad)
    Send, {ASC 65}

Single keys can also be repeated, e.g.
    Send, {DEL 4}    Presses the DEL key 4 times
    Send, {S 30}       Sends 30 'S' characters
    Send, +{TAB 4}  Presses SHIFT+TAB 4 times

Back to Contents

[ADLIB] Section

The [ADLIB] section is optional, and if present should be placed at the end of the script file. The ADLIB section is designed to cope with unexpected conditions. The ADLIB section consists of single line commands that check if a window is active and if so, send keys to it.
The ADLIB section must start with the line "[ADLIB]".

The format of the a line in the ADLIB section is:

<Window Title>,<Window Text>,<Command>

e.g.
Run,Notepad.exe
WinWaitActive,Untitled - Notepad
Send,12345678#!{F4}
WinWaitClose,Untitled - Notepad

[ADLIB]
Notepad, save the changes?, Send, !n

Without the ADLIB section, this script would never end as Notepad would never
close until someone responded to the message "Do you want to save the changes?".

ADLIB commands must contain a window title and some text on the window. If there is no text on the window, or if you don't want to specify any, then you must use two commas.

e.g.
Run,Notepad.exe
WinWaitActive,Untitled - Notepad
Send,12345678#!{F4}
WinWaitClose,Untitled - Notepad

[ADLIB]
Notepad,, Send, !n


Back to Contents

Examples

Some English examples are included with this archive, others can be found on the AutoIt Home Page.

Back to Contents

AutoIt History

03/12/2000 - v2.51

07/11/2000 - v2.5

17/6/2000 - v2.42

11/02/2000 - v2.41

09/02/2000 - v2.4

20/12/99 - v2.32

12/12/99 - v2.31

10/12/99 - v2.3

25/11/99 - v2.23

23/11/99 - v2.22

20/11/99 - v2.21

18/11/99 - v2.2

16/09/99 - v2.11

11/09/99 - v2.1

28/08/99 - v2.03

26/08/99 - v2.02

18/08/99 - v2.01

16/08/99 - v2.0

NB. Some changes mean that old AutoIt scripts may need to be modified slightly - Please re-read the documentation carefully if you are upgrading! Hence the jump from v1.8 to v2.0 - SORRY, but things needed changing to ease implementation of new commands that have been requested. I personally use v1.8 for old scripts and v2.0 for any new scripts I write.

02/04/99 - v1.8

14/03/99 - v1.7

28/02/99 - v1.6

20/02/99 - v1.5

20/01/99 - v1.4

18/01/99 - v1.3

14/01/99 - v1.2

12/01/99 - v1.1

12/01/99 - v1.0

Back to Contents

The Wish List

Here are some of the current outstanding suggestions (including stuff that I can't work out how to do...), if you have any more then pass them along.

Back to Contents

Thanks To...

Back to Contents