AutoIt v1.4 - 20th January, 1999 ================================ (C)1999 Jonathan Bennett Email: jbennett@hidden.demon.co.uk New releases at: http://www.hidden.demon.co.uk/AutoIt/index.html Email me, and I'll notify you of a new release. ----------------------------------------------------------------------------- License ======== This program is EmailWare. If you use it, drop me an email. The program may be freely distributed as long as the original package is intact. Disclaimer ========== This program is provided "As is". Use it at your own risk. There are no warranties, expressed or implied. Introduction ============ AutoIt was primarily designed to assist in automatically installing software. Many software packages such as MS Office, IE4, Mcafee have their own automated installation routines - most applications don't. AutoIt gets around this by using a script file to perform window commands (waiting for, hiding, activating, etc.) and to send keystrokes to specific windows. This allows AutoIt to perform the automatic installation of such software. It can also be used to automate simple tasks. Most keystrokes can be sent (i.e. not just alphanumerics, but characters like !"$%^&*()_-+=, using any language keyboard (reports please! :) ). AutoIt was my attempt to write a replacement for the Microsoft utility "ScriptIt". Here are the associated advantages and disadvanatages over ScriptIt. Advantages ---------- - It's much smaller at 40Kb (600Kb smaller than ScriptIt). - It will be updated if problems are found (or suggestions made)!!!!! - The "Reveal" function is much better. - Non-active as well as active windows can be waited for. - Variable delays are possible (defined in milliseconds). - The time in between keystrokes can be altered (in milliseconds). - When running an application, a working directory can be specified. - Can correctly activate windows under Win98/NT 5.0 (Use "WinActivate"). - Don't have to wait for a window in order to send keystrokes (e.g. send keys to the desktop). - Free, free, free! :) Disadvantages ------------- - None of the Wilson WinBatch commands are featured. (But who used them anyway? :) ) - Due to the command names I've used, the scripts tend to be a little larger. Conventions =========== Parameters are shown in angled brackets, optional parameters are shown in square brackets. e.g. ,[,] This is a command, followed by a comma and parameter1, optionally followed by a comma and parameter2. i.e. , OR ,, Command Line Syntax =================== AutoIt is executed from the command line in the two following ways: AutoIt /reveal AutoIt /reveal2 OR AutoIt Reveal Mode ----------- When launched with the "/reveal" command switch, the program pauses for five seconds and then displays information on the currently active window (five seconds should be enough time for you to switch to the window that you are interested in). This allows you to see what information AutoIt can "see" on a window. The switch "/reveal2" is similar, but causes the text to be continuously updated. N.B. As with ScriptIt, not all text on a window can be "Seen" - experiment! Script Mode ----------- AutoIt will execute the script filename given on the command line. The file can have any extension (I usually use .ini files as scripts). Script File Syntax ================== ; Start of script ; Comments are indicated by a semi-colon , , , ; More comments, etc ; End of script There may also be an optional [ADLIB] section at the end of the script. (see below) Each line in the script can contain leading and trailing white spaces (space or tabs). i.e. " Wait , Parameter1 , Parameter2 " will be evaluated as: "Wait,Parameter1,Parameter2" When using the key "Send" command, you may wish to send spaces, in this case use "{SPACE}" to denote a space. If a line contains a command that is not recognised, it will be treated as a comment. 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". Use the "/reveal" mode to see what text is present on a window. Script Commands =============== The following commands are currently recognised (commands are not case sensitive): ,[*] --------------------------------------------------- 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 '*'. The working directory is optional. 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 Creates a file called C:\Hello.txt containing the word "Hello". ,[*] ------------------------------------------------------- Executes a given program and waits for it to close before proceeded to the next line of the script. e.g. RunWait,Notepad.exe , ------------------------------ 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} WinWait,[,] -------------------------------------- Stops script execution until the specified window exists. The window does not need be active. e.g. WinWait,Untitled - Notepad WinWaitClose,[,] ------------------------------------------- Stops script execution until the specified window ceases to exist. e.g. WinWaitClose,Untitled - Notepad WinWaitActive,[,] -------------------------------------------- Stops script execution until the specified window to exists and is active. WinHide,[,] WinRestore,[,] WinMinimize,[,] WinMaximize,[,] WinActivate,[,] WinClose,[,] ------------------------------------------ Stops script execution until the specified window exists and then performs the relevant command, i.e. minimising, hiding, restoring, etc. >> N.B. WinActivate will bring a window to the top even under Win98/NT5. << Sleep, -------------------- Halts execution of the script for the given number of milliseconds. Max is 32767. SetKeyDelay, -------------------------- Changes the delay between keystrokes in milliseconds. Max is 32767. Default is 10ms. "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". '#' 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: Send Command Resulting Keystroke ------------ ------------------- {#} # {!} ! {^} ^ {+} + {{} { {}} } {SPACE} Space {ENTER} The return/enter key is sent {ALT} Alt key {BACKSPACE} Backspace {BS} Backspace {DEL} Delete {DELETE} Delete {DOWN} Cursor down {END} End {ESC} Escape {ESCAPE} Escape {F1}-{F12} Function keys {HOME} Home {INS} Insert {INSERT} Insert {LEFT} Cursor left {PGDN} Page down {PGUP} Page up {RIGHT} Cursor right {TAB} Tab {UP} Cursor up Keys can also be repeated, e.g. {DEL 4} Presses the DEL key 4 times {S 30} Sends 30 'S' characters +{TAB 4} Presses SHIFT+TAB 4 times [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: ,, e.g. Run,Notepad.exe WinWaitActive,Untitled - Notepad Send,12345678#!{F4} WinWaitClose,Untitled - Notepad [ADLIB] Notepad,save the changes?,!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,,!n Examples ======== See the "Examples" directory that accompanies this archive for some examples. Thanks to ========= - The people from Computacenter who tested it. - Steve Hurcombe for the "/reveal2" suggestion.