406
v3.3.6.1 ©1999-2010 Jonathan Bennett & AutoIt Team AutoIt v3 Homepage AutoIt Documentation Introduction License Installation Directory Frequently Asked Questions (FAQ) Credits History / ChangeLog History of AutoIt and Developers Using AutoIt Running Scripts AutoIt on Windows Vista Command Line Parameters Script Editors Compiling Scripts AutoIt Window Info Tool (AU3Info) Window Titles and Text (Basic) Window Titles and Text (Advanced) Controls Unicode Support Intended Use Notes for AutoIt v2 Users Running under Windows 64 - bit Edition Tutorials My First Script (Hello World) Simple Notepad Automation WinZip Installation String Regular expression Language Reference Datatypes Variables Macros Operators Conditional Statements Loop Statements Functions Comments GUI Reference GUI Concepts GUI MessageLoop Mode GUI OnEvent Mode Keyword Reference Keyword Reference Macro Reference Macro Reference Function Reference Function Reference Appendix AutoIt3 limits/defaults ASCII Characters CLSIDs of Special Folders GUI Control Styles Splash... Fonts @OSLang Values Send Key List Windows Message Codes

Auto It 3

Embed Size (px)

Citation preview

v3.3.6.1 1999-2010 Jonathan Bennett & AutoIt Team AutoIt v3 Homepage

AutoIt Documentation

Introduction License Installation Directory Frequently Asked Questions (FAQ) Credits History / ChangeLog History of AutoIt and Developers

Using AutoIt

Running Sc ripts AutoIt on Windows Vista Command Line Parameters Script Editors Compiling Sc ripts AutoIt Window Info Tool (AU3Info) Window Titles and Text (Basic) Window Titles and Text (Advanced) Controls Unicode Support Intended Use Notes for AutoIt v2 Users Running under Windows 64-bit Edition

Tutorials

My First Script (Hello World) Simple Notepad Automation WinZip Installation String Regular expression

Language Reference

Datatypes Variables Macros Operators Conditional Statements Loop Statements Functions Comments

GUI Reference

GUI Concepts GUI MessageLoop Mode GUI OnEvent Mode

Keyword Reference

Keyword Reference

Macro Reference

Macro Reference

Function Reference

Function Reference

Appendix

AutoIt3 limits/defaults ASCII Characters CLSIDs of Special Folders GUI Control Styles Splash... Fonts @OSLang Values Send Key List Windows Message Codes

v3.3.6.1 1999-2010 Jonathan Bennett & AutoIt Team AutoIt v3 Homepage

IntroductionAutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks in a way not possible or reliable with other languages (e.g. VBScript and SendKeys). AutoIt is also very small, self-contained and will run on all versions of Windows out-of-the-box with no annoying "runtimes" required! AutoIt was initially designed for PC "roll out" situations to reliably automate and configure thousands of PCs. Over time it has become a powerful language that supports complex expressions, user functions, loops and everything else that veteran scripters would expect. Features:

Easy to learn BASIC-like syntax Simulate keystrokes and mouse movements Manipulate windows and processes Interact with all standard windows controls Scripts can be compiled into standalone executables Create Graphical User Interfaces (GUIs) COM support Regular expressions Directly call external DLL and Windows API functions Scriptable RunAs functions Detailed helpfile and large c ommunity-based support forums Compatible with Windows 95 / 98 / ME / NT4 / 2000 / XP / 2003 / Vista / 2008 Unicode and x64 support Digitally signed for peace of mind Works with Windows Vista's User Account Control (UAC)

AutoIt has been designed to be as small as possible and stand-alone with no external .dll files or registry entries required making it safe to use on Servers. Scripts can be compiled into stand-alone executables with Aut2Exe. Also supplied is a combined COM and DLL version of AutoIt called AutoItX that allows you to add the unique features of AutoIt to your own favourite sc ripting or programming languages! Best of all, AutoIt continues to be FREE - but if you want to support the time, money and effort spent on the project and web hosting then you may donate at the AutoIt homepage.

Features in DetailBasic-like Syntax and Rich Function Set AutoIt has a BASIC-like syntax which means that most people who have ever written a script or used a high-level language should be able to pick it up easily. Although it started life as a simple automation tool, AutoIt now has functions and features that allow it to be used as a general purpose scripting language (with awesome automation as well of course!). Language features include:

The usual high-level elements for functions, loops and expression parsing A staggering amount of string handling functions and a Perl compatible regular expression engine (using the PCRE library). COM support Call Win32 and third-party DLL APIs

Built-in Editor with Syntax Highlighting AutoIt comes with a customised "lite" version of SciTe that makes editing scripts easy. Users can also download a complete version of SciTe that includes additional tools to make things even easier. Standalone and Small AutoIt is a very small and standalone application with no reliance on massive runtimes like .NET or VB. All you need to run AutoIt scripts are the main AutoIt executable (AutoIt3.exe) and the script. Scripts can also be encoded into standalone executables with the built-in script compiler Aut2Exe. International and 64-bit Support AutoIt is fully Unicode aware and also includes x64 versions of all the main components! How many other free scripting languages can you say that about? Key and Mouse Simulation Much time has been spent optimizing the keystroke and mouse simulation functions to be as accurate as possible on all versions of Windows. All the mouse and keyboard routines are highly configurable both in terms of simulation "speed" and functionality. Window Management You can expect to move, hide, show, resize, activate, close and pretty much do what you want with windows. Windows can be referenced by title, text on the window, size, position, class and even internal Win32 API handles.

Controls Directly get information on and interact with edit boxes, check boxes, list boxes, combos, buttons, status bars without the risk of keystrokes getting lost. Even work with controls in windows that aren't active! Graphical User Interfaces (GUIs) AutoIt v3 will also allow you to create some complex GUIs - just like those below!

And much, much more...

Software LicenseAutoIt Author : Jonathan Bennett and the AutoIt Team WWW : http://www.autoitscript.com/autoit3/ Email : support at autoitscript dot com ________________________________________________________ END-USER LICENSE AGREEMENT FOR THIS SOFTWARE This End-User License Agreement ("EULA") is a legal agreement between you (either an individual or a single entity) and the mentioned author of this Software for the software product identified above, which includes computer software and may include associated media, printed materials, and "online" or electronic documentation ("SOFTWARE PRODUCT"). By installing, copying, or otherwise using the SOFTWARE PRODUCT, you agree to be bound by the terms of this EULA. If you do not agree to the terms of this EULA, do not install or use the SOFTWARE PRODUCT. SOFTWARE PRODUCT LICENSE The SOFTWARE PRODUCT is protected by copyright laws and international copyright treaties, as well as other intellectual property laws and treaties. The SOFTWARE PRODUCT is licensed, not sold. The definition of SOFTWARE PRODUCT does not includes any files generated by the SOFTWARE PRODUCT, such as compiled script files in the form of standalone executables. 1. GRANT OF LICENSE This EULA grants you the following rights: Installation and Use. You may install and use an unlimited number of copies of the SOFTWARE PRODUCT. Reproduction and Distribution. You may reproduce and distribute an unlimited number of copies of the SOFTWARE PRODUCT either in whole or in part; each copy should include all copyright and trademark notices, and shall be accompanied by a copy of this EULA. Copies of the SOFTWARE PRODUCT may be distributed as a standalone product or included with your own product. Commercial Use. You may use the SOFTWARE PRODUCT for commercial purposes. You may sell for profit and freely distribute scripts and/or compiled scripts that were created with the SOFTWARE PRODUCT. Reverse engineering. You may not reverse engineer or disassemble the SOFTWARE PRODUCT or compiled scripts that were created with the SOFTWARE PRODUCT. 2. COPYRIGHT All title and copyrights in and to the SOFTWARE PRODUCT (including but not limited to any images, photographs, animations, video, audio, music, text, and "applets" incorporated into the SOFTWARE PRODUCT), the accompanying printed materials, and any copies of the SOFTWARE PRODUCT are owned by the Author of this Software. The SOFTWARE PRODUCT is protected by copyright laws and international treaty provisions. Therefore, you must treat the SOFTWARE PRODUCT like any other copyrighted material. MISCELLANEOUS If you acquired this product in the United Kingdom, this EULA is governed by the laws of the United Kingdom. If this product was acquired outside the United Kingdom, then local law may apply. Should you have any questions concerning this EULA, or if you desire to contact the author of this Software for any reason, please contact him/her at the email address mentioned at the top of this EULA. LIMITED WARRANTY 1. NO WARRANTIES The Author of this Software expressly disclaims any warranty for the SOFTWARE PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as is" without warranty of any kind, either express or implied, including, without limitation, the implied warranties or merchantability, fitness for a particular purpose, or non-infringement. The entire risk arising out of use or performance of the SOFTWARE PRODUCT remains with you. 2. NO LIABILITY FOR DAMAGES In no event shall the author of this Software be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or any other pecuniary loss) arising out of the use of or inability to use this product, even if the Author of this Software has been advised of the possibility of such damages. Because some states/jurisdictions do not allow the exclusion or

limitation of liability for consequential or incidental damages, the above limitation may not apply to you. [END OF LICENSE]

Install Directory StructureThe AutoIt installer creates a directory structure (usually located in \Program Files\AutoIt3) summarized in the following table. The installer also creates Start Menu shortcuts, but no other files are added or modified. Files and Directories (Top-level files) AutoIt3.exe AutoIt3_x64.exe AU3Info.exe AU3Info_x64.exe AU3Check.exe AutoIt.chm Uninstall.exe AutoIt v3 Website.url Aut2Exe Icons\ Aut2Exe.exe Aut2Exe_x64.exe AutoItSC.bin AutoItSC_x64.bin UPX.exe Examples GUI\ Helpfile\ Extras AutoUpdateIt\ Editors\ Exe2Aut\ Icons Contains icons used for the .au3 filetype icon in Explorer. Include Contains standard include files (pre-written user functions). See the Library Functions) AutoItX Contains a DLL version of AutoIt v3 that provides a subset of the features of AutoIt via an ActiveX/COM and DLL interface. SciTe Contains a light version of SciTe which allows syntax coloring. It should be repeated that to run AutoIt scripts, the only required file is AutoIt3.exe. If you compile a script into an executable then a user does not require AutoIt to be installed to run that compiled executable.(e x ce ption: Unde r W indows NT 4 the file PSAPI.dll ne e ds to be in the path or AutoIt dire ctory for the Proce ss...() re late d functions to work )

Description The AutoIt main program and only file required to run scripts! The x64 version of AutoIt (if installed). The AutoIt Window Info Tool. The x64 version of Au3Info (if installed). The AutoIt syntax checker. This help file which use AutoIt3.chm and UDFs3.chm The AutoIt uninstaller. A shortcut to http://www.autoitscript.com/autoit3/ Contains icons used for the .au3 filetype icon in Explorer. The script compiler. The x64 version of Aut2Exe (if installed). Executable stub for compiled scripts. x64 executable stub for compiled scripts. The UPX compressor (shinks the size of exe files). Contains examples of GUIs written in AutoIt. Contains scripts used in many of the help file examples. Contains a script for easily retrieving the latest version of AutoIt3. Contains syntax coloring definitions for some popular text editors. Contains utils for converting compiled scripts back in to source code. Contains SQLite command line executable and an help file.

SQLite\

v2_to_v3_Converter\ Contains a tool for converting v2.64 script to AutoIt v3 syntax.

Registry KeysThe AutoIt installer creates registry keys under HKEY_LOCAL_MACHINE\Software\AutoIt v3 and

HKEY_CURRENT_USER\Software\AutoIt v3. The keys are NOT used/created when AutoIt utilities are run on machines that lack a full AutoIt installation--AutoIt is "clean" to run on servers, etc. The table below shows the default (or typical) registry keys. The keys in italic are not created by the installer itself but by the first execution of the corresponding utility: HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\ AutoIt (Default) InstallDir Version REG_SZ REG_SZ REG_SZ (value not set) C:\Program Files\AutoIt3 Version Number

HKEY_CURRENT_USER\Software\AutoIt v3\ Aut2Exe (Default) AllowDec ompile LastCompression LastExeDir LastIcon LastIconDir LastScriptDir AutoUpdateIt (Default) DoneOption DownloadDir Exe2Aut (Default) LastExeDir LastScriptDir AU3Info Default AlwaysOnTop ColorMode CoordMode HighlightColor HighlightControls Magnify WinH WinW WinX WinY REG_SZ REG_DWORD REG_DWORD REG_DWORD REG_DWORD REG_DWORD REG_DWORD REG_DWORD REG_DWORD REG_DWORD REG_DWORD (value not set) 0x1 0x1 0x1 0x0 0x1 0x0 0x01c 2 0x012c 0x0064 0x0064 REG_SZ REG_SZ REG_SZ (value not set) C:\ForExample\ REG_SZ REG_SZ REG_SZ (value not set) Notify C:\Downloads\ForExample\ REG_SZ REG_DWORD REG_DWORD REG_SZ REG_SZ REG_SZ REG_SZ (value not set) 0x1 0x2 My Documents C:\Program Files\AutoIt3\Aut2Exe\Icons My Documents

Frequently Asked Questions (FAQ)This section gives some of the more frequently asked questions from the forum. If you can't find the answer you seek here then the forum should be your first port of call.

Questions1. Why doesn't my old AutoIt v2.64 script run in v3? 2. Isn't v3 much more difficult than previous versions? 3. How can I convert my v2.64 scripts to v3? 4. Where is the "goto" command? 5. How can I run a DOS program from within AutoIt? 6. Why can I only use Run() to execute .exe and .com files? What about .msi / .txt and others? 7. Why do I get errors when I try and use double quotes (") ? 8. What do the window "title" and "text" parameters mean? 9. Why can't I print a variable using "My var is $variable"? 10. When I use Send() to send a variable odd things happen? 11. What is the difference between the return value and @error? 12. How can I exit my script with a hot-key? 13. How can I use a custom icon when compiling my scripts? 14. How can I make sure only one copy of my script is run? 15. What are the current technical limits of AutoIt v3? 16. I get a missing picture symbol in the Help file under the Examples.

1. Why doesn't my old AutoIt v2.64 script run in v3?v3 has a different language structure to v2.64. Previous versions of AutoIt were fine for what they were designed for - writing simple scripts to help with software installations. Over time people began using it for general and complicated scripting tasks. The old syntax and structure made this possible but very very difficult and cumbersome. The decision was made to make AutoIt more suitable for general automation tasks and to achieve that a more standard and basic-like language was made. This also means that if you already know a scripting language you will pick AutoIt v3 up easily. Back To Top

2. Isn't v3 much more difficult than previous versions?No. In fact in many instances it's much easier than previous versions as you don't have to try and force the language to do something it was never designed to do. It also uses a familiar BASIC-like language, and BASIC is known for being...well...basic :) The vast majority of old AutoIt scripts were focused around software installation and clicking "Next" a lot in dialog boxes. Most of these scripts can be converted to v3 simply by adding a couple of brackets here and there. Here is an example of such a script in v2 and v3 (simulating a software installation with a few dialogs that have a Next button and a Finish button) ; v2.64 Script WinWaitActive, Welcome, Welcome to the XSoft installation Send, !n WinWaitActive, Choose Destination, Please choose the Send, !n WinWaitActive, Ready to install, Click Next to install Send, !n WinWaitActive, Installation Complete, Click Finish to exit Send, !f WinWaitClose, Installation Complete ; v3 Script WinWaitActive("Welcome", "Welcome to the XSoft installation") Send("!n") WinWaitActive("Choose Destination", "Please choose the") Send("!n") WinWaitActive("Ready to install", "Click Next to install") Send("!n") WinWaitActive("Installation Complete", "Click Finish to exit") Send("!f") WinWaitClose("Installation Complete") Now, that wasn't so bad! :) As all "strings" are enclosed in quotes you no longer have to wrestle with problems caused by leading and trailing spaces in text. There is also fantastic support for many text editors so that when you are writing v3 scripts you can have syntax highlighting which makes everything much easier. Back To Top

3. How can I convert my v2.64 scripts to v3?The first thing you should ask yourself is "Do I need to convert my script?". v2.64 will continue to be downloadable and supported so don't update all

your scripts just for the sake of it - well not unless you want to :) There is a section in the Help file that shows how the commands in v2 and v3 are related - click here to see the page. One of the AutoIt v3 authors has written a utility to automatically convert v2 scripts to v3. Conversion is pretty good unless your code is a rats-nest of gotos :) You can find the converter in the "Extras" directory (Start \ AutoIt v3 \ Extras - or look in the directory that you installed AutoIt v3). Back To Top

4. Where is the "goto" command?Gone. It's evil. No, you can't ask why - it just is. It's like that lump of rock they find in the microwave at the end of the film Time Bandits :) AutoIt v3 features most of the common "loops" in use today and with these Goto is no longer required. Look up While, Do, For, ExitLoop, ContinueLoop and Functions for the modern way of doing things :) And while you are looking at help file sections check out these on loops, conditional statements and functions. I promise you, once you have got the hang of such things you will be able to script in virtually any other language within a couple of minutes. Just to get you started, the most basic use of Goto in version 2.64 was an infinite loop like: :mylabel ...do something... ...and something else... goto, mylabel A simple v3 version of that is a While loop that is always "true". While 1 = 1 ...do something... ...do something else... Wend Back To Top

5. How can I run a DOS program from within AutoIt?If you wanted to run something like a DOS "Dir" command then you must run it though the command interpreter (command.com or cmd.exe depending on your OS). The @Comspec macro contains the correct location of this file. You should use the RunWait() function as it waits for the DOS program to finish before continuing with the next line of the script. Here is an example of running the DOS Dir command on the C: drive: (effectively running the c ommand command.com /c Dir C:\ ) RunWait(@COMSPEC & " /c Dir C:\") Back To Top

6. Why can I only use Run() to execute .exe files? What about .msi / .txt and others?Only a few file extensions are usually "runable" - these are .exe, .bat, .com, .pif. Other file types like .txt and .msi are actually executed with another program. When you double click on a "myfile.msi" file what actually happens in the background is that "msiexec.exe myfile.msi" is executed. So to run a .msi file from AutoIt you would do: RunWait("msiexec myfile.msi") Or, run the command "start" which will automatically work out how to execute the file for you: RunWait(@COMSPEC & " /c Start myfile.msi") Or, use the ShellExecuteWait function which will automatically work out how to execute the file for you: ShellExecuteWait("myfile.msi") Back To Top

7. Why do I get errors when I try and use double quotes (") ?If you want to use double-quotes inside a string then you must "double them up". So for every one quote you want you should use two. For example if you wanted to set a variable to the string: A word in "this" sentence has quotes around it! You would do: $var = "A word in ""this"" sentence has quotes around it!" or use single quotes instead: $var = 'A word in "this" sentence has quotes around it!' Back To Top

8. What do the window "title" and "text" parameters mean?There is a detailed description here. Back To Top

9. Why can't I print a variable using "My var is $variable"?

If you have a variable called $msg and you want to print in inside a MsgBox then this will NOT work: MsgBox(0, "Example", "My variable is $msg") It will actually print My variable is $msg .What you need to do is tell AutoIt to join the string and the variable together using the & operator: MsgBox(0, "Example", "My variable is " & $msg) Advanced: If you have many variables to add into a string then you may find the StringFormat() function useful. For example, if I wanted to insert $var1 to $var5 into a string then it may be easier to do: $msg = StringFormat("Var1 is %s, Var2 is %s, Var3 is %s, Var4 is %s, Var5 is %s", $var1, $var2, $var3, $var4, $var5) MsgBox(0, "Example", $msg) Back To Top

10. When I use Send() to send a variable odd things happen?If you are sending the contents of a variable then be mindful that if it contains special send characters like ! ^ + {SPACE} then these will be translated into special keystrokes - rarely what is wanted. To overcome this use the RAW mode of Send() that does not translate special keys: Send($myvar, 1) Back To Top

11. What is the difference between the return value and @error?Generally a return value is used to indicate the success of a function. But, if a function is already returning something ( like WinGetText() ) then we need to have a way of working out if the function was successful, so we set @error instead. Back To Top

12. How can I exit my script with a hot-key?Ah, an easy one. If you want to make your script exit when you press a certain key combination then use the HotKeySet() function to make a user function run when the desired key is pressed. This user function should just contain the Exit keyword. Here some code that will cause the script to exit when CTRL+ALT+x is pressed: HotKeySet("^!x", "MyExit") ... ... ; Rest of Script ... ... Func MyExit() Exit EndFunc Back To Top

13. How can I use a custom icon when compiling my scripts?You need to run the full compiler program (rather than just right-clicking a script and selecting compile). This page describes the compiler in detail. Back To Top

14. How can I make sure only one copy of my script is run?Use the _Singleton() function. See the User Defined Functions documentation for more information on _Singleton() and how to use it.Back To Top

15. What are the current technical limits of AutoIt v3?Here are details of the current technical limits of AutoIt. Please note that some of the limits are theoretical and you may run into performance or memory related problems before you reach the actual limit. Maximum length of a single script line: 4,095 Maximum string length: 2,147,483,647 characters Number range (floating point): 1.7E308 to 1.7E+308 with 15-digit precision Number range (integers): 64-bit signed integer Hexadec imal numbers: 32-bit signed integer (0x80000000 to 0x7FFFFFFF) Arrays: A maximum of 64 dimensions and/or a total of 16 million elements Maximum depth of recursive function calls: 5100 levels Maximum number of variables in use at one time: No limit Maximum number of user defined func tions: No limit Maximum number of GUI windows: No limit Maximum number of GUI c ontrols: 65532 Back To Top

16. I get a missing picture symbol in the Help file under the Examples.

This should be the Open button that enable you to open the Examples in the Help file. This issue is that the hhctrl.ocx isn't properly registered or corrupted. Try registering it by doing "regsvr32 hhctrl.ocx" from the command prompt or check if the file is still valid. Back To Top

Using AutoIt

Running Sc ripts AutoIt on Windows Vista Command Line Parameters Script Editors Compiling Sc ripts AutoIt Window Info Tool (AU3Info) Window Titles and Text (Basic) Window Titles and Text (Advanced) Controls Unicode Support Intended Use Notes for AutoIt v2 Users Running under Windows 64-bit Edition

Running ScriptsWhen 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

Command Line ParametersThe 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" If the script was compiled it would have been run like this: myscript.exe param1 "this is another param" $CmdLineRaw equals... param1 "this is another param" Note that $CmdLineRaw just return the parameters.

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

AutoIt specific command Line SwitchesForm1: AutoIt3.exe [/ErrorStdOut] [/AutoIt3ExecuteScript] file [params ...] Execute an AutoIt3 Script File /ErrorStdOut Allows to redirect fatal error to StdOut which can be captured by an application as Scite editor. This switch can be used with a compiled script. To execute a standard AutoIt Script File 'myscript.au3', use the command: 'AutoIt3.exe myscript.au3' Form2: Compiled.exe [/ErrorStdOut] [params ...] Execute an compiled AutoIt3 Script File produced with Aut2Exe. Form3: Compiled.exe [/ErrorStdOut] [/AutoIt3ExecuteScript file] [params ...] Execute another script file from a compiled AutoIt3 Script File. Then you don't need to fileinstall another copy of AutoIT3.exe in your compiled file. Form4: AutoIt3.exe [/ErrorStdOut] /AutoIt3ExecuteLine "command line" Execute one line of code. To execute a single line of code, use the command: Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"') The tray icon will not be displayed when using /AutoIt3ExecuteLine NOTE: Correct usage of single- and double- quotation marks is important, even double single.

AutoIt on Windows VistaWindows Vista brings new security features to restrict the running of files that require administrative rights. Even administrator users will be prompted every time an executable runs which will perform some administrative operation (such as writing to the registry key HKEY_LOCAL_MACHINE or writing to the C:\Windows directory). This is called User Account Control (UAC). By default AutoIt scripts run with standard user permissions but AutoIt has been coded to allow the script writer the option to "tag" a script in order to tell AutoIt if it needs to run with full admin rights or not. To force a script to attempt to run itself with administrative rights add the #requireadmin directive at the top of your script as follows: ; This script requires full Administrative rights #requireadmin MsgBox(0, "Info", "This script has admin rights! ") When the script runs AutoIt will check if it already has full admin rights and if not it will cause the operating system to prompt the user for permission as shown in "UAC Prompts". If permission is not given by the user the script will terminate.

UAC PromptsThe prompts that Vista will show when launching a program with administrative rights are shown below. The type of prompt displayed will depend on if the user is a "standard user" or an "adminstrator user" (remember even administrators need to get elevated permissions to perform admin operations). Note: The prompts shown are for the digitally signed version of AutoIt - all release versions are signed but beta versions may not be and will give a warning as shown in "Compiled Scripts" below. Standard User Prompt

A standard user must select a user name and enter a password in order to continue and run the script with elevated rights. Administrator User Prompt

As the user is already an administrator and just requires elevation the user needs only to click on continue - no password is needed.

Compiled ScriptsCompiled scripts (and possibly beta versions of AutoIt) are not digitally signed and will give a more serious looking warning as shown:

The user must click on Allow to continue (or enter a password if they are a standard user). If you have your own Authenticode signature you may sign your compiled scripts yourself. Important: Whether AutoIt or a compiled script is signed or not, you should only run scripts from sources you trust! Even signed code can be malicious!

Script EditorsAutoIt scripts are simple text files that you can edit with any text editor. However there are many free or shareware editors that are much better for writing scripts and many feature syntax highlighting so that AutoIt keywords and functions stand out making scripting much easier and less prone to mistakes. The current editor used by the majority of AutoIt users is SciTe, the AutoIt development team has created a custom version of SciTe with full syntax highlighting that also integrates various third-party AutoIt tools (like syntax checking and script tidying). A "lite" version of the SciTE editor comes with the AutoIt installation package. The full AutoIt version of SciTe that comes with all to tools can be downloaded seperately at http://www.autoitscript.com/autoit3/scite/ Some other recommended editors are:

TextPad Crimson Editor (free) Source Edit (free) UltraEdit

AutoIt comes supplied with some pre-written syntax files for many editors and they can be found in the Extra installation directory (there is a link under Start Menu / AutoIt v3 / Extra).

Compiling Scripts with Aut2ExeIt is possible to take your .au3 script and compile it into a standalone executable; this executable can be used without the need for AutoIt to be installed and without the need to have AutoIt3.exe on the machine. In addition, the compiled script is compressed and encrypted and there is the option to bind additional files (also compressed/encrypted) to the exe using the FileInstall function. Also, any #inc lude files will also be compiled into the script so they are not required at run-time. Caution: the script to be compiled must be free of syntax error as the compilation will not check the syntax. Aut2Exe can be used in three ways:

Method 1 - Start MenuOnly available if full install performed. 1. Open the Start Menu and browse to the AutoIt v3 group. 2. Click Script Compiler \ Convert .au3 to .exe 3. The main Aut2Exe interface should appear.

4. Use the Browse buttons to select your input (.au3) and output (.exe) files. 5. If you like you can change the icon of the resulting .exe - just browse to the icon you want (some example icons are supplied in Program Files\AutoIt3\Aut2Exe\Icons). 6. The only other option you might wish to change is the compression level (especially if using FileInstall to add extra files). Use the Compression menu to set this. As with all compression routines the better the compression you select the slower it will be. However, no matter what compression level you select the decompression speed (when the .exe is run) is the same. 7. Click on Convert to compile the script. Note: scripts can be compile with .a3x extension. They should be run with AutoIt.exe filename.a3x. The .a3x contains the script itself with all referred #include plus the FileInstall files. This format allow to distribute smaller files as they don't include the AutoIt3.exe in each compile script. You still need to have it accessible on the target machine but just AutoIt3.exe.

Method 2 - Right ClickOnly available if full install performed. 1. In Explorer browse to the .au3 file that you wish to compile. 2. Right-click the file to access the pop-up menu.

3. The file will be silently compiled with the same filename - just with a .exe extension. When compiling in this way, Aut2Exe uses current icon/compression settings (from the last time Aut2Exe was run manually as in method 1).

Method 3 - The Command LineThe Aut2Exe.exe program can be run from the command line as follows: Aut2exe.exe /in [/out ] [/icon ] [/comp 0-4] [/nopack] [x64] [/bin ] Where Switch /in /out /icon /comp /nopack /pack /x64 /x86 /console /gui /bin Usage Specifies the path and file name of the script to be compiled. Specifies the path and name of the compiled file. Specifies the path and file name when creating an *.a3x file. Specifies the path and file name of the icon to use for the compiled file. Specifies the compression level to be used when encoding the script (This is NOT related to UPX). It must be a number between 0 (none) and 4 (maximum). Specifies that the file should not be compressed with UPX after compilation. Specifies that the file should be compressed with UPX after compilation. Specifies that the script should be compiled for use on systems with x64 (64-bit) architecture. Specifies that the script should be compiled for use on systems with x86 (32-bit) architecture. Specifies that the script should be compiled as a Console application. Specifies that the script should be compiled as a Windows application. Specifies the path and file name of the bin file to be use to compile the file. Default value None. The file must be specified The input filename with a .exe extension The AutoIt icon 2 pack pack see notes see notes Windows application (/gui) Windows application (/gui) searched in Aut2exe folder

Command Line Examples/in c:\myscript.au3 /out c:\myapp.exe /icon c:\myicon.ico /x64 Will result in the creation of c:\myapp.exe with normal compression which will use the specified icon and be compiled for use on x64 system architecture. /in c:\myscript.au3 will result in the creation of a unicode c:\myscript.exe with normal compression which will use the default AutoIt icon for use on win_32 systems.

Command Line NotesLong filenames should be enclosed in double-quotes like "C:\Program Files\Test\test.au3". With the exception of /in all switches are optional. By default, the 32-bit compiler produces a 32-bit binary and the 64-bit compiler produces a 64-bit binary. Use the /x86 and /x64 parameters to explicitly specify the output. The /pass and /nodecompile switches are redundant as of version 3.2.8.1. They will be ignored if used and have been removed from this list. The /ansi and /unicode switches are redundant as of version 3.3.0.0.

T echnical DetailsThe compiled script and additional files added with FileInstall are compressed with my own (Jon) compression scheme.

AutoIt Window Information ToolAutoIt v3 comes with a standalone tool called the AutoIt Window Info Tool (Program File s\AutoIt3 \AU3Info.e x e ).AU3Info allows you to get information from a specified window that can be used to effectively automate it. Information that can be obtained includes:

Window titles Text on the window (visible and hidden) Window size and position Contents of the status bar Position of the mouse pointer Colour of the pixels underneath the mouse pointer Details of the Control underneath the mouse pointer

To use AU3Info just run it (from the command line or Start menu). AU3Info will remain the top most window at all times so that you can read it. Once active move to the window you are interested in and activate it - the contents of AU3Info will change to show the information that is available. With the help of AU3Info you should be automating in no time! When AU3Info is running you may want to copy text directly from it using CTRL-C and then paste it into your script to avoid spelling/case errors. For the tabs that have information in a list view (like the control information shown below) just double-click on an entry to copy it to the clipboard. This can be difficult when you want to capture pixel/mouse information as it keeps changing! To help with this you can "freeze" the output of AU3Info by pressing CTRL-ALT-F. Press the keys again to "unfreeze". Here is an example of AU3Info in use with the Windows "WordPad" editor:

Window Titles and Text (Basic)When automating, most windows can be uniquely identified by their title or a combination of their title & text. And by using AutoIt Window Info Tool (or even by sight) this information is easy to obtain. The titles of most windows are fairly obvious, for example Untitled - Notepad is the title of the notepad.exe editor and in many cases this is enough to automate. Note: If a blank string "" is given for both title and text then the currently Active window will be used (this is not true in some of the more advanced WinTitleMatchModes)! Window titles and text are case sensitive. You must match the case and punctuation exactly. To avoid problems select the title/text in the Window Info Tool and use ctrl-c to copy it and then paste it directly into your script. You can force match in lower case using advanced modes. Most of AutoIt's window functions have space for a title and text entry, here is the WinWaitActive function. This function pauses execution of the script until the specified window appears and is active. WinWaitActive ( "title", ["text"], [timeout] ) title is the only required parameter for this function, both the text and timeout are optional. In some functions the text parameter is not optional, if you do not wish to specify any text then just use "" (a blank string). A blank string, or nothing at all, in the text tells AutoIt that any text is valid. To use the above function with any notepad window both these methods will work: WinWaitActive("Untitled - Notepad") and WinWaitActive("Untitled - Notepad", "") If the same notepad window had "This is a line of text" typed into the window, the Window Info Tool would show:

Note that the Window Info Tool has seen the title and text of the notepad window. Whatever the Window Info Tool can see is what AutoIt can see. Now we have enough information to identify this exact window even if there are lots of other notepad windows open. In this case we use: WinWaitActive("Untitled - Notepad", "This is some text!")

Window TextThe window text consists of all the text that AutoIt can "see". This will usually be things like the contents of edit controls (as above with "This is a line of text") but will also include other text like:

Button text like &Yes, &No, &Next (the & indicates an underlined letter) Dialog text like "Are you sure you wish to continue?" Control text Misc text - sometimes you don't know what it is :)

The important thing is that you can use the text along with the title to uniquely identify a window to work with. When you specify the text parameter in a window function it is treated as a substring. So for the example above if you used the text "is some " you would get a match. What has been described is the default mode that AutoIt operates in, there are a number of more advanced modes to use when things are not as simple as this. Note: Hidden window can be matched by "title" only if "text" is empty ("").

Window Titles and Text (Advanced)AutoIt operates in one of three "Window matching" modes. The modes are set with the AutoItSetOption function using the WinTitleMatchMode option. Mode 1 (default) Matches partial titles from the start. In this mode the a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Un", etc. e.g. WinWait("Untitled") Mode 2 Matches any substring in the title. In this mode a window titled Untitled - Notepad would be matched by "Untitled - Notepad", "Untitled", "Notepad", "pad", etc. e.g. WinWait("Notepad") Mode 3 Exact title match. In this mode a window titled Untitled - Notepad would only be matched by "Untitled - Notepad" Mode 4 (Kept for backward compatibility) Advanced mode Must be replaced with Advanced Window Descriptions which does not need any mode to be set. Mode -1 to -3 Force lower case match according to other type of match.

Advanced Window DescriptionsA special description can be used as the window title parameter. This description can be used to identify a window by the following properties:

TITLE - Window title CLASS - The internal window classname REGEXPTITLE - Window title using a regular expression (if the regular expression is wrong @error will be set to 2) REGEXPCLASS - Window classname using a regular expression (if the regular expression is wrong @error will be set to 2) LAST - Last window used in a previous AutoIt command ACTIVE - Currently active window X \ Y \ W \ H - The position and size of a window INSTANCE - The 1-based instance when all given properties match

One or more properties are used in the title parameter of a window command in the format: [PROPERTY1:Value1; PROPERTY2:Value2] Note : if a Value must contain a ";" it must be doubled.

e.g. Wait a window of classname "Notepad" WinWaitActive("[CLASS:Notepad]", "") e.g. Close the currently active window WinClose("[ACTIVE]", "") e.g. Wait for the 2nd instance of a window with title "My Window" and classname "My Class" WinWaitActive("[TITLE:My Window; CLASS:My Class; INSTANCE:2]", "") e.g. List windows matching a classname defined by a regular expression WinList("[REGEXPCLASS:#\d+]")

Window Handles / HWNDsThe variant datatype in AutoIt natively supports window handles (HWNDs). A window handle is a special value that windows assigns to a window each time it is created. When you have a handle you may use it in place of the title parameter in any of the function calls that use the title/text convention. The advantage of using window handles is that if you have multiple copies of an application open - which have the same title/text - you can uniquely identify them when using handles. When you use a window handle for the title parameter then the text parameter is completely ignored. Various functions such as WinGetHandle, WinList and GUICreate return these handles. It is important to note that a window handle is not classed as a number or string - it is its own special type. Note: Window handles will work no matter what WinTitleMatchMode is currently in use. Example $handle = WinGetHandle("Untitled - Notepad", "") WinClose($handle)

ControlsOne of the best new features with AutoIt v3 is the ability to work directly with certain types of Window Controls. Almost everything you see on a window is a control of some kind: buttons, listboxes, edit fields, static text are all controls. In fact Notepad is just one big "Edit" control! Because AutoIt works directly with a control they provide a more reliable way to automate than just sending keystrokes. Note: AutoIt only works with standard Microsoft controls - some applications write their own custom controls which may look like a standard MS control but may resist automation. Experiment! Using the AutoIt Window Info Tool you can move your mouse around the window you are interested in and you will be given information of the control that is currently under your mouse. A special description can be used as the controlID parameter used in most of the Control...() functions . This description can be used to identify a control by the following properties:

ID - The internal control ID. The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screenreaders for the blind and Microsoft tools/APIs may allow you to get this Control ID TEXT - The text on a control, for example "&Next" on a button CLASS - The internal control classname such as "Edit" or "Button" CLASSNN - The ClassnameNN value as used in previous versions of AutoIt, such as "Edit1" NAME - The internal .NET Framework WinForms name (if available) REGEXPCLASS - Control classname using a regular expression X \ Y \ W \ H - The position and size of a control. INSTANCE - The 1-based instance when all given properties match.

One or more properties are used in the controlID parameter of a control command in the format: [PROPERTY1:Value1; PROPERTY2:Value2] Note: If this special format is not used then the parameter is taken to be a control ID (if numeric) or the ClassnameNN/text of the control (if a string). Although the special format is more longwinded than these methods it is much less ambiguous. If a Value must contain a ";" it must be doubled. e.g. Send text to the 1st Edit control in the Notepad window ControlSend("Untitled - Notepad", "", "[CLASS:Edit; INSTANCE:1]", "This is some text") or ControlSend("Untitled - Notepad", "", "[CLASSNN:Edit1]", "This is some text") or ControlSend("Untitled - Notepad", "", "Edit1", "This is some text") e.g. Click on control ID 254 in "My Window" ControlClick("My Window", "", "[ID:254]") or ControlClick("My Window", "", 254) e.g. Set the text of the .NET Winforms "textBoxFolder" control to "C:\Some\Folder" ControlSetText("My Window", "", "[NAME:textBoxFolder]", "C:\Some\Folder")

e.g. Click the 2nd instance of a "Button" control containing the text "Finish" ControlClick("My Window", "", "[CLASS:Button; TEXT:Finish; INSTANCE:2]")

Control Handle (HWND)Using the ControlGetHandle function you can determine the Handle or HWND of a control. A handle is the unique identifier that Windows gives controls. The handle changes each time the control is created. This method of accessing controls is generally only designed for users who are familiar with working with handles. Look under the contents for Function Reference \ Window Management \ Controls for a list of the functions that work with controls.

Unicode SupportFrom version 3.2.4.0 AutoIt is supplied as a Unicode program. The Unicode versions will allow our international friends to finally use AutoIt with extended characters and scripts! Note: the Unicode version of AutoIt (AutoIt3.exe) and scripts compiled in Unicode mode will only run on Windows NT/2000/XP/2003/Vista and later machines. To allow scripts to run on Windows 9x scripts you must use an older version of AutoIt. The last version compatible with Windows 9x was 3.2.12.x. AutoIt will read script files in ANSI or UTF16 (big or little endian) / UTF8 formats with a valid BOM. In addition, functions such as FileReadLine will automatically read text from ANSI and UTF16/UTF8 text files providing a valid BOM is found. UTF8 files with or without a BOM are also supported. Output functions such as FileWriteLine can use ANSI, UTF16 and UTF8 formats - but the file must be opened in the desired mode using the desired FileOpen flags otherwise the default ANSI mode is used. The supported file formats for text files and scripts and their notation in popular editors are shown in this table: AutoIt Notation ANSI UTF16 Little Endian UTF16 Big Endian UTF8 with BOM UTF8 without BOM The recommended script format is UTF-8. ANSI formats are not recommended for languages other than English as they can cause problems when run on machines with different locales. Notepad ANSI Unicode Unicode big endian UTF-8 Not supported Notepad++ ANSI UCS-2 Little Endian UCS-2 Big Endian UTF-8 UTF-8 without BOM SciTe (AutoIt Default Editor) 8 bit / Code Page Property UCS-2 Little Endian UCS-2 Big Endian UTF-8 with BOM UTF-8

Current LimitationsThere are a few parts of AutoIt that don't yet have full Unicode support. These are:

Send and ControlSend - Instead, Use ControlSetText or the Clipboard functions. Console operations are converted to ANSI.

These limits will be addressed in future versions if possible.

Intended UseAutoIt is a 'growing' scripting language. It started as an add-on tool to automate basic tasks in GUI's of other programs. These tasks (like sending a keystroke or clicking a button) are still the core components of an AutoIt script. However with the recent GUI additions, you can now incorporate your own graphical interface using native AutoIt script commands. The new COM (Object) functionality fills the gap with WSH languages, such as VBScript/JScript. With this combination of GUI Automation, GUI Interfaces and COM support, AutoIt offers you a powerful scripting tool that is able to compete with fully-fledged scripting languages like WSH or KiXStart).

Notes for users familiar with AutoIt 2.64Apart from the concept of windows and keystrokes, AutoIt v3 is quite different to v2.64 and previous versions of AutoIt. v2.64 will continue to be available for download and there are few reasons why users should try and convert existing scripts (if it ain't broke, etc.). However v3 has lots of great new features to make GUI automation easier than ever before, as well as being a much better general purpose scripting language. When start to use v3 the following should help to make things a little easier. There is also a v2.64 to v3 script converter available in the "Extra" directory which is located in the installation directory. - Backslashes are no longer a special character. However, quotation marks are a new issue.... For example, Run('C:\Windows\Notepad.exe "C:\Some File.txt" ') - Command-Line Syntax: There is only script mode, i.e., AutoIt.exe - Conventions: , [,] has been replaced with Cmd(parm1 [,parm2]) - Goto does not exist due to the support of loops and user-defined functions. - AutoItv3 supports variables like most programming languages: $myVar = "Example of assignment" - Scripts have the extension .au3 instead of .aut If you wish to re-write version 2.64 scripts as version 3, the following table may help you: Version 2.64 function AdlibOn Bloc kInput Break DetectHiddenText Exit EnvAdd EnvDiv EnvMult EnvSub FileAppend FileCopy FileCreateDir FileDelete FileInstall FileReadLine FileRemoveDir FileSelectFile Gosub Return Goto HideAutoItDebug HideAutoItWin IfInString Version 3 equivalent AdlibRegister Bloc kInput Break AutoItSetOption("WinDetectHiddenText",...) Exit [see + operator] [see / operator] [see * operator] [see - operator] [FileOpen(...,2) followed by FileWriteLine] FileCopy DirCreate FileDelete or FileRecycle FileInstall FileReadLine DirRemove FileOpenDialog or FileSaveDialog [see Func...EndFunc] [see Func...EndFunc] [not needed] -AutoItSetOption("TrayIconHide",...) If StringInStr(...) Then

IfNotInString IfWinExist IfWinNotExist IfWinActive IfWinNotActive IfEqual IfNotEqual IfGreater IfGreaterOrEqual IfLess IfLessOrEqual IfExist IfNotExist IfMsgBox IniRead IniWrite IniDelete InputBox LeftClick RightClic k LeftClic kDrag RightClic kDrag MouseGetPos MouseMove MsgBox Random RegRead RegWrite RegDelete Repeat EndRepeat Run RunWait Send SetCapslockState SetEnv SetBatchLines SetKeyDelay SetStoreCapslockMode SetTitleMatchMode SetWinDelay Shutdown Sleep SplashTextOn SplashTextOff

If Not StringInStr(...) Then If WinExists(...) Then If Not WinExists(...) Then If WinActive(...) Then If Not WinActive(...) Then [see = and == operators] [see operator] [see > operator] [see >= operator] [see < operator] [see Example1 Func swap(ByRef $a, ByRef $b) ;swap the contents of two variables Local $t $t = $a $a = $b $b = $t EndFunc Func today() ;Return the current date in mm/dd/yyyy form return (@MON & "/" & @MDAY & "/" & @YEAR) EndFunc Func max($x, $y) ;Return the larger of two numbers If $x > $y Then return $x Else return $y EndIf EndFunc ;End of sample script 1 ; example2 Func Example2() ; Sample scriptusing @NumParams macro Test_Numparams(1,2,3,4,5,6,7,8,9,10,11,12,13,14) EndFunc ;==>Example2 Func Test_Numparams($v1 = 0, $v2 = 0, $v3 = 0, $v4 = 0, $v5 = 0, $v6 = 0, $v7 = 0, $v8 = 0, $v9 = 0, _ $v10 = 0, $v11 = 0, $v12 = 0, $v13 = 0, $v14 = 0, $v15 = 0, $v16 = 0, $v17 = 0, $v18 = 0, $v19 = 0) Local $val For $i = 1 To @NumParams $val &= Eval("v" & $i) & " " Next MsgBox(0, "@NumParams example", "@NumParams =" & @NumParams & @CRLF & @CRLF & $val) EndFunc ;End of sample script 2

Keyword Reference

Dim / Global / Local / ConstDeclare a variable, a constant, or create an array. Dim [Const] $variable [ = initializer ] Dim [Const] $array[subscript 1]...[subscript n] [ = initializer ] Parameters const $variable initializer subscript Remarks The Dim/Loc al/Global keywords perform similar func tions: 1. Declare a variable before you use it (similar to VBScript) 2. Create an array Note: In AutoIt you can create a variable simply by assigning a value ($myvar = 0) but many people like to explicitly declare them. If AutoItSetOption("MustDeclareVars", 1) is active, then variables must be declared prior to use. You can also declare multiple variables on a single line: Dim $a, $b, $c And initialize the variables: Dim $a = 2, $b = 10, $c = 20 [optional] If present, the Const keyword creates a constant rather than a variable. The name of the variable/constant to declare. The value that will be initially assigned to the variable. A Const must include the initializer. The initializer can be a function call. The number of elements to create for the array dimension, indexed 0 to n-1.

Creating constants can be done in a similar way: Const $a = 2, $b = 10, $c = 20 Dim Const $d = 21, $e = Exp(1) Local Const $f = 5, $g = 7, $h = -2 Once created, you cannot change the value of a constant. Also, you cannot change an existing variable into a constant.

To initialize an array, specify the values for each element inside square brackets, separated by commas. For multiple dimensions, nest the initializers. You can specify fewer elements in the initializer than declared, but not more. Function calls can also be placed in the initializers of an array. If the function call returns an array, then the one array element will contain that returned array. Dim $Array1[12]=[3, 7.5, "string"], $array[5] = [8, 4, 5, 9, 1] Dim $Grid[2][4]=[["Paul", "Jim", "Richard", "Louis"], [485.44, 160.68, 275.16, 320.00]] Dim $Test[5] = [3, 1, StringSplit("Abe|Jack|Bobby|Marty", "|"), Cos(0)]

The difference between Dim, Local and Global is the scope in which they are created: Dim = Local scope if the variable name doesn't already exist globally (in which case it reuses the global variable!) Global = Forces creation of the variable in the Global scope Local = Forces creation of the variable in the Local/Function scope

You should use Local or Global, instead of Dim, to explicitly state which scope is desired for a variable/constant/array. When using variables, the local scope is checked first and then the global scope second. When creating arrays you are limited to up to 64 dimensions and/or a total of 16 million elements. A unique feature in AutoIt is the ability to copy arrays like this: $myc opy = $myarray In this case $mycopy will be an exact copy of $myarray and will have the same dimensions - no Dim statement is required to size the array first. If AutoItSetOption("MustDeclareVars", 1) is active then the variable $mycopy would still need to be declared first, but would not need to be sized. If the variable $mycopy was already an array or single value it will be erased before the copy takes place. To erase an array (maybe because it is a large global array and you want to free the memory), simply assign a single value to it: $array = 0 This will free the array and convert it back to the single value of 0. Declaring the same variable name again will erase all array values and reset the dimensions to the new definition. Declaring a variable with a simple value in the same scope will not change the value in the variable. If you declare a variable with the same name as a parameter, using Local inside a user function, an error will occur. Global can be used to assign to global variables inside a function, but if a local variable (or parameter) has the same name as a global variable, the local variable will be the only one used. It is recommended that local and global variables have distinct names. Related UBound, ReDim, Static, AutoItSetOption Example

; Example 1 - Declaring variables Dim $x, $y = 23, $z Global $_PI = 3.14159, $RADIUS Local $_daysWorking = 5 ; Example 2 - Declaring arrays Dim $weeklyWorkSchedule[$_daysWorking] Global $chessBoard[8][8] Local $mouseCoordinates[2], $windowStats[4] ; Example 3 - Declaring constant variables Const $x1 = 11, $y1 = 23, $z1 = 55 Global Const $PI = 3.14159, $E = 2.71828 Local Const $daysWorking = 5

Keyword Reference

ContinueCaseAbort the current case and continue a case into the next case in a Select or Switch block. ContinueCase Parameters None. Remarks Normally in a Select or Switch block, a case ends when the next Case statement is encountered. Executing the ContinueCase will tell AutoIt to stop executing the current case and start executing the next case. Trying to execute ContinueCase outside of a Select or Switch will cause a fatal error. Related Select...EndSelect, Switch...EndSwitch Example $msg = "" $szName = InputBox(Default, "Please enter a word.", "", " M", Default, Default, Default, Default, 10) Switch @error Case 2 $msg = "Timeout " ContinueCase Case 1; Continuing previous case $msg &= "Cancellation" Case 0 Switch $szName Case "a", "e", "i", "o", "u" $msg = "Vowel" Case "QP" $msg = "Mathematics" Case "Q" to "QZ" $msg = "Science" Case Else $msg = "Others" EndSwitch Case Else $msg = "Something went horribly wrong." EndSwitch MsgBox(0, Default, $msg)

Keyword Reference

ContinueLoopContinue a While/Do/For loop. ContinueLoop [level] Parameters level Remarks ContinueLoop will continue execution of the loop at the expression testing statement (that is the While, Until or Next statement). A negative level or zero value has no effect. Even though any program that uses ContinueLoop can be rewritten using If-ElseIf-EndIf statements, ContinueLoop can make long scripts easier to understand. Be careful with While/Do loops; you can create infinite loops by using ContinueLoop incorrectly. Related ExitLoop, For, While, Do Example [optional] The level of the loop to restart. The default is 1 (meaning the current loop).

;Print all numbers from 1 to 10 except number 7 For $i = 1 to 10 If $i = 7 Then ContinueLoop MsgBox(0, "The value of $i is:", $i) Next ;Example of using level is needed.

Keyword Reference

DefaultKeyword value use in function call. $var = Default Parameters None. Remarks This keyword should not be used in a general computation expression. AutoIt will not detect such situations because it has too much of a performance penalty. When used in parameter passing, the behavior is specified in the corresponding AutoIt function documentation. For UDF's, it is the scripter's responsiblity to check if the parameter has been set to Default and to perform the desired behavior in this situation. If used, the passed parameter will be set to the Default keyword and not to an optional parameter value, if defined. Related IsKeyWord Example

WinMove("[active]","",default, default, 200,300) ; just resize the active window (no move) MyFunc2(Default,Default) Func MyFunc2($Param1 = Default, $Param2 = 'Two', $Param3 = Default) If $Param1 = Default Then $Param1 = 'One' If $Param3 = Default Then $Param3 = 'Three' MsgBox(0, 'Params', '1 = ' & $Param1 & @LF & _ '2 = ' & $Param2 & @LF & _ '3 = ' & $Param3) EndFunc

Keyword Reference

Do...UntilLoop based on an expression. Do statements ... Until Parameters expression Remarks Do...Until statements may be nested. The expression is tested after the loop is executed, so the loop will be executed one or more times. Related ContinueLoop, ExitLoop Example $i = 0 Do MsgBox(0, "Value of $i is:", $i) $i = $i + 1 Until $i = 10 The statements in between Do and Until are executed until the expression is true.

Keyword Reference

EnumEnumerates constants. [scope] Enum [Step ] Parameters scope stepval constantlist Remarks By default, the first constant will be 0 and the rest will be incremented by 1 from there. When using the multiply operator to step, the first constant will be assigned 1 and the rest will be multiplied based on the previous constant value. Constants can be explicitly assigned by any valid statement. Related Example Global Enum $E1VAR1, $E1VAR2, MsgBox(4096, "", "Expect 0: " MsgBox(4096, "", "Expect 1: " MsgBox(4096, "", "Expect 2: " $E1VAR3 & $E1VAR1) & $E1VAR2) & $E1VAR3) [optional] The scope the Enum should be placed in, either Local, Global, Dim or none. If none, Dim behavior is used. [optional] The default step is to add 1. Other possible step methods are: *n, +n, -n where n is a whole number. A list constants to be enumerated.

Global Enum $E2VAR1 = 10, $E2VAR2, $E2VAR3 = 15 MsgBox(4096, "", "Expect 10: " & $E2VAR1) MsgBox(4096, "", "Expect 11: " & $E2VAR2) MsgBox(4096, "", "Expect 15: " & $E2VAR3) Global Enum Step MsgBox(4096, "", MsgBox(4096, "", MsgBox(4096, "", *2 $E3VAR1, $E3VAR2, $E3VAR3 "Expect 1: " & $E3VAR1) "Expect 2: " & $E3VAR2) "Expect 4: " & $E3VAR3)

Keyword Reference

ExitTerminates the script. Exit [return code] Parameters [optional] Integer that sets the script's return code. This code can be used by Windows or the DOS variable %ERRORLEVEL%. The default is 0. Scripts normally set an errorlevel of 0 if the script executed properly; error levels 1 and above typically indicate that the script did not execute properly.

return code

Remarks The parameter, if included, can be enclosed in parentheses. Thus, the following are equivalent: Exit, Exit 0, and Exit(0). However, Exit() is invalid. The code can be retrieved in an OnAutoItExitRegister function by @EXITCODE. Related ExitLoop, OnAutoItExitRegister Example

;First Example Exit ;Second Example ; Terminate script if no command-line arguments If $CmdLine[0] = 0 Then Exit(1) ;Third Example ; Open file specified as first command-line argument $file = FileOpen($CmdLine[1], 0) ; Check if file opened for reading OK If $file = -1 Then Exit(2) ; If file is empty then exit (script is successful) $line = FileReadLine($file) If @error = -1 Then Exit ;code to process file goes here FileClose($file) Exit ;is optional if last line of script

Keyword Reference

ExitLoopTerminate a While/Do/For loop. ExitLoop [level] Parameters level Remarks A negative level or zero value has no effect. ExitLoop will break out of a While, Do or For loop. ExitLoop is useful when you would otherwise need to perform error checking in both the loop-test and the loopbody. Related ContinueLoop, Exit, For, Do, While Example $sum = 0 While 1 ;use infinite loop since ExitLoop will get called $ans = InputBox("Running total=" & $sum, _ " Enter a positive number. (A negative number exits)") If $ans < 0 Then ExitLoop $sum = $sum + $ans WEnd MsgBox(0,"The sum was", $sum) [optional] The number of loop levels to exit from. The default is 1 (meaning the current loop).

Keyword Reference

False / TrueBoolean values for use in logical expressions. $var = False $var = True Parameters None. Remarks These keywords should not be used in expressions as AutoIt will not detect this 'misuse' and the results will be unpredictable. Related Example $bool= False if NOT $bool = true Then Msgbox(0,"Bool comparison", "OK")

Keyword Reference

For...To...Step...NextLoop based on an expression. For = To [Step ] statements ... Next Parameters variable start stop stepval Remarks The Variable will be created automatically with a LOCAL scope, even when MustDeclareVars is on. For...Next statements may be nested. The For loop terminates when the value of variable exceeds the stop threshold. If stepVal or stop is a variable, its value is only read the first time the loop executes. A For loop will execute zero times if: start > stop and step > 0, or start < stop and step is negative Related ContinueLoop, ExitLoop Example For $i = 5 to 1 Step -1 MsgBox(0, "Count down!", $i) Next MsgBox(0,"", "Blast Off!") The variable used for the count. The initial numeric value of the variable. The final numeric value of the variable. [optional] The numeric value (possibly fractional) that the count is increased by each loop. Default is 1.

Keyword Reference

For...In...NextEnumerates elements in an Object collection or an array For In statements ... Next Parameters Variable expression Remarks The Variable will be created automatically with a LOCAL scope, even when MustDeclareVars is on. If the expression is an Object collection with no elements, or an multi-dimensional array, the loop will be skipped and the Variable will contain an empty string. If the expression is not an Object nor an Array, the script stops with an error, unless a COM Error handler had been configured. Autoit Array's are read-only when using For...In. While you can assign the variable inside the For...In loop a value, this change is not reflected in the array itself. To modify the contents of an array during enumeration, use a For...To loop. For...In...Next statements may be nested. Related With...EndWith Example A variable to which an element is being assigned Must be an expression resulting in an Object, or an Array with at least one element

;Using an Array Dim $aArray[4] $aArray[0]="a" $aArray[1]=0 $aArray[2]=1.3434 $aArray[3]="test" $string = "" FOR $element IN $aArray $string = $string & $element & @CRLF NEXT Msgbox(0,"For..IN Arraytest","Result is: " & @CRLF & $string) ;Using an Object Collection $oShell = ObjCreate("shell.application") $oShellWindows=$oShell.windows if Isobj($oShellWindows) then $string="" for $Window in $oShellWindows $String = $String & $Window.LocationName & @CRLF

next msgbox(0,"","You have the following windows open:" & @CRLF & $String) else msgbox(0,"","you have no open shell windows.") endif

Keyword Reference

If...ThenConditionally run a single statement. If Then statement Parameters expression Remarks This version of the If statement is used to execute a single statement without the overhead of an EndIf. The expression can contain the boolean operators of AND, OR, and NOT as well as the logical operators =, =, ==, and grouped with parentheses as needed. Related If...Else...EndIf, Select...Case...EndSelect, Switch...EndSwitch Example If the expression is true, the statement is executed.

;Terminates script if no command-line arguments If $CmdLine[0] = 0 Then Exit ;Alternative: If $CmdLine[0] = 0 Then Exit EndIf

Keyword Reference

If...ElseIf...Else...EndIfConditionally run statements. If Then statements ... [ElseIf expression-n Then [elseif statements ... ]] ... [Else [else statements] ... EndIf Parameters expression Remarks If statements may be nested. The expression can contain the boolean operators of AND, OR, and NOT as well as the logical operators =, =, ==, and grouped with parentheses as needed. Related If...Then, Select...Case...EndSelect, Switch...EndSwitch Example If $var > 0 Then MsgBox(4096,"", "Value is positive.") ElseIf $var < 0 Then MsgBox(4096,"", "Value is negative.") Else If StringIsXDigit ($var) Then MsgBox(4096,"", "Value might be hexadecimal!") Else MsgBox(4096,"", "Value is either a string or is zero.") EndIf EndIf If the expression is true, the first statement block is executed. If not, the first true ElseIf block is executed. Otherwise, the "Else" block is executed.

Keyword Reference

ReDimResize an existing array ReDim $array[subscript 1]...[subscript n] Parameters $array subscript Remarks The ReDim keyword is similar to Dim, except that ReDim preserves the values in the array instead of removing the values while resizing an array. The number of dimensions must remain the same, or the old array will be forgotten during the ReDim. The array will retain the scope (Global or Local) that it had prior to resizing. Related Dim, UBound Example The name of the array to resize. The number of elements to create for the array dimension, indexed 0 to n-1.

; Example Resizing an array Dim $I, $K, $T, $MSG Dim $X[4][6], $Y[4][6] For $I = 0 To 3 For $K = 0 To 5 $T = Int(Random(20) + 1) ;Get random numbers between 1 and 20 $X[$I][$K] = $T $Y[$I][$K] = $T Next Next ReDim $X[3][8] Dim $Y[3][8] $MSG = "" For $I = 0 To UBound($X, 1) - 1 For $K = 0 To UBound($X, 2) - 1 If $K > 0 Then $MSG = $MSG & ", " $MSG = $MSG & $X[$I][$K] Next $MSG = $MSG & @CR Next MsgBox(0, "ReDim Demo", $MSG) $MSG = "" For $I = 0 To UBound($Y, 1) - 1 For $K = 0 To UBound($Y, 2) - 1 If $K > 0 Then $MSG = $MSG & ", " $MSG = $MSG & $Y[$I][$K] Next $MSG = $MSG & @CR Next MsgBox(0, "ReDim Demo", $MSG)

Keyword Reference

Select...Case...EndSelectConditionally run statements. Select Case statement1 ... [Case statement2 ...] [Case Else statementN ...] EndSelect Parameters Case Remarks Select statements may be nested. The expression can contain the boolean operators of AND, OR, and NOT as well as the logical operators =, =, ==, and grouped with parentheses as needed. Related If...Then, If...Else...EndIf, Switch...EndSwitch, ContinueCase Example $var = 0 $var2= "" Select Case $var = 1 MsgBox(0, "", "First Case expression was true") Case $var2 = "test" MsgBox(0, "", "Second Case expression was true") Case Else MsgBox(0, "", "No preceding case was true!") EndSelect If the expression is true the following statements up to the next Case or EndSelect statement are executed. If more than one of the Case statements are true, only the first one is executed.

Warning: This feature is experimental. It may not work, may contain bugs or may be changed or removed without notice. DO NOT REPORT BUGS OR REQUEST NEW FEATURES FOR THIS FEATURE. USE AT YOUR OWN RISK.Keyword Reference

StaticDeclare a static variable or create a static array. Static [Scope] $variable [ = initializer ] Static [Scope] $array[subscript 1]...[subscript n] [ = initializer ] Parameters Scope $variable initializer subscript Remarks The Static keyword can appear on the line before the optional scope specifier, or after. e.g. Local Static or Static Local are both acceptable. If the scope modifier Local is used, then the static variable is visible and usable only in the function in which it is declared. If the scope modifier Global is used, then the static variable is visible and usable in all parts of the script; in this regard, a Global Static has very little difference from a Global variable. If the scope modifier is not used, then the static variable will be created in the local scope; in this way, Static is similar to Dim. The difference between Local and Static is variable lifetime. Local variables are only stored while the function is called and are visible only within the function in which they are declared; when the function returns, all its local variables are released. Static variables are likewise visible only in the function in which they are declared, but they continue to exist, retaining their last value, after the function finishes execution. When looking for variables, the local scope is checked first and then the global scope second. The Static keyword performs similar functions to the Global/Local/Dim keywords. 1. They all declare a variable before you use it. 2. They all can create an array. An optional modifier, Local or Global that indicates where the variable is visible. The name of the static variable to declare. The value that will be initially assigned to the variable. The initializer can be a function call of involve mathematical or string operations. This initializer is only evaluated the first time this variable declaration is encountered. The number of elements to create for the array dimension, indexed 0 to n-1.

Note: Static variables must be declared using the Static keyword prior to use, no matter how AutoItSetOption ("MustDeclareVars") is set. Static variables can not be Const. You can also declare multiple static variables on a single line:

Static $a, $b, $c And initialize the variables: Static $a = 2, $b = 10, $c = 20

When initializing a static variable, the initialization value is evaluated and assigned only the first time, when the variable is created. On all subsequent passes, the initializer is ignored. See Local for more information about using arrays, which has all the same functionality as in Local, except for: 1. Reinitalizing a Static variable has no effect. 2. Changing the size of a Static array is treated like a ReDim. 3. You can not change a static variable to a local or global variable nor vice-versa.

If you want to resize an array, always use Static to do so, not Redim. Related Local, UBound, ReDim, AutoItSetOption Example

; Static variables examples. Opt("MustDeclareVars", 1) Func Test1() Static $STbFirstPass = 1 If $STbFirstPass Then $STbFirstPass = 0 ; Perform tasks for the first time through EndIf ; Other things the function should do EndFunc ;==>Test1 Func Accumulate($State) Static $Values[9] Local $I If IsNumber($State) Then Switch $State Case -1 ; Reset For $I = 0 To 8 $Values[$I] = 0 Next Return True Case -2 Return $Values Case 0 To UBound($Values) - 1 $Values[$State] += 1 Return $Values[$State] Case Else If $State < 0 Then SetError(1, 0) Return False Else Static $Values[$State + 1] ; Resize the array to accomodate the new value $Values[$State] = 1

Return 1 EndIf EndSwitch Else SetError(2, 0) EndIf EndFunc ;==>Accumulate Global $I Test1() For $I = 1 To 99 Accumulate(Random(0, 20, 1)) Next For $I In Accumulate(-2) ConsoleWrite($I & ", ") Next ConsoleWrite("\n"); Test1()

Keyword Reference

Switch...Case...EndSwitchConditionally run statements. Switch Case [To ] [, [To ] ...] statement1 ... [Case [To ] [, [To ] ...] statement2 ...] [Case Else statementN ...] EndSwitch Parameters To Remarks If no cases match the Switch value, then the Case Else section, if present, is executed. If no cases match and Case Else is not defined, then none of the code inside the Switch structure, other than the condition, will be executed. Switch statements may be nested. Related If...Then, If...Else...EndIf, Select...EndSelect, ContinueCase Example Switch @HOUR Case 6 To 11 $msg = "Good Morning" Case 12 To 17 $msg = "Good Afternoon" Case 18 To 21 $msg = "Good Evening" Case Else $msg = "What are you still doing up?" EndSwitch MsgBox(0, Default, $msg) An expression that returns a value. The value from the expression is then compared against the values of each case until a match is found. This expression is always evaluted exactly once each time through the structure. The case is executed if the expression is between the two values. The case is executed if the expression matches the value.

Keyword Reference

With...EndWithUsed to reduce long references to object type variables With statements ... EndWith Parameters expression Remarks With...EndWith statements may NOT be nested. Related For...In...Next Example Must be an object type expression

$oExcel = ObjCreate("Excel.Application") $oExcel.visible =1 $oExcel.workbooks.add With $oExcel.activesheet .cells(2,2).value = 1 .range("A1:B2").clear EndWith $oExcel.quit

Keyword Reference

While...WEndLoop based on an expression. While statements ... WEnd Parameters expression Remarks While...WEnd statements may be nested. The expression is tested before the loop is executed so the loop will be executed zero or more times. To create an infinite loop, you can use a non-zero number as the expression. Related ContinueLoop, ExitLoop Example $i = 0 While $i = 0 the sizes Returns -1 and sets @error to 1 if the path doesn't exist.

$size = DirGetSize(@HomeDrive) Msgbox(0,"","Size(MegaBytes):" & Round($size / 1024 / 1024)) $size = DirGetSize(@WindowsDir, 2) Msgbox(0,"","Size(MegaBytes):" & Round($size / 1024 / 1024)) $timer = TimerInit() $size = DirGetSize("\\10.0.0.1\h$",1) $diff = Round(TimerDiff($timer) / 1000) ; time in seconds If IsArray($size) Then Msgbox(0,"DirGetSize-Info","Size(Bytes):" & $size[0] & @LF _ & "Files:" & $size[1] & @LF & "Dirs:" & $size[2] & @LF _ & "TimeDiff(Sec):" & $diff) EndIf

Function Reference

DirMoveMoves a directory and all sub-directories and files. DirMove ( "source dir", "dest dir" [, flag] ) Parameters source dir dest dir flag Return Value Success: Failure: Remarks If the source and destination are on different volumes or UNC paths are used then a copy/delete operation will be performed rather than a move. If the destination already exists and the overwrite flag is specified then the source directory will be moved inside the destination. Because AutoIt lacks a "DirRename" function, use DirMove to rename a folder! Related DirRemove, FileMove Example Returns 1. Returns 0 if there is an error moving the directory. Path of the source directory (with no trailing backslash). e.g. "C:\Path1" Path of the destination dir (with no trailing backslash). e.g. "C:\Path_Copy" [optional] this flag determines whether to overwrite files if they already exist: 0 = (default) do not overwrite existing files 1 = overwrite existing files

DirMove(@MyDocumentsDir, "C:\Backups\MyDocs")

Function Reference

DirRemoveDeletes a directory/folder. DirRemove ( "path" [, recurse] ) Parameters path recurse Return Value Success: Failure: Remarks Some dir attributes can make the removal impossible. Related DirCreate, FileRecycle, DirCopy, DirMove, FileDelete Example Returns 1. Returns 0 if there is an error removing the directory (or if directory does not exist). Path of the directory to remove. [optional] Use this flag to specify if you want to delete sub-directories too. 0 = (default) do not remove files and sub-directories 1 = remove files and subdirectories (like the DOS DelTree command)

; Delete C:\Test1 and all subdirs and files DirRemove("C:\Test1", 1)

Function Reference

DriveGetDriveReturns an array containing the enumerated drives. DriveGetDrive ( "type" ) Parameters type Return Value Success: Failure: Remarks None. Related DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus Example Returns an array of strings (drive letter followed by colon) of drives found. The zeroth array element contains the number of drives. Returns "" and sets @error to 1. Type of drive to find: "ALL", "CDROM", "REMOVABLE", "FIXED", "NET WORK", "RAMDISK", or "UNKNOWN"

$var = DriveGetDrive( "all" ) If NOT @error Then MsgBox(4096,"", "Found " & $var[0] & " drives") For $i = 1 to $var[0] MsgBox(4096,"Drive " & $i, $var[$i]) Next EndIf

Function Reference

DriveGetFileSystemReturns File System Type of a drive. DriveGetFileSystem ( "path" ) Parameters path Return Value Success: Failure: Returns the File System Type of the drive as a string; see table below. Sets @error to 1. Path of drive to receive information from.

Return Value 1 (numeric) "FAT" "FAT32" "NTFS" "NWFS" "CDFS" "UDF" Remarks

Interpretation Drive does NOT contain media (CD, Floppy, Zip) or media is unformatted (RAW). Typical file system for drives under ~500 MB such as Floppy, RAM disks, USB "pen" drives, etc. Typical file system for Windows 9x/Me hard drives. Typical file system for Windows NT/2000/XP hard drives. Typical file system for Novell Netware file servers. Typically indicates a CD (or an ISO image mounted as a virtual CD drive). Typically indicates a DVD.

The list of possible return values might be incomplete. Related DriveGetDrive, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus Example

$var = DriveGetFileSystem( "c:\" ) MsgBox(4096,"File System Type:", $var)

Function Reference

DriveGetLabelReturns Volume Label of a drive, if it has one. DriveGetLabel ( "path" ) Parameters path Return Value Success: Failure: Remarks None. Related DriveGetDrive, DriveGetFileSystem, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus Example Returns the Volume Label of the drive as a string. Sets @error to 1. Path of drive to receive information from.

$var = DriveGetLabel( "c:\" ) MsgBox(4096,"Volume Label: ",$var)

Function Reference

DriveGetSerialReturns Serial Number of a drive. DriveGetSerial ( "path" ) Parameters path Return Value Success: Failure: Remarks The value returned is not the hardware serial number as found on the label of the drive, it is the Windows Volume ID for the drive. Related DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus Example Returns the Serial Number of the drive as a string. Sets @error to 1. Path of drive to receive information from.

$var = DriveGetSerial( "c:\" ) MsgBox(4096, "Serial Number: ", $var)

Function Reference

DriveGetTypeReturns drive type. DriveGetType ( "path" ) Parameters path Return Value Success: Failure: Remarks The list of possible return values might be incomplete. Related DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus, CDTray Example Returns the type of drive: "Unknown", "Removable", "Fixed", "Network", "CDROM", "RAMDisk" Returns "" and sets @error to 1. Path of drive to receive information from.

$var = DriveGetType( "c:\" ) MsgBox(4096, "Drive Type:", $var)

Function Reference

DriveMapAddMaps a network drive. DriveMapAdd ( "device", "remote share" [, flags [, "user" [, "password"]]] ) Parameters device remote share flags user password Return Value Success: Failure: Remarks When the function fails (returns 0) @error contains extended information: 1 = Undefined / Other error. @extended set with Windows API return 2 = Access to the remote share was denied 3 = The device is already assigned 4 = Invalid device name 5 = Invalid remote share 6 = Invalid password Note: When using "*" for the device parameter the drive letter selected will be returned instead of 1 or 0, e.g. "U:". If there was an error using "*" then a blank string "" will be returned. If defined the user/password will be presented to the remote computer that will validate the credential. Related DriveMapDel, DriveMapGet Example Returns 1. (See Remarks) Returns 0 if a new mapping could not be created and sets @error (see below). (See Remarks) The device to map, for example "O:" or "LPT1:". If you pass a blank string for this parameter a connection is made but not mapped to a specific drive. If you specify "*" an unused drive letter will be automatically selected. The remote share to connect to in the form "\\server\share". [optional] A combination of the following: 0 = default 1 = Persistent mapping 8 = Show authentication dialog if required [optional] The username to use to connect. In the form "username" or "domain\username". [optional] The password to use to connect.

; Map X drive to \\myserver\stuff using current user DriveMapAdd("X:", "\\myserver\stuff") ; Map X drive to \\myserver2\stuff2 using the user "jon" from "domainx" with password "tickle" DriveMapAdd("X:", "\\myserver2\stuff2", 0, "domainx\jon", "tickle")

Function Reference

DriveMapDelDisconnects a network drive. DriveMapDel ( "drive" ) Parameters drive Return Value Success: Failure: Remarks If a connection has no drive letter mapped you may use the connection name to disconnect, e.g. \\server\share Related DriveMapAdd, DriveMapGet Example Returns 1. Returns 0 if the disconnection was unsuccessful. The device to disconnect, e.g. "O:" or "LPT1:".

; Map X drive to \\myserver\stuff using current user DriveMapAdd("X:", "\\myserver\stuff") ; Disconnect DriveMapDel("X:")

Function Reference

DriveMapGetRetrieves the details of a mapped drive. DriveMapGet ( "device" ) Parameters device Return Value Success: Failure: Remarks None. Related DriveMapAdd, DriveMapDel Example Returns details of the mapping, e.g. \\server\share Returns a blank string "" and sets @error to 1. The device (drive or printer) letter to query, e.g. "O:" or "LPT1:"

; Map X drive to \\myserver\stuff using current user DriveMapAdd("X:", "\\myserver\stuff") ; Get details of the mapping MsgBox(0, "Drive X: is mapped to", DriveMapGet("X:"))

Function Reference

DriveSetLabelSets the Volume Label of a drive. DriveSetLabel ( "path", "label" ) Parameters path label Return Value Success: Failure: Remarks Most hard drives have a maximum label length of 11 characters, and DriveSetLabel will fail if max length is exceeded. Also, FAT32 partition labels tend to revert to all capital letters. Related DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSpaceFree, DriveSpaceTotal, DriveStatus Example Returns 1. Returns 0. Path of drive to change. New volume label for the drive. (11 characters is usually max length)

DriveSetLabel("C:\", "New_Label")

Function Reference

DriveSpaceFreeReturns the free disk space of a path in Megabytes. DriveSpaceFree ( "path" ) Parameters path Return Value Success: Failure: Remarks DriveSpaceFree may even work when a complete directory path (that exists) is given. However, a file path won't work. Use the Round function if the return value is too precise. Related DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceTotal, DriveStatus Example Returns free disk space in Megabytes as a float number. Returns 0 and sets @error to 1. Path of drive to receive information from.

$var = DriveSpaceFree( "c:\" ) MsgBox(4096, "Free space on C:", $var & " MB")

Function Reference

DriveSpaceTotalReturns the total disk space of a path in Megabytes. DriveSpaceTotal ( "path" ) Parameters path Return Value Success: Failure: Remarks DriveSpaceTotal may even work when a complete directory path (that exists) is given. However, a file path won't work. Related DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveStatus, FileGetSize Example Returns diskspace in Megabytes as a float number. Sets @error to 1. Path of drive to receive information from.

$var = DriveSpaceTotal( "c:\" ) MsgBox(4096, "Total Space on C:", $var & " MB")

Function Reference

DriveStatusReturns the status of the drive as a string. DriveStatus ( "path" ) Parameters path Return Value Value UNKNOWN READY NOTREADY INVALID Remarks The list of possible return values may be incomplete. DriveStatus may even work when a complete directory path (which exists) is given. However, a file path won't work. Related DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, CDTray, FileExists Example Interpretation Drive may be unformatted (RAW). Typical of hard drives and drives that contain removable media. Typical of floppy and CD drives that do not contain media. May indicate the drive letter does not exist or that a mapped network drive is inaccessible. Path of drive to receive information from.

$var = DriveSt