AutoIt

v3.1.1

©1999-2005 Jonathan Bennett & AutoIt Team

AutoIt v3 Homepage

Introduction

AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI. 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 was initially designed for PC "roll out" situations to configure thousands of PCs, but with the arrival of v3 it is also well suited to performing home automation and the scripting of repetitive tasks.

AutoIt can:

  • Execute Windows and DOS executables
  • Simulate key strokes (supports most keyboards layouts)
  • Simulate mouse movements and clicks
  • Move, resize and manipulate windows
  • Interact directly with "controls" on a window (set/get text, move, disable, etc.)
  • Work with the clipboard to cut/paste text items
  • Work with the registry

Unlike AutoIt v2, the new v3 language has a much more standard syntax -similar to VBScript and BASIC - and now supports complex expressions, user functions, looping and everything else that veteran scripters would expect.

As with previous versions, AutoIt has been designed to be as small as possible (~115KB) and stand-alone with no external .dll files or registry entries required. Scripts can also be compiled into stand-alone executables with Aut2Exe.

There have also been updates to the ActiveX and DLL versions of AutoIt called AutoItX - unlike v2 this will be a combined control (COM and standard DLL functions in the same DLL). AutoItX will allow you to add the unique features of AutoIt to your own favourite scripting or programming languages! See the AutoItX helpfile (Start \ AutoIt v3 \ Extras \ AutoItX \ AutoItX Help File) for more information and examples.

Best of all, AutoIt continues to be FREE - but if you want to support the time, money and effort spent on the project and webhosting then you may donate at the AutoIt homepage.

What's New?

v3 has a completely different syntax to v2.64 so old scripts are not compatible. However, v2.64 will continue to be supported and downloadable. Both AutoIt v3 and v2.64 can be installed on the same machine together without any problems and you can keep your old scripts intact. v2 uses the .aut extension and v3 uses .au3. There is rarely a need to rewrite a working v2.64 script for v3.

v3 has the same concepts as previous versions with windows titles and text and keyboard and mouse simulation but has many new features:

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!

Language Upgrades

"Proper" numbers, unlimited-length strings, complex expressions, if statements, select, while loops, for loops, do loops, functions, arrays, excellent string handling (over 25 functions!) - the list goes on. Everything you need to make your automation routines as painless as possible. Yes, this is a GUI automation language but the syntax in v3 is powerful enough for general purpose scripting. Old versions of AutoIt were often referred to as "not a proper language". Not any more.

Key and Mouse Simulation

Much time has been spent optimizing the keystroke and mouse simulation functions to be as accurate as possible on all current operating systems. The mouse functions also look more "human" in this version and can even be used to create slick demo scripts. All the mouse and keyboard routines are highly configurable both in terms of simulation "speed" and functionality.

Window Management

In addition to the "title/text" v2 way of accessing windows you can also access windows by their class names and handles. As usual you can expect to move, hide, show, resize, activate, close and pretty much do what you want with windows.

And much, much more.


License

Software License

AutoIt v3

Author : Jonathan Bennett and the AutoIt Team
WWW : http://www.autoitscript.com/autoit3/
Email : support at hiddensoft dot com
________________________________________________________

END-USER LICENSE AGREEMENT FOR THIS SOFTWARE
Important - read carefully:

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 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; provided that each copy shall be a true and complete copy, including 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 sell for profit and freely distribute scripts and/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

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 noninfringement. The entire risk arising out of use or performance of the SOFTWARE PRODUCT remains with you.

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.


Install Directory Structure

The AutoIt installer creates a directory structure (usually located in \Program Files\AutoIt3) summarized in the following table. The installer also creates Start Menu shortuts, but no other files are added or modified.

Files and Directories |  | Description
(Top-level files)
AutoIt3.exe |  | The AutoIt main program and only file required to run scripts!
AU3Info.exe |  | The The AutoIt Window Info Tool.
AutoIt.chm |  | This help file.
psapi.dll |  | Process...() function helper DLL - used under Windows NT 4 only (Microsoft redistributable file)
Uninstall.exe |  | The AutoIt uninstaller. You should never need to use this.
AutoIt v3 Website.url |  | A shortcut to http://www.autoitscript.com/autoit3/
Aut2Exe
 | Icons\ | Contains icons used for the .au3 filetype icon in Explorer.
 | Aut2Exe.exe | The script compiler.
 | AutoItSC.bin | Executable stub for compiled scripts
 | UPX.exe | The UPX compressor (shinks the size of exe files).
Examples
 | GUI\ | Contains examples of GUIs written in AutoIt.
 | Helpfile\ | Contains scripts used in many of the help file examples.
Extras
 | AutoUpdateIt\ | Contains a script for easily retrieving the latest version of AutoIt3.
 | Editors\ | Contains syntax coloring definitions for some popular text editors.
 | Exe2Aut\ | Contains utils for converting compiled scripts back in to source code.
 | v2_to_v3_Converter\ | Contains a tool for converting v2.64 script to AutoIt v3 syntax.
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.

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.

(exception: Under Windows NT 4 the file PSAPI.dll needs to be in the path or AutoIt directory for the Process...() related functions to work)

Registry Keys

The 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 executation of the corresponding utility:
HKEY_LOCAL_MACHINE\SOFTWARE\AutoIt v3\
AutoIt
 | (Default) | REG_SZ | (value not set)
 | InstallDir | REG_SZ | C:\Program Files\AutoIt3
 | Version | REG_SZ | v3.1.0
HKEY_CURRENT_USER\Software\AutoIt v3\
Aut2Exe
 | (Default) | REG_SZ | (value not set)
 | AllowDecompile | REG_DWORD | 0x1
 | LastCompression | REG_DWORD | 0x2
 | LastExeDir | REG_SZ | My Documents
 | LastIcon | REG_SZ |
 | LastIconDir | REG_SZ | C:\Program Files\AutoIt3\Aut2Exe\Icons
 | LastScriptDir | REG_SZ | My Documents
AutoUpdateIt
 | (Default) | REG_SZ | (value not set)
 | DoneOption | REG_SZ | Notify
 | DownloadDir | REG_SZ | C:\Downloads\ForExample\
Exe2Aut
 | (Default) | REG_SZ | (value not set)
 | LastExeDir | REG_SZ | C:\ForExample\
 | LastScriptDir | REG_SZ |
AU3Info
 | Default | REG_SZ | (value not set)
 | AlwaysOnTop | REG_DWORD | 0x1
 | ColorMode | REG_DWORD | 0x1
 | CoordMode | REG_DWORD | 0x1
 | HighlightColor | REG_DWORD | 0x0
 | HighlightControls | REG_DWORD | 0x1
 | Magnify | REG_DWORD | 0x0
 | WinH | REG_DWORD | 0x01c2
 | WinW | REG_DWORD | 0x012c
 | WinX | REG_DWORD | 0x0064
 | WinY | REG_DWORD | 0x0064


AutoIt

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.

Questions

1. 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?

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. But over time people started to use it for more more 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 N ext button and a F inish 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 helpfile 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

If there is a massive outcry about this after the launch of v3 then I may add it back in, but only to help people convert scripts.

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 command 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, an even simpler way is to run the command "start" which will automatically work out how to execute the file for you:

RunWait(@COMSPEC " /c Start 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?

The easiest way is to rename the title of the hidden AutoIt window when your script first starts. Then in the same script check for that window title existing - if it does then another copy of the script is running.

; Place at the top of your script
$g_szVersion = "My Script 1.1"
If WinExists($g_szVersion) Then Exit ; It's already running
AutoItWinSetTitle($g_szVersion)
; Rest of your script goes here

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.7E–308 to 1.7E+308 with 15-digit precision
Number range (integers): 64-bit signed integer
Hexadecimal 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: 384 levels

Simultaneous open files: 64
Simultaneous active HotKeys: 64

Maximum number of variables in use at one time: No limit
Maximum number of user defined functions: No limit

Maximum number of GUI windows: 1024
Maximum number of GUI controls per window: 4096

Back To Top


Running Scripts

When you start AutoIt you will be asked to open a script file. A script file is a simple text file containing AutoIt keywords and functions that tell AutoIt what you want it to do. Script files are created in a simple text editor such as notepad.exe or a much better alternative.

Although AutoIt v3 scripts are just plain-text files they are usually given the file extension .au3 to help tell the difference between a script and a text file. If you used the full installer to install AutoIt you can execute an AutoIt script simply by double-clicking it. There are also various options to open, edit, or compile a script if you right-click on the .au3 file.

Here is an example script. Notice that ; is used for comments (much like REM in DOS batch files):

; This is my first script
MsgBox(0, "My First Script!", "Hello World!")

More complicated scripts may use functions, which are usually placed at the end of a script. Here is a similar script using functions:

; This is my second script (with functions)
MsgBox(0, "My second script!", "Hello from the main script!")
TestFunc()

Func TestFunc()
MsgBox(0, "My Second Script!", "Hello from the functions!")
EndFunc

Command Line Parameters

The special array $CmdLine is initialized with the command line parameters passed in to your AutoIt script. Note the scriptname is not classed as a parameter; get this information with @ScriptName instead. A parameter that contains spaces must be surrounded by "double quotes". Compiled scripts accept command line parameters in the same way.

$CmdLine[0] is number of parameters
$CmdLine[1] is param 1 (after the script name)
$CmdLine[2] is param 2 etc
...
$CmdLine[$CmdLine[0]] is one way to get the last parameter...

So if your script is run like this:

AutoIt3.exe myscript.au3 param1 "this is another param"

$CmdLine[0] equals... 2

$CmdLine[1] equals... param1

$CmdLine[2] equals... this is another param

@ScriptName equals... myscript.au3

In addition to $CmdLine there is a variable called $CmdLineRaw that contains the entire command line unsplit, so for the above example:

$CmdLineRaw equals... myscript.au3 param1 "this is another param"


Scripts Editors

Script Editors

AutoIt scripts are simple text files that you can edit with notepad.exe. 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). The AutoIt version of SciTe can be found at http://www.autoitscript.com/autoit3/scite/

Some other recommended editors are:

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

There are frequent arguments on the forums over which is the best. :)

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 Aut2Exe

It 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 #include files will also be compiled into the script so they are not required at run-time.

Aut2Exe can be used in three ways:

Method 1 - Start Menu

Only 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. If you don't want anyone to be able to decompile your script (when a decompiler is made available) then you should enter a passphrase.

7. 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.

8. Click on Convert to compile the script.

Method 2 - Right Click

Only 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 Line

The Aut2Exe.exe program can be run from the command line as follows:

Aut2exe.exe /in <infile.au3> [/out <outfile.exe>] [/icon <iconfile.ico>] [/nodecompile] [/comp 0-4] [/pass <passphrase>]

Long filenames should be enclosed in double-quotes like "C:\Program Files\Test\test.au3". If no "out" file is given the input filename is used with a .exe extension.

Technical Details

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

Because a compiled script must "run" itself without a password it needs to be able to decrypt itself - i.e., the encryption is two-way. For this reason you should regard the compiled exe as being encoded rather than completely safe. For example, if I wrote a script that contained a username and password (say, for a desktop rollout) then I would be happy using something like a workstation-level user/password but I would not consider it safe for a domain/entire network password unless I was sure that the end-user would not have easy access to the .exe file.


AutoIt Window Info Tool

AutoIt Window Information Tool

AutoIt v3 comes with a standalone tool called the AutoIt Window Info Tool (Program Files\AutoIt3\AU3Info.exe). 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. 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.

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 Text

The 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.


Window Titles and Text (Advanced)

AutoIt operates in one of four "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.

eg.

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.

eg.

WinWait("Notepad")

Mode 3

Exact title match.

In this mode a window titled Untitled - Notepad would only be matched by "Untitled - Notepad"

Mode 4

Advanced mode.

In this mode special sequences are used in the title parameter so that window classnames and handles can be used. The text parameter remains the same.

The special sequences must contain no whitespace. They are:

"classname=CLASSNAME"

"active"

"last" or ""

"classname=" matches a window based on its classname. For example to identify a window that has the classname "MYCLASS1" then you would use "classname=MYCLASS1" for the title parameter.

"active" matches the currently active window (same as "" in the default WinTitleMatchMode).

"last" uses the last successful window match so you don't have to keep specifying the title and text again and again. e.g.

AutoItSetOption("WinTitleMatchMode", 4)

WinWaitActive("Untitled - Notepad")

WinClose("last") ; Closes the previously matched notepad window

 Note: If "classname=", "active", "last" or "" are not used as the title then the window matching takes place as in Mode 1 making this a good mode for general use.

Window Handles / HWNDs

The 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 it's own special type.

Note: Window handles will work no matter what WinTitleMatchMode is currently in use.

Example

$handle = WinGetHandle("Untitled - Notepad", "")
WinClose($handle)


Controls

One 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. Information on controls is given in a number of ways, these are:

  • Control ID
  • ClassNameNN
  • Text
  • Control Handle (HWND) (Not available in AutoIt Window Info Tool - see below)

Whenever you see a Control...() command expecting a ControlID parameter (most of them) you can use any one of these methods. The method you choose will vary by personal preference and the information you are able to retrieve from the AutoIt Window Info Tool. In general, the best method to use is the Control ID, with the other methods being used when a Control ID is not available or is not unique (usually with static text each piece of text actually has the same Control ID so you will need to use one of the other methods to work with those controls).

Control ID

The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of indentifying 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.

ClassNameNN

Each Microsoft standard control has a "classname" such as "button" or "edit". In AutoIt this is combined with the "instance" of that control to give the "ClassNameNN" method. If you have a simple dialog with a few buttons on it they will generally be referred to as "Button1", "Button2", "Button3", etc.

This method is useful when the Control ID is not applicable (for static text or custom controls).

Text

You will notice that AU3Info gives you the text it can see on a control, for example on a Next button you might see the text &Next - the & indicates that the next letter is underlined and is common when working with menus and controls. You can use this text to identify a control in place of the "ClassNameNN" if you like - however if many controls have the same text you will run into problems.

Control Handle (HWND)

Using the ControlGetHandle function you can determine the Handle or HWND of a control. A handle is the unique indentifier 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 familar with working with handles.

Look under the contents for Function Reference \ Window Management \ Controls for a list of the functions that work with controls.


Intended Use

This program is intended for performing GUI automation tasks in Windows. It is not intended as the "be-all and end-all" of scripting. When performing complex tasks such a COM manipulation I would recommend using AutoIt in conjunction with a fully-fledged scripting language (such as WSH or Kixtart - both free) and using AutoIt to "fill in the gaps".

I personally use AutoIt for large PC rollouts. I use WSH for complex scripting/COM and then use it to call AutoIt (or AutoItX/AutoItDLL) when I need to perform configurations that can only be usually achieved by manual input (software installation, configuring control panel, changing drive letters, sending keys and clicking the mouse, etc.).

However, there are many who use AutoIt as a general scripting language (and with v3 this is much more realistic) and are very happy with it :)

- Jon


Help for AutoIt v2 users

Notes for users familiar with AutoIt 2.64

Apart 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 <filename of script file>

- Conventions:
<cmd>, <parameter1> [,<parameter2>] 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 | Version 3 equivalent
AdlibOn | AdlibEnable
BlockInput | BlockInput
Break | Break
DetectHiddenText | AutoItSetOption("WinDetectHiddenText",...)
Exit | Exit
EnvAdd | [see + operator]
EnvDiv | [see / operator]
EnvMult | [see * operator]
EnvSub | [see - operator]
FileAppend | [FileOpen(...,2) followed by FileWriteLine]
FileCopy | FileCopy
FileCreateDir | DirCreate
FileDelete | FileDelete or FileRecycle
FileInstall | FileInstall
FileReadLine | FileReadLine
FileRemoveDir | DirRemove
FileSelectFile | FileOpenDialog or FileSaveDialog
Gosub | [see Func...EndFunc]
Return | [see Func...EndFunc]
Goto | [not needed]
HideAutoItDebug | --
HideAutoItWin | AutoItSetOption("TrayIconHide",...)
IfInString | If StringInStr(...) Then
IfNotInString | If Not StringInStr(...) Then
IfWinExist | If WinExists(...) Then
IfWinNotExist | If Not WinExists(...) Then
IfWinActive | If WinActive(...) Then
IfWinNotActive | If Not WinActive(...) Then
IfEqual | [see = and == operators]
IfNotEqual | [see <> operator]
IfGreater | [see > operator]
IfGreaterOrEqual | [see >= operator]
IfLess | [see < operator]
IfLessOrEqual | [see <= operator]
IfExist | FileExists
IfNotExist | If Not FileExists(...) Then
IfMsgBox | [see MsgBox(...) and Select...Case...EndSelect]
IniRead | IniRead
IniWrite | IniWrite
IniDelete | IniDelete
InputBox | InputBox
LeftClick | MouseClick("left",...)
RightClick | MouseClick("right",...)
LeftClickDrag | MouseClickDrag("left",...)
RightClickDrag | MouseClickDrag("right",...)
MouseGetPos | MouseGetPos
MouseMove | MouseMove
MsgBox | MsgBox
Random | Random
RegRead | RegRead
RegWrite | RegWrite
RegDelete | RegDelete
Repeat | [see For...Next]
EndRepeat | [see For...Next]
Run | Run
RunWait | RunWait
Send | Send
SetCapslockState | SendSetCapslockState
SetEnv | EnvSet
SetBatchLines | --
SetKeyDelay | AutoItSetOption("SendKeyDelay",...)
SetStoreCapslockMode | AutoItSetOption("SendCapslockMode",...)
SetTitleMatchMode | AutoItSetOption("WinTitleMatchMode",...)
SetWinDelay | AutoItSetOption("WinWaitDelay",...)
Shutdown | Shutdown
Sleep | Sleep
SplashTextOn | SplashTextOn and others
SplashTextOff | SplashOff
StringCaseSense | [see individual functions]
StringLeft | StringLeft
StringRight | StringRight
StringMid | StringMid
StringLen | StringLen
StringReplace | StringReplace
StringTrimLeft | StringTrimLeft
StringTrimRight | StringTrimRight
StringGetPos | StringInStr
WinGetActiveStats | [see WinGetPos, WinGetTitle, WinGetText]
WinGetActiveTitle | WinGetTitle("")
WinKill | WinKill
WinWait | WinWait
WinWaitClose | WinWaitClose
WinWaitActive | WinWaitActive
WinWaitNotActive | WinWaitNotActive
WinHide | WinSetState(..., @SW_HIDE)
WinShow | WinSetState(..., @SW_SHOW)
WinRestore | WinSetState(...,@SW_RESTORE)
WinMinimize | WinSetState(...,@SW_MINIMIZE)
WinMaximize | WinSetState(...,@SW_MAXIMIZE)
WinActivate | WinActivate
WinClose | WinClose
WinMove | WinMove
WinSetTitle | WinSetTitle
WinMinimizeAll | WinMinimizeAll
WinMinimizeAllUndo | WinMinimizeAllUndo
#Include | #Include
%CLIPBOARD% | [see ClipGet and ClipPut]
A_OSTYPE | @OSType
A_OSVERSION | @OSVersion
A_SCRIPTNAME | @ScriptName
A_SCRIPTDIR | @ScriptDir
A_SCRIPTFULLPATH | @ScriptFullPath
A_WORKINGDIR | @WorkingDir
A_NUMBATCHLINES | --
A_SEC | @SEC
A_MIN | @MIN
A_HOUR | @HOUR
A_MDAY | @MDAY
A_MON | @MON
A_YEAR | @YEAR
A_WDAY | @WDAY
A_YDAY | @YDAY


Tutorial - HelloWorld

This tutorial explains the basics of creating an AutoIt script and running it. The tutorial assumes that you have already fully installed AutoIt v3 using the supplied installer.

(Note: if you have installed the SciTe editor for AutoIt then that will be used instead of Notepad when you are editing the script).

First open a folder where you wish to create the script. Right-click in the folder and select New / AutoIt v3 Script.

Call the script helloworld.au3. Notice the .au3 extension - this indicates that the file is an AutoIt v3 script.

Now we have created the script file we want to edit it to make it do something useful. Right-click on helloworld.au3 and select Edit Script.

The Notepad editor will open and you will see something like this:

The code you see is simply some comments that you can use to organise your scripts. There are also some suggested "options" that may help in the future. All the lines start with a semi-colon ; and are treated as comments (ignored). ; is similar to the REM statement in a DOS batch file.

Now we want to tell AutoIt to display a message box - this is done with the MsgBox function.

At the bottom of the file type the following:

MsgBox(0, "Tutorial", "Hello World!")

All functions take parameters, MsgBox takes three - a flag, a title and a message. The flag is a number that changes the way MsgBox displays - we will use 0 for now. The title and message are both string parameters - when using strings in AutoIt surround the text in double or single quotes. "This is some text" or 'This is some text' - both will work fine.

Now save the script and close Notepad. You've just written your very first AutoIt script! To run the script simply double-click the helloworld.au3 file (you may also right-click the file and select Run Script) .

You should see this:

Now, let's look at the flag parameter for the MsgBox function again. From the manual page we can see various values listed which change the way MsgBox displays. The value of 0 simply shows a simple message box with an OK button. A value of 64 displays the message box with an information icon.

Edit the script again and change the 0 to 64 so you have:

MsgBox(64, "Tutorial", "Hello World!")

Run the script and you will see:

Experiment with the various flag values to see what kind of results you can get. Remember, if you want to use more than one flag value then simply add the required values together.


Tutorial - Notepad

This tutorial explains how to automate the opening of Notepad, automatically type some text and then close Notepad. It is assumed that you are already familiar with creating and running AutoIt scripts as shown in the HelloWorld tutorial.

First create an empty script called npad.au3 and then edit the file (using Notepad or SciTe as you prefer).

The first thing we need to know is the name of the Notepad executable. It is notepad.exe - you can get this information by looking at the properties of the Notepad shortcut icon in the Start Menu. To execute Notepad we use the AutoIt Run function. This function simply launches a given executable and then continues.

Type in the first line of script as:

Run("notepad.exe")

Run the script - if all goes well then a new instance of Notepad should open.

When automating applications AutoIt can check for window title so that it knows which window it should work with. With Notepad the window title is obviously Untitled - Notepad. AutoIt is case-sensitive when using window titles so you must get the title exactly right - the best way to do this is to use the AutoIt Window Information Tool. Run the Information Tool from Start Menu \ AutoIt v3 \ AutoIt Window Info.

With the Info Tool open click on the newly opened Notepad window to activate it; the Info Tool will give you information about it. The information we are interested in is the window title.

Highlight the title in the AutoIt Info Tool window and press CTRL-C to copy it to the clipboard - we can then paste the title into our script without fear of misspelling it.

After Running a copy of Notepad we need to wait for it to appear and become active before we send any keystrokes. We can wait for a window using the WinWaitActive function. Most window-related functions in AutoIt take a window title as a parameter.

Enter the following as the second line in the script (use CTRL-V or Edit\Paste to paste our window title from the clipboard).

WinWaitActive("Untitled - Notepad")

After we are sure the Notepad window is visible we want to type in some text. This is done with the Send function.

Add this line to our script.

Send("This is some text.")

The entire script will now look like this:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")

Close the copy of Notepad that we previously opened (you will need to do this every time you run the script otherwise you will end up with lots of copies running!). Run the script.

You should see Notepad open, and then some text will magically appear!

Next we want to close notepad, we can do this with the WinClose function.

WinClose("Untitled - Notepad")

When Notepad tries to close you will get a message asking you to save the changes. Use the Window Info Tool to get details of the dialog that has popped up so that we can respond to it :)

So, we add a line to wait for this dialog to become active (we will also use the window text to make the function more reliable and to distinguish this new window from the original Notepad window):

WinWaitActive("Notepad", "The text in the Untitled file has changed")

Next we want to automatically press ALT-N to select the No button (Underlined letters in windows usually indicate that you can use the ALT key and that letter as a keyboard shortcut). In the Send function to send an ALT key we use !

Send("!n")

Our complete script now looks like this:

Run("notepad.exe")
WinWaitActive("Untitled - Notepad")
Send("This is some text.")
WinClose("Untitled - Notepad")
WinWaitActive("Notepad", "The text in the Untitled file has changed")
Send("!n")

Run the script and you will see Notepad open, some text appear, then close! You should be able to use the techniques learned in this tutorial to automate many other applications.


Tutorial - WinZip

This tutorial explains how to automate the installation of WinZip 9 SR-1. It is assumed that you are already familiar with creating and running AutoIt scripts and the use of the AutoIt Window Information Tool to read window titles and text, as shown in the HelloWorld and Notepad tutorials.

The WinZip installation consists of approximately 10 dialog boxes that you must click buttons (usually Next) to continue. We are going to write a script that simply waits for these dialog boxes to appear and then clicks the appropriate buttons. As usual with these types of installations the window title of each dialog is the same (WinZip Setup) so we must use window text to tell the difference between windows. Screenshots of each dialog will be provided and you can click on the picture to see the Information Tool output for that dialog.

First create a directory that we will use for the WinZip installer and our script file. Copy the WinZip installer to this directory and create a blank script called winzipinstall.au3.

We will now run through the installation manually and write the script as we go. The script lines to automate each dialog will be shown after each picture (remember to click on the picture to see the AutoIt Window Information Tool output). You can also look at the completed script for reference.

The first script line is easy, we want to run the winzip90.exe installer. So the first line is:

Run("winzip90.exe")

The first dialog will pop-up:

We need to wait for this window to popup and become active, and then we need to send the keystroke ALT-s to click the Setup button. The resulting script lines are:

WinWaitActive("WinZip® 9.0 SR-1 Setup", "&Setup")
Send("!s")

(Remember to click on the picture to see the AutoIt Window Information Tool output, this is especially important as the title contains the special (R) character which would be difficult to type).

The installation location dialog will appear next:

We need to wait for this screen to be active and then click ENTER to accept the install location. The script lines are:

WinWaitActive("WinZip Setup", "into the following folder")
Send("{ENTER}")

The WinZip Features dialog will appear next:

Notice that this window has exactly the same title as the first of WinZip Setup - in fact all the dialogs in the setup have this title! In order to tell the difference between these windows we must also use the window text - on each screen try to pick the most unique text you can. In this case i've chosen WinZip features include. After the window has appeared we will want to press ALT-n:

WinWaitActive("WinZip Setup", "WinZip features include")
Send("!n")

The License dialog will appear next:

Wait for the window to appear and then press ALT-y to accept the agreement:

WinWaitActive("License Agreement")
Send("!y")

Setup continues in a similar fashion for a few dialogs. The picture of each dialog is shown along with the script lines needed to automate it.

WinWaitActive("WinZip Setup", "Quick Start Guide")
Send("!n")

WinWaitActive("WinZip Setup", "switch between the two interfaces")
Send("!c")
Send("!n")

WinWaitActive("WinZip Setup", "&Express setup (recommended)")
Send("!e")
Send("!n")

WinWaitActive("WinZip Setup", "WinZip needs to associate itself with your archives")
Send("!n")

This is the final dialog of the setup. Notice that the Finish button doesn't have a keyboard shortcut - luckily it is the default button on this dialog so we can just press ENTER to select it. If this were not the case then we would have to TAB between controls or better yet use the ControlClick function.

WinWaitActive("WinZip Setup", "Thank you for installing this evaluation version")
Send("{ENTER}")

After installation WinZip will automatically start:

We simply wait for the main WinZip window to appear and then close it with the WinClose function.

WinWaitActive("WinZip (Evaluation Version)")
WinClose("WinZip (Evaluation Version)")

Here is the completed script - note that I have commented each dialog separately which makes it easier to follow and to change in the future (the next version of WinZip may be slightly different).

And that's it! Run the winzipinstaller.au3 script and watch as WinZip is installed in just a few seconds! The techniques used in this tutorial can be used to automate the installation of most programs.

As an exercise for the reader, try and redo the script but instead of using the Send function (which sends keys to the active window) to click on buttons try and use ControlClick instead which can be much more reliable. You will need to read up on Controls to do this.


Language Reference

The basics of the AutoIt language:

  • Datatypes
  • Variables
  • Macros
  • Operators
  • Conditional Statements
  • Loop Statements
  • User Functions
  • Comments


Language Reference - Datatypes

In AutoIt there is only one datatype called a Variant. A variant can contain numeric or string data and decides how to use the data depending on the situation it is being used in. For example, if you try and multiply two variants they will be treated as numbers, if you try and concatenate (join) two variants they will be treated as strings.

Some examples:

10 * 20 equals the number 200 (* is used to multiply two numbers)

10 * "20" equals the number 200

"10" * "20" equals the number 200

10 & 20 equals the string "1020" (& is used to join strings)

If a string is used as a number and it doesn't contain a valid number, it will be assumed to equal 0. For example,

10 * "fgh" equals the number 0.

Numbers

Numbers can be standard decimal numbers like 2, 4.566, and -7.

Scientific notation is also supported; therefore, you could write 1.5e3 instead of 1500.

Integers (whole numbers) can also be represented in hexadecimal notation by preceding the integer with 0x as in 0x409 or 0x4fff (when using hex notation only 32-bit numbers are valid).

Strings

Strings are enclosed in double-quotes like "this". If you want a string actually contain a double-quote use it twice like:

"here is a ""double-quote"" - ok?"

You can also use single-quotes like 'this' and 'here is a ' 'single-quote' ' - ok?'

You can mix quote types to make for easier working and to avoid having to double-up your quotes to get what you want. For example if you want to use a lot of double-quotes in your strings then you should use single-quotes for declaring them:

'This "sentence" contains "lots" of "double-quotes" does it not?'

is much simpler than:

"This ""sentence"" contains ""lots"" of ""double-quotes"" does it not?"

Datatype Ranges

The following table shows the range of values that a variant datatype can hold.

Data Sub-type | Range and Notes
Numeric | A "double precision" number which is a 15 digit precision number in the range 1.7E–308 to 1.7E+308. (Stored internally as 8 bytes)
String | Can contain strings of up to 2 billion characters.

Some functions in AutoIt only work with 32 bit numbers (e.g. BitAND) and are converted automatically - these functions are documented where required.


Language Reference - Variables

A variable is just a place to store data in memory so that it can be accessed quickly. Think of it as a mailbox in memory that you can put information in or take information out of. For example you might create a variable to store the number a user's response to a question, or the result to a math equation.

Each variable has a name (again, similar to a mailbox) and must start with the $ character and may only contain letters, numbers and the underscore _ character. Here are some example names:

$var1

$my_variable

Each variable is stored as a variant.

Declaring Variables

Variables are declared and created with the Dim, Local and Global keywords:

Dim $var1

Or you can declare multiple variables at once:

Dim $var1, $myvariable

You can also assign a variable without declaring it first, but many prefer explicit declarations.

$var1 = "create and assign"

Scope

A variable's scope is controlled by when and how you declare the variable. If you declare a variable at the start of your script and outside any functions it exists in the Global scope and can be read or changed from anywhere in the script.

If you declare a variable inside a function it is in Local scope and can only be used within that same function. Variables created inside functions are automatically destroyed when the function ends.

By default when variables are declared using Dim or assigned in a function they have Local scope unless there is a global variable of the same name (in which case the global variable is reused). This can be altered by using the Local and Global keywords to declare variables and force the scope you want.


Language Reference - Macros

AutoIt has an number of Macros that are special read-only variables used by AutoIt. Macros start with the @ character instead of the usual $ so are easy to tell apart. As with normal variables you can use macros in expressions but you cannot assign a value to them.

The pre-defined macros are generally used to provide easy access to system information like the location of the Windows directory, or the name of the logged on user.

Go here for a complete list.


Language Reference - Operators

AutoIt has the following mathematical, logical and comparison operators.

Operator | Description
+ | Adds two numbers. e.g. 10 + 20 (equals 30)
- | Subtracts two numbers. e.g. 20 - 10 (equals 10)
* | Multiplies two numbers. e.g. 20 * 10 (equals 200)
/ | Divides two numbers. e.g. 20 / 10 (equals 2)
& | Concatenates/joins two strings. e.g. "one" & 10 (equals "one10")
^ | Raises a number to the power. e.g. 2 ^ 4 (equals 16)
NOT | Logical NOT operation. e.g. NOT 1 (equals 0)
= | Tests if two values are equal (case insensitive if used with strings). e.g. If $var= 5 Then (true if $var equals 5)
== | Tests if two values are equal (case sensitive if used with strings)
<> | Test if two values are not equal.
> | Tests if the first value is greater than the second.
>= | Tests if the first value is greater than or equal to the second.
< | Tests if the first value is less than the second.
<= | Tests if the first value is less than or equal to the second.
AND | Logical AND operation. e.g. If $var = 5 AND $var2 > 6 Then (true if $var equals 5 and $var2 is greater than 6)
OR | Logical OR operation. e.g. If $var = 5 OR $var2 > 6 Then (true if $var equals 5 or $var2 is greater than 6)

When more than one operator is used in an expression the order in which things happen is controlled by operator precedence. The precedence used in AutoIt is given below. Where two operators have the same precedence the expression is evaluated left to right.

From highest precedence to lowest:

NOT
^
* /
+ -
&
< > <= >= = <> ==
AND OR

e.g. 2 + 4 * 10 is evaluated as 42:

4 * 10 (equals 40)

2 + 40 (equals 42)

As the * has a higher precedence than + it occurs before the addition.

You can use brackets to force a part of the expression to be evaluated first.

e.g. (2 + 4) * 10 equals 60.


Language Reference - Conditional Statements

You will often want to change the flow of your script based on a condition or series of conditions. Is one number bigger than another? Or, does a string contain a certain value?

Conditions are evaluated as true (non-zero) or false (zero). Conditions generally use comparison operators like ==, <>, >=.

The following conditional statements are available in AutoIt:

  • If...Then...Else
  • Select...Case

Both statements are similar and decide which code to execute depending on the condition given. Here is an example of an If statement that pops up a message box if a variable is greater than 10.

$var = 20

If $var > 10 Then
MsgBox(0, "Example", "$var was greater than 10!")
Else
MsgBox(0, "Example", "$var was less than 10")
EndIf

In the example above the expression $var > 10 evaluated to true because the variable was indeed greater than 10. This caused the If statement to execute the first MsgBox line and display "$var was greater than 10!".

A Select statement is very similar, but is generally used for situations where you want to test a large number of conditions as it is generally easier to read than than large If/ElseIf type block. e.g.

$var = 30

Select
Case $var > 1 AND $var <= 10
MsgBox(0, "Example", "$var was greater than 1")

Case $var > 10 AND $var <= 20
MsgBox(0, "Example", "$var was greater than 10")

Case $var > 20 AND $var <= 30
MsgBox(0, "Example", "$var was greater than 20")

Case $var > 30 AND $var <= 40
MsgBox(0, "Example", "$var was greater than 30")

Case $var > 40
MsgBox(0, "Example", "$var was greater than 40")
EndSelect


Language Reference - Loops Statements

Language Reference - Loop Statements

A loop is how you refer to a section of script that you repeat a number of times. You might might want to loop a given number of times or you might wish to repeat a section of script as long as a certain condition is true or false.

The following loop statements are available in AutoIt:

  • For...Next
  • While...WEnd
  • Do...Until

While (no pun intended) all the statements perform similar functions, they are slightly different and one will usually be more appropriate than another for a given situation.


Language Reference - User Functions

A function is a section of code that can be called from the script to perform a certain "function". There are two sorts of functions in AutoIt, inbuilt functions and user functions.

Inbuilt Functions

The full list of inbuilt functions is here and the notes on using them are here.

User Functions

User functions are declared using the Func...EndFunc statements.

Functions can accept parameters and return values as required.

Function names must start with either a letter or an underscore, and the remainder of the name can contain any combination of letters and numbers and underscores. Some valid function names are:

MyFunc

Func1

_My_Func1

Here is an example of using a function to double a number 5 times:

$val = 10
For $i = 1 To 10
$doubled = MyDouble($val)
MsgBox(0, "", $val & " doubled is " & $doubled)
$val = $doubled
Next

Exit

Func MyDouble($value)
$value = $value * 2
Return $value
EndFunc


Language Reference - Comments

Although only one statement per line is allowed, a long statement can span multiple lines if an underscore, _, is placed at the end of a "broken" line.

MsgBox(4096,"", "This is a rather long line, so I _
broke it with the underscore, _, character.")

The semicolon (;) is the comment character. Unless the semicolon is within a string, all text following it is ignored by the script interpreter/complier.

; The next line contains a meaningful, end-of-line comment
Sleep(5000) ;pause 5 seconds

NOTE: You cannot put comments on lines ending with underscores!

It is also possible to comment of large blocks of script by using the #comments-start and #comments-end directives.


GUI Reference

AutoIt has the ability to create simple Graphical User Interfaces (GUIs) that consist of windows and controls.

GUI Concepts

A GUI consists of one or more windows and each window contains one or more controls. GUIs are "event driven" which means you react to events - like a button that is clicked. You spend most of your time idling and waiting for an event to happen - this is a little different to a normal script where you are in control of what happens and when! Think of it as waiting by the door for the postman - you sit there until a letter pops through the postbox and then you look at the letters and decide what to do with them - this is exactly how GUIs work - you wait for the postman to come to you.

Of course, you may choose to do other tasks while the GUI is active - for example you might use the GUI functions to create an elaborate progress box that you update while your script performs complex actions.

GUI Controls

All users will be familiar with controls - anything you click on or interact with in a window is a type of control. The types of controls that can be created with AutoIt are listed below - you will have used most of them in other Windows programs.

Label | A plain piece of text.
Button | A simple button.
Input | A single line control that you can enter text into.
Edit | A multi-line control that you can enter text into.
Checkbox | A box that can be "checked" or "unchecked".
Radio | A set of circular buttons - only one can be active at once.
Combo | A list with a dropdown box.
List | A list.
Date | A date picker.
Pic | A picture.
Icon | An icon.
Progress | A progress bar.
Tab | A group of controls that are contained in tabs.
UpDown | A control that can be added to input controls.
Avi | Display an AVI format clip.
Menu | A menu across the top of the window.
ContextMenu | A menu that appears when you right click inside the window.
TreeView | A control similar to the windows file-explorer.
Slider | A control similar to the windows sound volume control.
ListView | A control displaying columns information.
ListViewItem | A control displaying item in a listview control.
Dummy | A dummy user control.

Here is an example of a single window GUI that contains many of the controls available. As you can see it is possible to create very detailed GUIs!

Controls are created with the GUICtrlCreate... set of functions. When a control is created a Control ID is returned. The most important things to note about a control ID is that:

  • The control ID is a positive number (that is, a number greater than 0)
  • Each control ID is unique - even when there are multiple windows
  • The control ID is actually the same value as the Control ID that the AutoIt Window Info Tool shows.

    • GUI Basic Functions

    These are the main functions that you will need to create a GUI. They are just the basics though, there are many more when you are ready to create some really advanced GUIs.

    Function | Explanation
GUICreate | Create a window.
GUICtrlCreate... | Create various controls in a window.
GUISetState | Display or hide the window.
GUIGetMsg | Poll the GUI to see if an event has happened (MessageLoop mode only)
GUICtrlRead | Read the data in a control.
GUICtrlSetData | Set/change the data in a control.
GUICtrlSet... | Change various options for a control (color, style, etc.)

    Before writing any GUI scripts you must include the file GUIConstants.au3 at the beginning of your script - this contains all the variables and constants needed to write GUI programs.

    First let's create a window, call it "Hello World" and make it 200 by 100 pixels in size. When a new window is created it is hidden - so we must "show" it.

    #include <GUIConstants.au3>

    GUICreate("Hello World", 200, 100)
    GUISetState(@SW_SHOW)
    Sleep(2000)

    If your run the above script you will see a window open and close after 2 seconds. Not very interesting...let's add some text and an OK button. The text will be added at position 30, 10 and the button at 70, 50 and the button will be 60 pixels wide.

    #include <GUIConstants.au3>

    GUICreate("Hello World", 200, 100)
    GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
    GUICtrlCreateButton("OK", 70, 50, 60)
    GUISetState(@SW_SHOW)
    Sleep(2000)

    That's pretty good, but how do we make the GUI react to us clicking the button? Well, this is where we must make a decision as to how we will process events - via a MessageLoop or via OnEvent functions.

    GUI Event Modes

    As mentioned above there are two basic GUI modes: MessageLoop mode and OnEvent mode. The modes are simply two different ways of reacting to GUI events. The mode you choose will depend on personal preference, and to some extent the type of GUI you wish to create. Both modes are equally capable of creating any GUI you wish but sometimes one mode is more suited to a task than the other.

    The default mode is the MessageLoop mode. To switch to OnEvent mode use Opt("GUIOnEventMode", 1).

    Message-loop Mode (default)

    In the Message-loop mode your script will spend the majority of its time in a tight loop. This loop will simply poll the GUI using the GUIGetMsg function. When an event has occurred the return value of the GUIGetMsg function will show the details (a button is clicked, the GUI has been closed, etc.).

    In this mode you will only receive events while you are actively polling the GUIGetMsg function so you must ensure that you call it many times a second otherwise your GUI will be unresponsive.

    This mode is best for GUIs where the GUI is "king" and all you care about is waiting for user events.

    See this page for a more detailed explanation of the MessageLoop mode.

    OnEvent Mode

    In the OnEvent mode instead of constantly polling the GUI to find out if anything has happened you make the GUI temporarily pause your script and call a pre-defined function to handle the event. For example, if the user clicks Button1 the GUI halts your main script and calls a previously defined user function that deals with Button1. When the function call is completed the main script is resumed. This mode is similar to the Visual Basic forms method.

    This mode is best for GUIs where the GUI is of secondary importance and your script has other tasks to perform in addition to looking after the GUI.

    See this page for a more detailed explanation of the OnEvent mode.


GUI Reference - MessageLoop Mode

In the MessageLoop mode your script will spend the majority of its time in a tight loop. This loop will simply poll the GUI using the GUIGetMsg function. When an event has occurred the return value of the GUIGetMsg function will show the details (a button is clicked, the GUI has been closed, etc.).

The MessageLoop mode is the default message mode for AutoIt GUIs - the other possible mode is the OnEvent mode.

In the MessageLoop mode you will only receive events while you are actively polling the GUIGetMsg function so you must ensure that you call it many times a second otherwise your GUI will be unresponsive.

Basic MessageLoop Format

The general layout of MessageLoop code is:

While 1
$msg = GUIGetMsg()
...
...
WEnd

Usually a tight loop like the one shown would send the CPU to 100% - fortunately the GUIGetMsg function automatically idles the CPU when there are no events waiting. Do not put a manual sleep in the loop for fear of stressing the CPU - this will only cause the GUI to become unresponsive.

GUI Events

There are three types of event messages that GUIGetMsg will return:

  • No Event
  • Control Event
  • System Event

    • No Event

    When there are no events waiting to be processed GUIGetMsg returns 0. In a usual GUI this is the most common event.

    Control Event

    When a control is clicked or changes a control event is sent - this event is a positive number that corresponds to the controlID that was returned when the control was created with GUICtrlCreate....

    System Event

    System events - such as the GUI closing - are negative numbers. The different events are shown below and are defined in GUIConstants.au3:

    $GUI_EVENT_CLOSE
    $GUI_EVENT_MINIMIZE
    $GUI_EVENT_RESTORE
    $GUI_EVENT_MAXIMIZE
    $GUI_EVENT_PRIMARYDOWN
    $GUI_EVENT_PRIMARYUP
    $GUI_EVENT_SECONDARYDOWN
    $GUI_EVENT_SECONDARYUP
    $GUI_EVENT_MOUSEMOVE

    Example GUI

    In the main GUI Reference page we started a simple Hello World example that looked like this:

    #include <GUIConstants.au3>

    GUICreate("Hello World", 200, 100)
    GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
    GUICtrlCreateButton("OK", 70, 50, 60)
    GUISetState(@SW_SHOW)
    Sleep(2000)

    Now we will finish the code using a MessageLoop and some of the event messages described above. It is usual because of the number of possible messages to use a Select statement for readability.

    #include <GUIConstants.au3>

    GUICreate("Hello World", 200, 100)
    GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
    $okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
    GUISetState(@SW_SHOW)

    While 1
    $msg = GUIGetMsg()

    Select
    Case $msg = $okbutton
    MsgBox(0, "GUI Event", "You pressed OK!")

    Case $msg = $GUI_EVENT_CLOSE
    MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
    ExitLoop
    EndSelect
    WEnd

    It's that simple. Obviously the more windows and controls you create the more complicated it gets but the above shows you the basics.

    Advanced GUIGetMsg and Multiple Windows

    Control IDs are unique, even when you have multiple windows, so the above code with work fine with controls and multiple windows. However, when processing events such as $GUI_EVENT_CLOSE or $GUI_MOUSEMOVE you need to know which GUI window generated the event. To do this you must call GUIGetMsg like so:

    $msg = GUIGetMsg(1)

    When called with the 1 parameter instead of returning an event value an array will be returned, the array contains the event ( in $array[0] ) and extra information such as the window handle ( in $array[1] ). If two windows were created in the previous example then the correct way to write the code would be:

    #include <GUIConstants.au3>

    $mainwindow = GUICreate("Hello World", 200, 100)
    GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
    $okbutton = GUICtrlCreateButton("OK", 70, 50, 60)

    $dummywindow = GUICreate("Dummy window for testing ", 200, 100)

    GUISwitch($mainwindow)
    GUISetState(@SW_SHOW)

    While 1
    $msg = GUIGetMsg(1)

    Select
    Case $msg[0] = $okbutton
    MsgBox(0, "GUI Event", "You pressed OK!")

    Case $msg[0] = $GUI_EVENT_CLOSE And $msg[1] = $mainwindow
    MsgBox(0, "GUI Event", "You clicked CLOSE on the main window! Exiting...")
    ExitLoop
    EndSelect
    WEnd

    The first major change is the GUISwitch function call - when a new window is created it becomes the "default" window for future GUI operations (including control creation). In our case we want to work with the main "Hello World" window, not the test window, so we "switch". Some GUI functions allow you to use the window handle in the function call itself - these functions will do the switch automatically. In our example we could have done this with:

    GUISetState(@SW_SHOW, $mainwindow)

    The next change is the way GUIGetMsg is called and how the events are checked - notice the use of $msg[0] and $msg[1] - now we only exit the script if the close event is sent and the event is from our main window.


GUI Reference - OnEvent Mode

In the OnEvent mode instead of constantly polling the GUI to find out if anything has happened you make the GUI temporarily pause your script and call a pre-defined function to handle the event. For example, if the user clicks Button1 the GUI pauses your main script and calls a previously defined user function that deals with Button1. When the function call is completed the main script is resumed. This mode is similar to the Visual Basic forms method.

While the GUI is executing, your main script could be doing any normal scripting work, but for ease of examples we will just make the main script "idle" in an infinite While loop.

The default mode is the MessageLoop mode so before using the OnEvent mode we must use Opt("GUIOnEventMode", 1).

Basic OnEvent Format

The general layout of OnEvent code is:

While 1
Sleep(1000) ; Just idle around
WEnd

Func Event1()
; Code to handle event goes here
EndFunc

Func Event2()
; Code to handle event goes here
EndFunc

GUI Events

In the OnEvent mode your GUI will generate the following "events":

  • Control Event
  • System Event

    • Both types of event will call a user defined function if one was set for the GUI (GUISetOnEvent) or for a control (GUICtrlSetOnEvent). If no functions are defined for an event then it is simply ignored. When inside this called function various macros will be set to values to help process the event.

    Macro | Details
@GUI_CTRLID | The control ID of the control sending the message OR the system event ID
@GUI_WINHANDLE | The handle of the GUI that sent the message
@GUI_CTRLHANDLE | The handle of the Control that sent the message (if applicable)

    Note: It is perfectly legal to use the same function for multiple events, all that you need to do in these cases is to take action based on the @GUI_CTRLID macro. For example, you could register all system events to the same function.

    Control Event

    When a control is clicked or changes a control event is sent. The event is sent to the function defined with GUICtrlSetOnEvent. Inside the user defined function @GUI_CTRLID is set to the controlID that was returned when the control was created with GUICtrlCreate....

    System Event

    System events - such as the GUI closing - are sent in a similar way to Control event, but the event type is defined by @GUI_CTRLID. The event is sent to the function defined with GUISetOnEvent. The possible system event values are shown here:

    $GUI_EVENT_CLOSE
    $GUI_EVENT_MINIMIZE
    $GUI_EVENT_RESTORE
    $GUI_EVENT_MAXIMIZE
    $GUI_EVENT_PRIMARYDOWN
    $GUI_EVENT_PRIMARYUP
    $GUI_EVENT_SECONDARYDOWN
    $GUI_EVENT_SECONDARYUP
    $GUI_EVENT_MOUSEMOVE

    Example GUI

    In the main GUI Reference page we started a simple Hello World example that looked like this:

    #include <GUIConstants.au3>

    GUICreate("Hello World", 200, 100)
    GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
    GUICtrlCreateButton("OK", 70, 50, 60)
    GUISetState(@SW_SHOW)
    Sleep(2000)

    Now we will finish the code using OnEvents and some of the event messages described above.

    #include <GUIConstants.au3>

    Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
    $mainwindow = GUICreate("Hello World", 200, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
    $okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
    GUICtrlSetOnEvent($okbutton, "OKButton")
    GUISetState(@SW_SHOW)

    While 1
    Sleep(1000) ; Idle around
    WEnd

    Func OKButton()
    ;Note: at this point @GUI_CTRLID would equal $okbutton,
    ;and @GUI_WINHANDLE would equal $mainwindow
    MsgBox(0, "GUI Event", "You pressed OK!")
    EndFunc

    Func CLOSEClicked()
    ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
    ;and @GUI_WINHANDLE would equal $mainwindow
    MsgBox(0, "GUI Event", "You clicked CLOSE! Exiting...")
    Exit
    EndFunc

    It's that simple. Obviously the more windows and controls you create the more complicated it gets but the above shows you the basics.

    Advanced Operations and Multiple Windows

    Control IDs are unique, even when you have multiple windows but how do we handle multiple windows?

    Here is an example similar to the one above but with another "dummy" window.

    #include <GUIConstants.au3>

    Opt("GUIOnEventMode", 1) ; Change to OnEvent mode
    $mainwindow = GUICreate("Hello World", 200, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
    GUICtrlCreateLabel("Hello world! How are you?", 30, 10)
    $okbutton = GUICtrlCreateButton("OK", 70, 50, 60)
    GUICtrlSetOnEvent($okbutton, "OKButton")

    $dummywindow = GUICreate("Dummy window for testing ", 200, 100)
    GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")

    GUISwitch($mainwindow)
    GUISetState(@SW_SHOW)

    While 1
    Sleep(1000) ; Idle around
    WEnd

    Func OKButton()
    ;Note: at this point @GUI_CTRLID would equal $okbutton
    MsgBox(0, "GUI Event", "You pressed OK!")
    EndFunc

    Func CLOSEClicked()
    ;Note: at this point @GUI_CTRLID would equal $GUI_EVENT_CLOSE,
    ;@GUI_WINHANDLE will be either $mainwindow or $dummywindow
    If @GUI_WINHANDLE = $mainwindow Then
    MsgBox(0, "GUI Event", "You clicked CLOSE in the main window! Exiting...")
    Exit
    EndIf
    EndFunc

    The first major change is the GUISwitch function call - when a new window is created it becomes the "default" window for future GUI operations (including control creation). In our case we want to work with the main "Hello World" window, not the test window, so we "switch". Some GUI functions allow you to use the window handle in the function call itself - these functions will do the switch automatically. In our example we could have done this with:

    GUISetState(@SW_SHOW, $mainwindow)

    Also notice that we used the same OnEvent function to handle the "close" button for both windows and then used @GUI_WINHANDLE to determine which window sent the message - then we only closed the GUI when the close button was clicked and the message came from the main window . You can just as easily use separate functions for each window if you wish.


Keywords

Keyword Reference

Below is a complete list of the keywords available in AutoIt. Click on a keyword name for a detailed description.

Keyword | Description
#comments-start | Specify that an entire section of script should be commented out.
ContinueLoop | Continue a While/Do/For loop.
Dim / Global / Local / Const | Declare a variable, a constant, or create an array.
Do...Until | Loop based on an expression.
Exit | Terminates the script.
ExitLoop | Terminate a While/Do/For loop.
For...Next | Loop based on an expression.
Func...Return...EndFunc | Defines a user-defined function that takes zero or more arguments and optionally returns a result.
If...Then | Conditionally run a single statement.
If...ElseIf...Else...EndIf | Conditionally run statements.
#include-once | Specifies that the current file may only be included once.
#include | Includes a file in current script.
#NoTrayIcon | Indicates that the AutoIt tray icon will not be shown when the script starts.
ReDim | Resize an existing array
Select...Case...EndSelect | Conditionally run statements.
While...WEnd | Loop based on an expression.


Keyword #comments-start

Keyword Reference

#comments-start

Specify that an entire section of script should be commented out.

#comments-start
...
...
#comments-end

Parameters

None.

Remarks

The #comments-start and #comments-end directives can be nested.
You can also use the abbreviated keywords #cs and #ce.
Additionally, the directives themselves can be commented out!

Related

#include, #include-once

Example

#comments-start
MsgBox(4096, "", "This won't be executed")
MsgBox(4096, "", "Or this")
#comments-end

;;; #cs
MsgBox(4096, "", "This will print if '#cs' is commented out.")
#ce


Keyword #include

Keyword Reference

#include

Includes a file in current script.

#include "[path\]filename"
#include <filename>

Parameters

filename The filename of the current script to include. Path is optional. This must be a string--it cannot be a variable.
If "..." is used, the filename is taken to be relative to the current script.
If <...> is used the filename is taken to be relative to include library directory (usually C:\Program Files\AutoIt3\Include). The include library contains many pre-written user-functions for you to use!

Remarks

In an AutoIt script, other scripts can be included using the #include" command. #include must be in lower-case.

For the include library syntax (#include <file>) to work AutoIt must have been installed using the supplied installer otherwise the installation directory will not be known and the current script directory (@ScriptDir\Include) will be used instead.

If you include the same file containing a user-function more than once you will get a "Duplicate function" error. When writing an include file that may be used in this way, make sure that the top line contains #include-once to prevent that file from being included more than once.

Related

#include-once, FileInstall

Example

;;; TIME.AU3 ;;;
MsgBox(0,"", "The time is " & @HOUR & ":" & @MIN & ":" & @SEC)

;;; SCRIPT.AU3 ;;;
#include "TIME.AU3"
MsgBox(0,"", "Example")
#include "TIME.AU3"
Exit

; Running script.au3 will output three message boxes:
; one with the time, one with 'Example', and another with the time.


Keyword #include-once

Keyword Reference

#include-once

Specifies that the current file may only be included once.

#include-once

Parameters

None.

Remarks

If you include the same file containing a user-function more than once, you will get a "Duplicate function" error. When writing an include file that may be used in this way, make sure that the top line contains #include-once to prevent that file from being included more than once.

Related

#include, FileInstall

Example

;;; LIBRARY.AU3 ;;;
#include-once

Func myFunc()
MsgBox(0,"", "Hello from library.au3")
EndFunc

;;; SCRIPT.AU3 ;;;
#include "Library.au3"
#include "Library.au3" ;throws an error if #include-once was not used

MsgBox(0, "Example", "This is from 'script.au3' file")
myFunc()
Exit

; Running script.au3 will output the two message boxes:
; one saying "This is from 'script.au3' file"
; and another saying "Hello from library.au3"


Keyword #NoTrayIcon

Keyword Reference

#NoTrayIcon

Indicates that the AutoIt tray icon will not be shown when the script starts.

#NoTrayIcon

Parameters

None.

Remarks

You can use Opt("TrayIconHide", 1) to remove the AutoIt tray icon, but it will still be visible for a second when the script starts. Placing the #NoTrayIcon directive anywhere in your script will stop the icon from being shown at startup.

You may still turn the icon back on later in the script using Opt("TrayIconHide", 0)

Related

TrayIconHide (Option)

Example

#NoTrayIcon
MsgBox(4096,"Click OK","Show the tray icon for 5 seconds...")
Opt("TrayIconHide", 0) ;un-hide the icon
Sleep(5000)


Keyword Dim / Global / Local / Const

Keyword Reference

Dim / Global / Local / Const

Declare a variable, a constant, or create an array.

Dim [Const] $variable
Dim $array[subscript 1]...[subscript n]

Parameters

const | [optional] If present, the Const keyword creates a constant rather than a variable.
$variable | The name of the variable to declare.
subscript | The number of elements to create for the array dimension, indexed 0 to n-1.

Remarks

The Dim/Local/Global keywords perform a similar function.
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.

You can also declare multiple variables on a single line:

Dim $a, $b, $c

And pre-initialize, if variable is not an array:

Dim $a = 2, $b, $c = 20

Creating constants can be done in a similar way:

Dim Const $a, $b, $c
Const $a, $b, $c
Const $a = 2, $b, $c = 20
Local Const $a, $b, $c

Once created you cannot change the value of a constant. Also, you cannot change an existing variable into a constant.

The difference between Dim/Local/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

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 element.

A unique feature is the ability to copy arrays like this:
$mycopy = $myarray
In this case $mycopy will be an exact copy of $myarray and will have the same dimensions - no Dim statement is required first. If the variable $mycopy was already an array or 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.

Dim for the same variable name will erase and reset the dimensions to the new definition.

Related

UBound, ReDim

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 $x, $y = 23, $z
Global Const $PI = 3.14159, $RADIUS
Local Const $daysWorking = 5


Keyword ContinueLoop

Keyword Reference

ContinueLoop

Continue a While/Do/For loop.

ContinueLoop [level]

Parameters

level [optional] The level of the loop to restart. The default is 1 (meaning the current loop).

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-End 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

;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 Do...Until

Keyword Reference

Do...Until

Loop based on an expression.

Do
statements
...
Until <expression>

Parameters

expression The statements in between Do and Until are executed until the expression is true.

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, While...WEnd, For...Next

Example

$i = 0
Do
MsgBox(0, "Value of $i is:", $i)
$i = $i + 1
Until $i = 10


Keyword Exit

Keyword Reference

Exit

Terminates the script.

Exit [return code]

Parameters

return code [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 sets an errorlevel of 0 if the script executed properly; error levels 1 and above typically indicate that the script did not execute properly.

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.

Related

ExitLoop

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 ExitLoop

Keyword Reference

ExitLoop

Terminate a While/Do/For loop.

ExitLoop [level]

Parameters

level [optional] The number of levels of loop to exit. The default is 1 (meaning the current loop).

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 loop-body.

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)


Keyword For...Next

Keyword Reference

For...Next

Loop based on an expression.

For <variable> = <start> To <stop> [Step <stepval>]
statements
...
Next

Parameters

variable | The variable used for the count.
start | The initial numeric value of the variable.
stop | The final numeric value of the variable.
stepval | [optional] The numeric value (possibly fractional) that the count is increased by each loop. Default is 1.

Remarks

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!")


Keyword Func...Return...EndFunc

Keyword Reference

Func...Return...EndFunc

Defines a user-defined function that takes zero or more arguments and optionally returns a result.

Func functioname ( [ByRef] $param1, ..., [ByRef] $paramN, $optionalpar1 = value, ...)
...
[Return [value]]
EndFunc

Parameters

The parameters are set by you. You later call the function like any other built-in function.

Remarks

The ByRef keyword is optional and means: (1) the parameter must a variable, and (2) the variable could be changed by the function. By default, a parameter is passed by value which means that a copy of the parameter's value is manipulated by the function.

Use the Return keyword to exit the function. Unlike built-in functions, user-defined functions return 0 unless another return value is specified.

Arrays can be passed to functions (and returned from them) by simply using the array name without any brackets. Note that function declarations cannot appear inside other function declarations.

Optional parameters are defined by assigning to them a default value which can be a macro . They cannot be embedded with mandatory parameters. They are always the last in the definition.
Inside the the function the number of parameters used to called the function can be retrieved with the @NUMPARAMS macro.

Related

Dim/Global/Local, #include

Example

; Sample script with three user-defined functions
; Notice the use of variables, ByRef, and Return

$foo = 2
$bar = 5
msgBox(0,"Today is " & today(), "$foo equals " & $foo)
swap($foo, $bar)
msgBox(0,"After swapping $foo and $bar", "$foo now contains " & $foo)
msgBox(0,"Finally", "The larger of 3 and 4 is " & max(3,4))
Exit

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


Keyword If...Then

Keyword Reference

If...Then

Conditionally run a single statement.

If <expression> Then statement

Parameters

expression If the expression is true, the statement is executed.

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

Example

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

;Alternative:
If $CmdLine[0] = 0 Then
Exit
EndIf


Keyword If...ElseIf...Else...EndIf

Keyword Reference

If...ElseIf...Else...EndIf

Conditionally run statements.

If <expression> Then
statements
...
[ElseIf expression-n Then
[elseif statements ... ]]
...
[Else
[else statements]
...
EndIf

Parameters

expression 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.

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

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


Keyword ReDim

Keyword Reference

ReDim

Resize an existing array

ReDim $array[subscript 1]...[subscript n]

Parameters

$variable | The name of the variable to resize.
subscript | The number of elements to create for the array dimension, indexed 0 to n-1.

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

; 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 Select...Case...EndSelect

Keyword Reference

Select...Case...EndSelect

Conditionally run statements.

Select
Case <expression>
statement1
...
[Case
statement2
...]
[Case Else
statementN
...]
EndSelect

Parameters

Case <expression> 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.

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

Example

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


Keyword While...WEnd

Keyword Reference

While...WEnd

Loop based on an expression.

While <expression>
statements
...
WEnd

Parameters

expression If the expression is true the following statements up to the WEnd statement are executed. This loop continues until the expression is false.

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, Do...Until, ExitLoop

Example

$i = 0
While $i <= 10
MsgBox(0, "Value of $i is:", $i)
$i = $i + 1
WEnd


Macros

Macro Reference

Below is an alphabetized list of all the macros available in AutoIt.

Macro | Description
@AppDataCommonDir | path to Application Data
@AppDataDir | path to current user's Application Data
@AutoItExe | The full path and filename of the AutoIt executable currently running. For compiled scripts it is the path of the compiled script.
@AutoItVersion | Version number of AutoIt such as 3.0.81.0
@CommonFilesDir | path to Common Files folder
@Compiled | Returns 1 if script is a compiled executable; otherwise, returns 0.
@ComputerName | Computer's network name.
@ComSpec value of %comspec%, the SPECified secondary COMmand interpreter;
primarily for command line uses, e.g. Run(@ComSpec & " /k help | more")
@CR | Carriage return, Chr(13); sometimes used for line breaks.
@CRLF | = @CR & @LF ;occasionally used for line breaks.
@DesktopCommonDir | path to Desktop
@DesktopDir | path to current user's Desktop
@DesktopHeight | Height of the desktop screen in pixels. (horizontal resolution)
@DesktopWidth | Width of the desktop screen in pixels. (vertical resolution)
@DesktopDepth | Depth of the desktop screen in bits per pixel.
@DesktopRefresh | Refresh rate of the desktop screen in hertz.
@DocumentsCommonDir | path to Documents
@error | Status of the error flag. See the SetError function.
@extended | Extended function return - used in certain functions such as StringReplace.
@FavoritesCommonDir | path to Favorites
@FavoritesDir | path to current user's Favorites
@GUI_CtrlId | Last click control identifier. See the GUICtrlSetOnEvent function.
@GUI_CtrlHandle | Last click control handle. See the GUICtrlSetOnEvent function.
@GUI_WinHandle | Last click GUI window handle. See the GUICtrlSetOnEvent function.
@HomeDrive | Drive letter of drive containing current user's home directory.
@HomePath | Directory part of current user's home directory. To get the full path, use in conjunction with @HomeDrive.
@HomeShare | @HomeShare - Server and share name containing current user's home directory.
@HOUR | Hours value of clock in 24-hour format. Range is 00 to 23
@InetGetActive | Is 1 if a InetGet download is currently active, otherwise is 0.
@InetGetBytesRead | During a InetGet download this is the number of bytes currently read. It is -1 when there is an error downloading.
@IPAddress1 IP address of first network adapter. Tends to return 127.0.0.1 on some computers.
@IPAddress2 | IP address of second network adapter. Returns 0.0.0.0 if not applicable.
@IPAddress3 | IP address of third network adapter. Returns 0.0.0.0 if not applicable.
@IPAddress4 | IP address of fourth network adapter. Returns 0.0.0.0 if not applicable.
@LF | Line feed, Chr(10); typically used for line breaks.
@LogonDNSDomain | Logon DNS Domain.
@LogonDomain | Logon Domain.
@LogonServer | Logon server.
@MDAY | Current day of month. Range is 01 to 31
@MIN | Minutes value of clock. Range is 00 to 59
@MON | Current month. Range is 01 to 12
@MyDocumentsDir | path to My Documents target
@NumParams | Number of parameters used to call the user functions
@OSBuild | Returns the OS build number. For example, Windows 2003 Server returns 3790
@OSLang | Returns code denoting OS Language. See Appendix for possible values.
@OSServicePack | Service pack info in the form of "Service Pack 3" or, for Windows 95, it may return "B"
@OSTYPE | Returns "WIN32_NT" for NT/2000/XP/2003 and returns "WIN32_WINDOWS" for 95/98/Me
@OSVersion | Returns one of the following: "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95"
@ProgramFilesDir | path to Program Files folder
@ProgramsCommonDir | path to Start Menu's Programs folder
@ProgramsDir | path to current user's Programs (folder on Start Menu)
@ScriptDir | Directory containing the running script. (Result does not contain a trailing backslash)
@ScriptFullPath | Equivalent to @ScriptDir & "\" & @ScriptName
@ScriptName | Long filename of the running script.
@SEC | Seconds value of clock. Range is 00 to 59
@StartMenuCommonDir | path to Start Menu folder
@StartMenuDir | path to current user's Start Menu
@StartupCommonDir | path to Startup folder
@StartupDir | current user's Startup folder
@SW_DISABLE | Disables the window.
@SW_ENABLE | Enables the window.
@SW_HIDE | Hides the window and activates another window.
@SW_MAXIMIZE | Maximizes the specified window.
@SW_MINIMIZE | Minimizes the specified window and activates the next top-level window in the Z order.
@SW_RESTORE | Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
@SW_SHOW | Activates the window and displays it in its current size and position.
@SW_SHOWDEFAULT | Sets the show state based on the SW_ value specified by the program that started the application.
@SW_SHOWMAXIMIZED | Activates the window and displays it as a maximized window.
@SW_SHOWMINIMIZED | Activates the window and displays it as a minimized window.
@SW_SHOWMINNOACTIVE | Displays the window as a minimized window. This value is similar to @SW_SHOWMINIMIZED, except the window is not activated.
@SW_SHOWNA | Displays the window in its current size and position. This value is similar to @SW_SHOW, except the window is not activated.
@SW_SHOWNOACTIVATE | Displays a window in its most recent size and position. This value is similar to @SW_SHOWNORMAL, except the window is not actived.
@SW_SHOWNORMAL | Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
@SystemDir | path to Windows' System (or System32) folder
@TAB | Tab character, Chr(9)
@TempDir | Path to the temporary files folder.
@UserProfileDir | Path to current user's Profile folder.
@UserName | ID of the currently logged on user.
@WDAY | Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday.
@WindowsDir | path to Windows folder
@WorkingDir | Current/active working directory. (Result does not contain a trailing backslash)
@YDAY | Current day of year. Range is 1 to 366 (or 365 if not a leap year)
@YEAR | Current four-digit year


Macros Reference - AutoIt Related

Macro Reference - AutoIt Related

Below is a list of AutoIt-related macros.

The full list of macros can be found here.

Macro | Description
@compiled | Returns 1 if script is a compiled executable; otherwise, returns 0.
@error | Status of the error flag. See the SetError function.
@extended | Extended function return - used in certain functions such as StringReplace.
@NumParams | Number of parameters used in calling the user function.
@ScriptName | Filename of the running script.
@ScriptDir | Directory containing the running script. (Result does not contain a trailing backslash)
@ScriptFullPath | Equivalent to @ScriptDir & "\" & @ScriptName
@WorkingDir | Current/active working directory. (Result does not contain a trailing backslash)
@AutoItExe | The full path and filename of the AutoIt executable currently running. For compiled scripts it is the path of the compiled script.
@AutoItVersion | Version number of AutoIt such as 3.0.102.0
@InetGetActive | Is 1 if a InetGet download is currently active, otherwise is 0.
@InetGetBytesRead | During a InetGet download this is the number of bytes currently read. It is -1 when there is an error downloading.
@GUI_CtrlId | Last click GUI Control identifier.
@GUI_CtrlHandle | Last click GUI Control handle.
@GUI_WinHandle | Last click GUI Window handle..
For use with the WinSetState, Run, RunWait, FileCreateShortcut and FileGetShortcut functions:
@SW_DISABLE | Disables the window.
@SW_ENABLE | Enables the window.
@SW_HIDE | Hides the window and activates another window.
@SW_MAXIMIZE | Maximizes the specified window.
@SW_MINIMIZE | Minimizes the specified window and activates the next top-level window in the Z order.
@SW_RESTORE | Activates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized window.
@SW_SHOW | Activates the window and displays it in its current size and position.
@SW_SHOWDEFAULT | Sets the show state based on the SW_ value specified by the program that started the application.
@SW_SHOWMAXIMIZED | Activates the window and displays it as a maximized window.
@SW_SHOWMINIMIZED | Activates the window and displays it as a minimized window.
@SW_SHOWMINNOACTIVE | Displays the window as a minimized window. This value is similar to @SW_SHOWMINIMIZED, except the window is not activated.
@SW_SHOWNA | Displays the window in its current size and position. This value is similar to @SW_SHOW, except the window is not activated.
@SW_SHOWNOACTIVATE | Displays a window in its most recent size and position. This value is similar to @SW_SHOWNORMAL, except the window is not actived.
@SW_SHOWNORMAL | Activates and displays a window. If the window is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the window for the first time.
@CR | Carriage return, Chr(13); sometimes used for line breaks.
@LF | Line feed, Chr(10); typically used for line breaks.
@CRLF | = @CR & @LF ;occasionally used for line breaks.
@TAB | Tab character, Chr(9)


Macro Reference - Directory

Below is a list of Directory macros. Note that paths do not contain a trailing backslash.

The full list of macros can be found here.

Macro | Description
Macros for "All User" data. Most values are read from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion
@AppDataCommonDir | path to Application Data
@DesktopCommonDir | path to Desktop
@DocumentsCommonDir | path to Documents
@FavoritesCommonDir | path to Favorites
@ProgramsCommonDir | path to Start Menu's Programs folder
@StartMenuCommonDir | path to Start Menu folder
@StartupCommonDir | path to Startup folder
Macros for Current User data. Most values are read from HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion
@AppDataDir | path to current user's Application Data
@DesktopDir | path to current user's Desktop
@MyDocumentsDir | path to My Documents target
@FavoritesDir | path to current user's Favorites
@ProgramsDir | path to current user's Programs (folder on Start Menu)
@StartMenuDir | path to current user's Start Menu
@StartupDir | current user's Startup folder
@UserProfileDir | Path to current user's Profile folder.

Other macros for the computer system:
@HomeDrive | Drive letter of drive containing current user's home directory.
@HomePath | Directory part of current user's home directory. To get the full path, use in conjunction with @HomeDrive.
@HomeShare | Server and share name containing current user's home directory.
@LogonDNSDomain | Logon DNS Domain.
@LogonDomain | Logon Domain.
@LogonServer | Logon server.
@ProgramFilesDir | path to Program Files folder
@CommonFilesDir | path to Common Files folder
@WindowsDir | path to Windows folder
@SystemDir | path to Windows' System (or System32) folder
@TempDir | path to the temporary files folder
@ComSpec value of %comspec%, the SPECified secondary COMmand interpreter;
primarly for command line uses, e.g. Run(@ComSpec & " /k help | more")


Macro Reference - System Info

Below is a list of System information macros.

The full list of macros can be found here.

Macro | Description
@OSLang | Returns code denoting OS Language. See Appendix for possible values.
@OSType | Returns "WIN32_NT" for NT/2000/XP/2003 and returns "WIN32_WINDOWS" for 95/98/Me
@OSVersion | Returns one of the following: "WIN_2003", "WIN_XP", "WIN_2000", "WIN_NT4", "WIN_ME", "WIN_98", "WIN_95"
@OSBuild | Returns the OS build number. For example, Windows 2003 Server returns 3790
@OSServicePack | Service pack info in the form of "Service Pack 3" or, for Windows 95, it may return "B"
@ComputerName | Computer's network name.
@UserName | ID of the currently logged on user.
@IPAddress1 | IP address of first network adapter. Tends to return 127.0.0.1 on some computers.
@IPAddress2 | IP address of second network adapter. Returns 0.0.0.0 if not applicable.
@IPAddress3 | IP address of third network adapter. Returns 0.0.0.0 if not applicable.
@IPAddress4 | IP address of fourth network adapter. Returns 0.0.0.0 if not applicable.
@DesktopWidth | Width of the desktop screen in pixels. (vertical resolution)
@DesktopHeight | Height of the desktop screen in pixels. (horizontal resolution)
@DesktopDepth | Depth of the desktop screen in bits per pixel.
@DesktopRefresh | Refresh rate of the desktop screen in hertz.


Macro Reference - Time And Date

Below is a list of Time and Date macros. Notice that most return values are two-digits long.

The full list of macros can be found here.

Macro | Description
@SEC | Seconds value of clock. Range is 00 to 59
@MIN | Minutes value of clock. Range is 00 to 59
@HOUR | Hours value of clock in 24-hour format. Range is 00 to 23
@MDAY | Current day of month. Range is 01 to 31
@MON | Current month. Range is 01 to 12
@YEAR | Current four-digit year
@WDAY | Numeric day of week. Range is 1 to 7 which corresponds to Sunday through Saturday.
@YDAY | Current day of year. Range is 1 to 366 (or 365 if not a leap year)


Functions

Function Reference

Below is a complete list of the functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
Abs | Calculates the absolute value of a number.
ACos | Calculates the arcCosine of a number.
AdlibDisable | Disables the adlib functionality.
AdlibEnable | Enables Adlib functionality.
Asc | Returns the ASCII code of a character.
ASin | Calculates the arcsine of a number.
Assign | Assigns a variable by name with the data.
ATan | Calculates the arctangent of a number.
AutoItSetOption | Changes the operation of various AutoIt functions/parameters.
AutoItWinGetTitle | Retrieves the title of the AutoIt window.
AutoItWinSetTitle | Changes the title of the AutoIt window.
BitAND | Performs a bitwise AND operation.
BitNOT | Performs a bitwise NOT operation.
BitOR | Performs a bitwise OR operation.
BitShift | Performs a bit shifting operation.
BitXOR | Performs a bitwise exclusive OR (XOR) operation.
BlockInput | Disable/enable the mouse and keyboard.
Break | Enables or disables the users' ability to exit a script from the tray icon menu.
Call | Calls a user-defined function contained in a string parameter.
CDTray | Opens or closes the CD tray.
Chr | Returns a character corresponding to an ASCII code.
ClipGet | Retrieves text from the clipboard.
ClipPut | Writes text to the clipboard.
ConsoleWrite | Writes data to a stream that text editors can sometimes read.
ControlClick | Sends a mouse click command to a given control.
ControlCommand | Sends a command to a control.
ControlDisable | Disables or "grays-out" a control.
ControlEnable | Enables a "grayed-out" control.
ControlFocus | Sets input focus to a given control on a window.
ControlGetFocus | Returns the ControlRef# of the control that has keyboard focus within a specified window.
ControlGetHandle | Retrieves the internal handle of a control.
ControlGetPos | Retrieves the position and size of a control relative to it's window.
ControlGetText | Retrieves text from a control.
ControlHide | Hides a control.
ControlListView | Sends a command to a ListView32 control.
ControlMove | Moves a control within a window.
ControlSend | Sends a string of characters to a control.
ControlSetText | Sets text of a control.
ControlShow | Shows a control that was hidden.
Cos | Calculates the cosine of a number.
Dec | Returns a numeric representation of a hexadecimal string.
DirCopy | Copies a directory and all sub-directories and files (Similar to xcopy).
DirCreate | Creates a directory/folder.
DirGetSize | Returns the size in bytes of a given directory.
DirMove | Moves a directory and all sub-directories and files.
DirRemove | Deletes a directory/folder.
DllCall | Dynamically calls a function in a DLL.
DllClose | Closes a previously opened DLL.
DllOpen | Opens a dll file for use in DllCall.
DriveGetDrive | Returns an array containing the enumerated drives.
DriveGetFileSystem | Returns File System Type of a drive.
DriveGetLabel | Returns Volume Label of a drive, if it has one.
DriveGetSerial | Returns Serial Number of a drive.
DriveGetType | Returns drive type.
DriveMapAdd | Maps a network drive.
DriveMapDel | Disconnects a network drive.
DriveMapGet | Retreives the details of a mapped drive.
DriveSetLabel | Sets the Volume Label of a drive.
DriveSpaceFree | Returns the free disk space of a path in Megabytes.
DriveSpaceTotal | Returns the total diskspace of a path in Megabytes.
DriveStatus | Returns the status of the drive as a string.
EnvGet | Retrieves an environment variable.
EnvSet | Writes an environment variable.
EnvUpdate | Refreshes the OS environment.
Eval | Return the value of the variable whose name is given by the expression.
Exp | Calculates e to the power of a number.
FileChangeDir | Changes the current working directory.
FileClose | Closes a previously opened text file.
FileCopy | Copies one or more files.
FileCreateShortcut | Creates a shortcut (.lnk) to a file.
FileDelete | Delete one or more files.
FileExists | Checks if a file or directory exists.
FileFindFirstFile | Returns a filename according to search string.
FileFindNextFile | Returns a filename according to a previous call to FileFindFirstFile.
FileGetAttrib | Returns a code string representing a file's attributes.
FileGetLongName | Returns the long path+name of the path+name passed.
FileGetShortcut | Retrieves details about a shortcut.
FileGetShortName | Returns the 8.3 short path+name of the path+name passed.
FileGetSize | Returns the size of a file in bytes.
FileGetTime | Returns the time and date information for a file.
FileGetVersion | Returns the "File" version information.
FileInstall | Include and install a file with the compiled script.
FileMove | Moves one or more files
FileOpen | Opens a text file for reading or writing.
FileOpenDialog | Initiates a Open File Dialog.
FileRead | Read in a number of characters from a previously opened text file.
FileReadLine | Read in a line of text from a previously opened text file.
FileRecycle | Sends a file or directory to the recycle bin.
FileRecycleEmpty | Empties the recycle bin.
FileSaveDialog | Initiates a Save File Dialog.
FileSelectFolder | Initiates a Browse For Folder GUI.
FileSetAttrib | Sets the attributes of one or more files.
FileSetTime | Sets the timestamp of one of more files.
FileWrite | Append a line of text to the end of a previously opened text file.
FileWriteLine | Append a line of text to the end of a previously opened text file.
FtpSetProxy | Sets the internet proxy to use for ftp access.
GUICreate | Create a GUI window.
GUICtrlCreateAvi | Creates an AVI video control for the GUI.
GUICtrlCreateButton | Creates a Button control for the GUI.
GUICtrlCreateCheckbox | Creates a Checkbox control for the GUI.
GUICtrlCreateCombo | Creates a ComboBox control for the GUI.
GUICtrlCreateContextMenu | Creates a context menu for a control or entire GUI window.
GUICtrlCreateDate | Creates a date control for the GUI.
GUICtrlCreateDummy | Creates a Dummy control for the GUI.
GUICtrlCreateEdit | Creates an Edit control for the GUI.
GUICtrlCreateGroup | Creates a Group control for the GUI.
GUICtrlCreateIcon | Creates an Icon control for the GUI.
GUICtrlCreateInput | Creates an Input control for the GUI.
GUICtrlCreateLabel | Creates a static Label control for the GUI.
GUICtrlCreateList | Creates a List control for the GUI.
GUICtrlCreateListView | Creates a ListView control for the GUI.
GUICtrlCreateListViewItem | Creates a ListView item.
GUICtrlCreateMenu | Creates a Menu control for the GUI.
GUICtrlCreateMenuitem | Creates a MenuItem control for the GUI.
GUICtrlCreatePic | Creates a Picture control for the GUI.
GUICtrlCreateProgress | Creates a Progress control for the GUI.
GUICtrlCreateRadio | Creates a Radio button control for the GUI.
GUICtrlCreateSlider | Creates a Slider control for the GUI.
GUICtrlCreateTab | Creates a Tab control for the GUI.
GUICtrlCreateTabItem | Creates a TabItem control for the GUI.
GUICtrlCreateTreeView | Creates a TreeView control for the GUI.
GUICtrlCreateTreeViewItem | Creates a TreeViewItem control for the GUI.
GUICtrlCreateUpdown | Creates an UpDown control for the GUI.
GUICtrlDelete | Deletes a control.
GUICtrlGetState | Gets the current state of a control
GUICtrlRead | Read state or data of a control.
GUICtrlRecvMsg | Send a message to a control and retrieve information in lParam.
GUICtrlSendMsg | Send a message to a control.
GUICtrlSendToDummy | Sends a message to a Dummy control.
GUICtrlSetBkColor | Sets the background color of a control.
GUICtrlSetColor | Sets the text color of a control.
GUICtrlSetCursor | Sets mouse cursor icon for a particular control.
GUICtrlSetData | Modifies the data for a control.
GUICtrlSetFont | Sets the font for a control.
GUICtrlSetImage | Sets the bitmap or icon image to use for a control.
GUICtrlSetLimit | Limits the number of characters/pixels for a control.
GUICtrlSetOnEvent | Defines a user-defined function to be called when a control is clicked.
GUICtrlSetPos | Changes the position of a control within the GUI window.
GUICtrlSetResizing | Defines the resizing method used by a control.
GUICtrlSetState | Changes the state of a control.
GUICtrlSetStyle | Changes the style of a control.
GUICtrlSetTip | Sets the tip text associated with a control.
GUIDelete | Deletes a GUI window and all controls that it contains.
GUIGetCursorInfo | Gets the mouse cursor position relative to GUI window.
GUIGetMsg | Polls the GUI to see if any events have ocurred.
GUISetBkColor | Sets the background color of the GUI window.
GUISetCoord | Sets absolute coordinates for next control.
GUISetCursor | Sets the mouse cursor icon for a GUI window.
GUISetFont | Sets the default font for a GUI window.
GUISetHelp | Sets an executable file that will be run when F1 is pressed.
GUISetIcon | Sets the icon used in a GUI window.
GUISetOnEvent | Defines a user function to be called when a control is clicked.
GUISetState | Changes the state of a GUI window.
GUIStartGroup | Defines that any subsequent controls that are created will be "grouped" together.
GUISwitch | Switches the current window used for GUI functions.
Hex | Returns a string representation of an integer converted to hexadecimal.
HotKeySet | Sets a hotkey that calls a user function.
HttpSetProxy | Sets the internet proxy to use for http access.
InetGet | Downloads a file from the internet using the http or ftp protocol.
InetGetSize | Returns the size (in bytes) of a file located on the internet.
IniDelete | Deletes a value from a standard format .ini file.
IniRead | Reads a value from a standard format .ini file.
IniReadSection | Reads all key/value pairs from a section in a standard format .ini file.
IniReadSectionNames | Reads all sections in a standard format .ini file.
IniWrite | Writes a value to a standard format .ini file.
InputBox | Displays an input box to ask the user to enter a string.
Int | Returns the integer (whole number) representation of an expression.
IsAdmin | Checks if the current user has administrator privileges.
IsArray | Checks if a variable is an array type.
IsDeclared | Check if a variable has been declared.
IsFloat | Checks if a variable or expression is a float-type.
IsInt | Checks if a variable or expression is an integer type.
IsNumber | Checks if a variable's base type is numeric.
IsString | Checks if a variable is a string type.
Log | Calculates the natural logarithm of a number.
MemGetStats | Retrieves memory related information.
Mod | Performs the modulus operation.
MouseClick | Perform a mouse click operation.
MouseClickDrag | Perform a mouse click and drag operation.
MouseDown | Perform a mouse down event at the current mouse position.
MouseGetCursor | Returns a cursor ID Number of the current Mouse Cursor.
MouseGetPos | Retrieves the current position of the mouse cursor.
MouseMove | Moves the mouse pointer.
MouseUp | Perform a mouse up event at the current mouse position.
MouseWheel | Moves the mouse wheel up or down. NT/2000/XP ONLY.
MsgBox | Displays a simple message box with optional timeout.
Number | Returns the numeric representation of an expression.
Ping | Pings a host and returns the roundtrip-time.
PixelChecksum | Generates a checksum for a region of pixels.
PixelGetColor | Returns a pixel color according to x,y pixel coordinates.
PixelSearch | Searches a rectangle of pixels for the pixel color provided.
ProcessClose | Terminates a named process.
ProcessExists | Checks to see if a specified process exists.
ProcessList | Returns an array listing the currently running processes (names and PIDs).
ProcessSetPriority | Changes the priority of a process
ProcessWait | Pauses script execution until a given process exists.
ProcessWaitClose | Pauses script execution until a given process does not exist.
ProgressOff | Turns Progress window off.
ProgressOn | Creates a customizable progress bar window.
ProgressSet | Sets the position and/or text of a previously created Progress bar window.
Random | Generates a pseudo-random float-type number.
RegDelete | Deletes a key or value from the registry.
RegEnumKey | Reads the name of a subkey according to it's instance.
RegEnumVal | Reads the name of a value according to it's instance.
RegRead | Reads a value from the registry.
RegWrite | Creates a key or value in the registry.
Round | Returns a number rounded to a specified number of decimal places.
Run | Runs an external program.
RunAsSet | Initialise a set of user credentials to use during Run and RunWait operations. 2000/XP or later ONLY.
RunWait | Runs an external program and pauses script execution until the program finishes.
Send | Sends simulated keystrokes to the active window.
SetError | Manually set the value of the @error macro.
SetExtended | Manually set the value of the @extended macro.
Shutdown | Shuts down the system.
Sin | Calculates the sine of a number.
Sleep | Pause script execution.
SoundPlay | Play a sound file.
SoundSetWaveVolume | Sets the system wave volume by percent.
SplashImageOn | Creates a customizable image popup window.
SplashOff | Turns SplashText or SplashImage off.
SplashTextOn | Creates a customizable text popup window.
Sqrt | Calculates the square-root of a number.
StatusbarGetText | Retrieves the text from a standard status bar control.
String | Returns the string representation of an expression.
StringAddCR | Takes a string and prefixes all linefeed characters ( Chr(10) ) with a carriage return character ( Chr(13) ).
StringFormat | Returns a formatted string (similar to the C sprintf() function).
StringInStr | Checks if a string contains a given substring.
StringIsAlNum | Checks if a string contains only alphanumeric characters.
StringIsAlpha | Checks if a string contains only alphabetic characters.
StringIsASCII | Checks if a string contains only ASCII characters in the range 0x00 - 0x7f (0 - 127).
StringIsDigit | Checks if a string contains only digit (0-9) characters.
StringIsFloat | Checks if a string is a floating point number.
StringIsInt | Checks if a string is an integer.
StringIsLower | Checks if a string contains only lowercase characters.
StringIsSpace | Checks if a string contains only whitespace characters.
StringIsUpper | Checks if a string contains only uppercase characters.
StringIsXDigit | Checks if a string contains only hexadecimal digit (0-9, A-F) characters.
StringLeft | Returns a number of characters from the left-hand side of a string.
StringLen | Returns the number of characters in a string.
StringLower | Converts a string to lowercase.
StringMid | Extracts a number of characters from a string.
StringReplace | Replaces substrings in a string.
StringRight | Returns a number of characters from the right-hand side of a string.
StringSplit | Splits up a string into substrings depending on the given delimiters.
StringStripCR | Removes all carriage return values ( Chr(13) ) from a string.
StringStripWS | Strips the white space in a string.
StringTrimLeft | Trims a number of characters from the left hand side of a string.
StringTrimRight | Trims a number of characters from the right hand side of a string.
StringUpper | Converts a string to uppercase.
Tan | Calculates the tangent of a number.
TimerDiff | Returns a difference in time from a previous call to TimerInit().
TimerInit | Returns a timestamp (in milliseconds).
ToolTip | Creates a tooltip anywhere on the screen.
TrayTip | Displays a balloon tip from the AuotIt Icon. (2000/XP only)
UBound | Returns the size of array dimensions.
WinActivate | Activates (gives focus to) a window.
WinActive | Checks to see if a specified window exists and is currently active.
WinClose | Closes a window.
WinExists | Checks to see if a specified window exists.
WinGetCaretPos | Returns the coordinates of the caret in the foreground window
WinGetClassList | Retrieves the classes from a window.
WinGetClientSize | Retrieves the size of a given window's client area.
WinGetHandle | Retrieves the internal handle of a window.
WinGetPos | Retrieves the position and size of a given window.
WinGetProcess | Retrieves the Process ID (PID) associated with a window.
WinGetState | Retrieves the state of a given window.
WinGetText | Retrieves the text from a window.
WinGetTitle | Retrieves the full title from a window.
WinKill | Forces a window to close.
WinList | Retrieves a list of windows.
WinMenuSelectItem | Invokes a menu item of a window.
WinMinimizeAll | Minimizes all windows.
WinMinimizeAllUndo | Undoes a previous WinMinimizeAll function.
WinMove | Moves and/or resizes a window.
WinSetOnTop | Change a window's "Always On Top" attribute.
WinSetState | Shows, hides, minimizes, maximizes, or restores a window.
WinSetTitle | Changes the title of a window.
WinSetTrans | Sets the transparency of a window. (Windows 2000/XP or later)
WinWait | Pauses execution of the script until the requested window exists.
WinWaitActive | Pauses execution of the script until the requested window is active.
WinWaitClose | Pauses execution of the script until the requested window does not exist.
WinWaitNotActive | Pauses execution of the script until the requested window is not active.


Function Notes

Many functions contain optional parameters that can be omitted. If you wish to specify an optional parameter, however, all parameters that precede it must be specified!
For example, consider Run ( "filename", ["workingdir" [, flag]] ). If you wish to specify the flag, you must specify a workingdir.

Many Win___ functions contain an optional parameter "text." This parameter is intended to help differentiate between windows that have identical titles.

Some functions indicate success/failure as a return value; others indicate it by setting the @error flag. Some do both....
@error = 0 ;is always success
Return = varies, but is typically non-zero for success to allow easy to read code...

If someUserFunc() then ;...function worked
If Not someUserFunc() then ;...function failed

$x = FileReadLine("C:\someFile.txt")
If @error = -1 Then ;end-of-file was reached

If a function can set the @error flag, you should always check it before using a return value - if @error indicates an error then the function return value is generally undefined...


Function ClipGet

Function Reference

ClipGet

Retrieves text from the clipboard.

ClipGet ( )

Parameters

None.

Return Value

Success: | Returns a string containing the text on the clipboard.
Failure: | Sets @error to 1 if clipboard is empty or contains a non-text entry.

Remarks

None.

Related

ClipPut

Example

$bak = ClipGet()
MsgBox(0, "Clipboard contains:", $bak)

ClipPut($bak & "additional text")
MsgBox(0, "Clipboard contains:", ClipGet())


Function ClipPut

Function Reference

ClipPut

Writes text to the clipboard.

ClipPut ( "value" )

Parameters

value The text to write to the clipboard.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Any existing clipboard contents are overwritten.

Related

ClipGet

Example

ClipPut("I am copied to the clipboard")


Function EnvGet

Function Reference

EnvGet

Retrieves an environment variable.

EnvGet ( "envvariable" )

Parameters

envvariable Name of the environment variable to get such as "TEMP" or "PATH".

Return Value

Returns the requested variable (or a blank string if the variable does not exist).

Remarks

None.

Related

EnvSet, EnvUpdate

Example

$var = EnvGet("PATH")
MsgBox(4096, "Path variable is:", $var)


Function EnvSet

Function Reference

EnvSet

Writes an environment variable.

EnvSet ( "envvariable" [, "value"] )

Parameters

envvariable | Name of the environment variable to set.
value | [optional] Value to set the environment variable to. If a value is not used the environment variable will be deleted.

Return Value

None.

Remarks

A environment variable set in this way will only be accessible to programs that AutoIt spawns (Run, RunWait). Once AutoIt closes, the variables will cease to exist.

Related

EnvGet, EnvUpdate

Example

EnvSet("MYENV", "this is a test")


Function EnvUpdate

Function Reference

EnvUpdate

Refreshes the OS environment.

EnvUpdate ( )

Parameters

None.

Return Value

Success: | None.
Failure: | Sets @error to 1.

Remarks

Similar effect as logging off and then on again. For example, changes to the %path% environment might not take effect until you call EnvUpdate (or you logoff/reboot).

Related

EnvGet, EnvSet

Example

EnvUpdate()


Function MemGetStats

Function Reference

MemGetStats

Retrieves memory related information.

MemGetStats ( )

Parameters

None.

Return Value

Returns a seven-element array containing the memory information:

$array[0] = Memory Load (Percentage of memory in use)
$array[1] = Total physical RAM
$array[2] = Available physical RAM
$array[3] = Total Pagefile
$array[4] = Available Pagefile
$array[5] = Total virtual
$array[6] = Available virtual

All memory sizes are in kilobytes.

Remarks

None.

Related

None.

Example

$mem = MemGetStats()
MsgBox(0, "Total physical RAM (KB):", $mem[1])


Function DirCopy

Function Reference

DirCopy

Copies a directory and all sub-directories and files (Similar to xcopy).

DirCopy ( "source dir", "dest dir" [, flag] )

Parameters

source dir | Path of the source directory (with no trailing backslash). eg. "C:\Path1"
dest dir | Path of the destination dir (with no trailing backslash). eg. "C:\Path_Copy"
flag | [optional] this flag determines whether to overwrite file if they already exist: 0 = (default) do not overwrite existing files 1 = overwrite existing files

Return Value

Success: | Returns 1.
Failure: | Returns 0 if there is an error copying the directory.

Remarks

If the destination directory structure doesn't exist, it will be created (if possible).

Related

DirRemove, FileCopy

Example

DirCopy("C:\My Documents", "C:\Backups\MyDocs", 1)


Function DirCreate

Function Reference

DirCreate

Creates a directory/folder.

DirCreate ( "path" )

Parameters

path Path of the directory to create.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if there is an error creating the directory.

Remarks

This function will also create all parent directories given in "path" if they do not already exist.

Related

DirRemove, FileCopy

Example

DirCreate("C:\Test1\Folder1\Folder2")


Function DirGetSize

Function Reference

DirGetSize

Returns the size in bytes of a given directory.

DirGetSize( "path" [, flag] )

Parameters

dest dir | The directory path to get the size from, eg. "C:\Windows".
flag | [optional] this flag determines the behaviour and result of the function, and can be a combination of the following: 0 = (default) 1 = Extended mode is On -> returns an array that contains extended information (see Remarks). 2 = Don't get the size of files in subdirectories (recursive mode is Off)

Return Value

Success: | Returns >= 0 the sizes
Failure: | Returns -1 and sets @error to 1 if the path doesn't exist.

Remarks

If the script is paused then this function is paused too and will only continue when the script continues!

If you use the extended mode then the array returned from this function is a single dimension array containing the following elements:
$array[0] = Size
$array[1] = Files count
$array[2] = Dirs Count

Related

None.

Example

$size = DirGetSize("C:")
Msgbox(0,"","Size(MegaBytes):" & Round($size / 1024 / 1024))

$size = DirGetSize("C:\Windows", 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 DirMove

Function Reference

DirMove

Moves a directory and all sub-directories and files.

DirMove ( "source dir", "dest dir" [, flag] )

Parameters

source dir | Path of the source directory (with no trailing backslash). eg. "C:\Path1"
dest dir | Path of the destination dir (with no trailing backslash). eg. "C:\Path_Copy"
flag | [optional] this flag determines whether to overwrite files if they already exist: 0 = (default) do not overwrite existing files 1 = overwrite existing files

Return Value

Success: | Returns 1.
Failure: | Returns 0 if there is an error moving the directory.

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" funciton, use DirMove to rename a folder!

Related

DirRemove, FileMove

Example

DirMove("C:\My Documents", "C:\Backups\MyDocs")


Function DirRemove

Function Reference

DirRemove

Deletes a directory/folder.

DirRemove ( "path" [, recurse] )

Parameters

path | Path of the directory to remove.
recurse | [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)

Return Value

Success: | Returns 1.
Failure: | Returns 0 if there is an error removing the directory (or if directory does not exist).

Remarks

None.

Related

DirCreate, FileRecycle

Example

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


Function DriveGetDrive

Function Reference

DriveGetDrive

Returns an array containing the enumerated drives.

DriveGetDrive ( "type" )

Parameters

type Type of drive to find:
"ALL", "CDROM", "REMOVABLE", "FIXED", "NETWORK", "RAMDISK", or "UNKNOWN"

Return Value

Success: | Returns an array of strings (drive letter followed by colon) of drives found. The zeroth array element contains the number of drives.
Failure: | Returns numeric 1 and sets @error to 1.

Remarks

None.

Related

DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

$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 DriveGetFileSystem

Function Reference

DriveGetFileSystem

Returns File System Type of a drive.

DriveGetFileSystem ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | Returns the File System Type of the drive as a string; see table below.
Failure: | Sets @error to 1.
Return Value | Interpretation
1 (numeric) | Drive does NOT contain media (CD, Floppy, Zip) or media is unformatted (RAW).
"FAT" | Typical file system for drives under ~500 MB such as Floppy, RAM disks, USB "pen" drives, etc.
"FAT32" | Typical file system for Windows 9x/Me hard drives.
"NTFS" | Typical file system for Windows NT/2000/XP hard drives.
"CDFS" | Typically indicates a CD (or an ISO image mounted as a virtual CD drive).
"UDF" | Typically indicates a DVD.

Remarks

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 DriveGetLabel

Function Reference

DriveGetLabel

Returns Volume Label of a drive, if it has one.

DriveGetLabel ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | Returns the Volume Label of the drive as a string.
Failure: | Sets @error to 1.

Remarks

None.

Related

DriveGetDrive, DriveGetFileSystem, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

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


Function DriveGetSerial

Function Reference

DriveGetSerial

Returns Serial Number of a drive.

DriveGetSerial ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | Returns the Serial Number of the drive as a string.
Failure: | Sets @error to 1.

Remarks

None.

Related

DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

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


Function DriveGetType

Function Reference

DriveGetType

Returns drive type.

DriveGetType ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | Returns the type of drive: "Unknown", "Removable", "Fixed", "Network", "CDROM", "RAMDisk"
Failure: | Returns numeric 1 and sets @error to 1.

Remarks

The list of possible return values might be incomplete.

Related

DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

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


Function DriveMapAdd

Function Reference

DriveMapAdd

Maps a network drive.

DriveMapAdd( "device", "remote share" [, flags [, "user" [, "password"]]] )

Parameters

device | 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.
remote share | The remote share to connect to in the form "\\server\share".
flags | [optional] A combination of the following: 0 = default 1 = Persistant mapping 8 = Show authentication dialog if required
user | [optional] The username to use to connect. In the form "username" or "domain\username".
password | [optional] The password to use to connect.

Return Value

Success: | Returns 1. (See Remarks)
Failure: | Returns 0 if a new mapping could not be created and sets @error (see below). (See Remarks)

Remarks

When the function fails (returns 0) @error contains extended information:
1 = Undefined / Other error
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.

Related

DriveMapDel, DriveMapGet

Example

; 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 DriveMapDel

Function Reference

DriveMapDel

Disconnects a network drive.

DriveMapDel( "device" )

Parameters

drive The device to disconnect, e.g. "O:" or "LPT1:".

Return Value

Success: | Returns 1.
Failure: | Returns 0 if the disconnection was unsuccessful.

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

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

; Disconnect
DriveMapDel("X:")


Function DriveMapGet

Function Reference

DriveMapGet

Retreives the details of a mapped drive.

DriveMapGet( "device" )

Parameters

device The device (drive or printer) letter to query. Eg. "O:" or "LPT1:"

Return Value

Success: | Returns details of the mapping, e.g. \\server\share
Failure: | Returns a blank string "" and sets @error to 1.

Remarks

None.

Related

DriveMapAdd, DriveMapDel

Example

; 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 DriveSetLabel

Function Reference

DriveSetLabel

Sets the Volume Label of a drive.

DriveSetLabel ( "path", "label" )

Parameters

path | Path of drive to change.
label | New volume label for the drive. (11 characters is usually max length)

Return Value

Success: | Returns 1.
Failure: | Returns 0.

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

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


Function DriveSpaceFree

Function Reference

DriveSpaceFree

Returns the free disk space of a path in Megabytes.

DriveSpaceFree ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | Returns free disk space in Megabytes as a float number.
Failure: | Returns numeric 1 and sets @error to 1.

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

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


Function DriveSpaceTotal

Function Reference

DriveSpaceTotal

Returns the total diskspace of a path in Megabytes.

DriveSpaceTotal ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Success: | Returns diskspace in Megabytes as a float number.
Failure: | Sets @error to 1.

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

Example

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


Function DriveStatus

Function Reference

DriveStatus

Returns the status of the drive as a string.

DriveStatus ( "path" )

Parameters

path Path of drive to receive information from.

Return Value

Return Value | Interpretation
UNKNOWN | Drive may be unformatted (RAW).
READY | Typical of hard drives and drives that contain removable media.
NOTREADY | Typical of floppy and CD drives that do not contain media.
INVALID | May indicate the drive letter does not exist or that a mapped network drive is inaccessible.

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

Example

$var = DriveStatus( "c:\" )
MsgBox(4096,"Status",$var)


Function FileChangeDir

Function Reference

FileChangeDir

Changes the current working directory.

FileChangeDir ( "path" )

Parameters

path The path to make the current working directory.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if working directory not changed.

Remarks

None.

Related

@WorkingDir

Example

FileChangeDir("C:\Windows")


Function FileClose

Function Reference

FileClose

Closes a previously opened text file.

FileClose ( filehandle )

Parameters

filehandle The handle of a file, as returned by a previous call to FileOpen.

Return Value

None.

Remarks

If filehandle is invalid, an AutoIt runtime error will be thrown, and the script will terminate!
Upon termination, AutoIt automatically closes any files it opened--but calling FileClose is still a good idea.

This function is also used to close search handles as returned by FileFindFirstFile().

Related

FileFindFirstFile, FileOpen

Example

$handle = FileOpen("test.txt", 0)

FileClose($handle)


Function FileCopy

Function Reference

FileCopy

Copies one or more files.

FileCopy ( "source", "dest" [, flag] )

Parameters

source | The source path of the file(s) to copy. Wildcards are supported.
dest | The destination path of the copied file(s).
flag | [optional] this flag determines whether to overwrite files if they already exist: 0 = (default) do not overwrite existing files 1 = overwrite existing files

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

The destination directory must already exist.
See FileFindFirstFile for a discussion of wildcards.

Related

FileMove, FileDelete, DirCopy

Example

FileCopy("C:\*.au3", "D:\mydir\*.*")

; method to copy a folder (with its contents)
DirCreate("C:\new")
FileCopy("C:\old\*.*", "C:\new\")


Function FileCreateShortcut

Function Reference

FileCreateShortcut

Creates a shortcut (.lnk) to a file.

FileCreateShortcut ( "file", "lnk" [, "workdir" [, "args" [, "desc" [, "icon" [, "hotkey" [, icon number [, state]]]]]]] )

Parameters

file | Full path and file name of file to create shortcut to.
lnk | Full path and file name of the shortcut.
workdir | [optional] Working directory.
args | [optional] Additional file arguments.
desc | [optional] File Description.
icon | [optional] Full Path/File name of icon to use.
hotkey | [optional] Hotkey - same as the Send() key format.
icon number | [optional] The icon instance to use (usually 0)
state | [optional] The state the shortcut is launched in. Use either @SW_SHOWNORMAL, @SW_SHOWMINNOACTIVE or @SW_SHOWMAXIMIZED

Return Value

Success: | Returns 1.
Failure: | Returns 0 if lnk cannot be created.

Remarks

Hotkeys for windows shortcuts are of the following form: Ctrl+Alt+X, Ctrl+Shift+X, Shift+Alt+X, Ctrl+NumPadKey, or Alt+NumPadKey where X represents a letter, number, punctuation, or function key. If you specify an invalid form, Windows typically defaults to Ctrl+Alt
Note that Windows distinguishes number pad keys from regular number and punctuation keys. FileCreateShortcut allows you to create Ctrl+X and Alt+X shortcuts (which Windows normally only allows when X is a NumPadKey); however, you should avoid these assignments as they may conflict with standard application hotkeys.
Windows prohibits ESC, ENTER, TAB, SPACEBAR, PRINT SCREEN, SHIFT, or BACKSPACE from being used in hotkeys.

FileCreateShortcut does not require a valid target, workdir, icon, or hotkey in order to "successfully" create the LNK file; however, the destination of the LNK file must be valid! If the hotkey you choose is already in use, your new shortcut takes precedence. Also, if you create a shortcut with the same path\name as as a pre-existing shortcut, it gets overwritten with your new version.

Related

FileGetShortcut

Example

; Sets a shortcut with ctrl+alt+t hotkey
FileCreateShortcut(@WindowsDir & "\Explorer.exe",@DesktopDir & "\Shortcut Test.lnk",@WindowsDir,"/e,c:\", "This is an Explorer link;-)", @SystemDir & "\shell32.dll", "^!t", "15", @SW_MINIMIZE)


Function FileDelete

Function Reference

FileDelete

Delete one or more files.

FileDelete ( "path" )

Parameters

Path The path of the file(s) to delete. Wildcards are supported.

Return Value

Success: | Return 1.
Failure: | Returns 0 if files are not deleted or do not exist.

Remarks

See FileFindFirstFile for a discussion of wildcards.

Related

FileCopy, FileMove, FileRecycle, DirRemove

Example

FileDelete("D:\*.tmp")


Function FileExists

Function Reference

FileExists

Checks if a file or directory exists.

FileExists ( "path" )

Parameters

Path The directory or file to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if path/file does not exist.

Remarks

FileExists returns 0 if you specify a floppy drive which does not contain a disk.

Related

FileGetAttrib, DriveStatus

Example

If FileExists("D:\") Then
MsgBox(4096, "", "D: exists.")
Else
MsgBox(4096,"", "D: does not exist.")
EndIf


Function FileFindFirstFile

Function Reference

FileFindFirstFile

Returns a filename according to search string.

FileFindFirstFile ( "filename" )

Parameters

filename File search string. (* and ? wildcards accepted)

Return Value

Success: | Returns a search "handle" or use with subsequent FileFindNextFile functions.
Failure: | Returns -1 if error occurs.

Remarks

The search string is not case sensitive.
Wildcards: In general, * denotes zero or more characters, and ? denotes zero or one character. If your file search string contains only wildcards (or is "*.*"), then see the example below for the return value!

When you have finished searching with the FileFind... functions you must call FileClose() to release the search handle.

Related

FileClose, FileFindNextFile

Example

; Shows the filenames of all files in the current directory, note that "." and ".." are returned.
$search = FileFindFirstFile("*.*")

; Check if the search was successful
If $search = -1 Then
MsgBox(0, "Error", "No files/directories matched the search pattern")
Exit
EndIf

While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop

MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)


Function FileFindNextFile

Function Reference

FileFindNextFile

Returns a filename according to a previous call to FileFindFirstFile.

FileFindNextFile ( search )

Parameters

search The search handle, as returned by FileFindFirstFile.

Return Value

Success: | Returns a filename according to a previous call to FileFindFirstFile.
Failure: | Sets @error to 1 if no more files/directories match the search.

Remarks

A previous call to FileFindFirstFile is necessary to setup the search and get a search handle. Every subsequent call to FileFindNextFile will return the next file found according to the search string supplied to FileFindFirstFile. When @error = 1, no more files found matching the original search string.

When you have finished searching with the FileFind... functions you must call FileClose() to release the search handle.

Related

FileClose, FileFindFirstFile

Example

; Shows the filenames of all files in the current directory
$search = FileFindFirstFile("*.*")

; Check if the search was successful
If $search = -1 Then
MsgBox(0, "Error", "No files/directories matched the search pattern")
Exit
EndIf

While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop

MsgBox(4096, "File:", $file)
WEnd

; Close the search handle
FileClose($search)


Function FileGetAttrib

Function Reference

FileGetAttrib

Returns a code string representing a file's attributes.

FileGetAttrib ( "filename" )

Parameters

filename Filename (or directory) to check.

Return Value

Success: | Returns a code string representing a files attributes.
Failure: | Returns empty string and sets @error to 1.

Remarks

String returned could contain a combination of these letters "RASHNDOCT":
"R" = READONLY
"A" = ARCHIVE
"S" = SYSTEM
"H" = HIDDEN
"N" = NORMAL
"D" = DIRECTORY
"O" = OFFLINE
"C" = COMPRESSED (NTFS compression, not ZIP compression)
"T" = TEMPORARY

Related

FileGetTime, FileSetAttrib

Example

$attrib = FileGetAttrib(@HomeDrive & "\boot.ini")
If @error Then
MsgBox(4096,"Error", "Could not obtain attributes.")
Exit
Else
If StringInStr($attrib, "R") Then
MsgBox(4096,"", "File is read-only.")
EndIf
EndIf

; Display full attribute information in text form
; Arrays rely upon the fact that each capital letter is unique
; Figuring out how this works is a good string exercise...
$input = StringSplit("R,A,S,H,N,D,O,C,T",",")
$output = StringSplit("Read-only /, Archive /, System /, Hidden /, _
Normal /, Directory /, Offline /, Compressed /, Temporary /", ",")
For $i = 1 to 9
$attrib = StringReplace($attrib, $input[$i], $output[$i], 0, 1)
; last parameter in StringReplace means case-sensitivity
Next
$attrib = StringTrimRight($attrib, 2) ;remove trailing slash
MsgBox(0,"Full file attributes:", $attrib)


Function FileGetLongName

Function Reference

FileGetLongName

Returns the long path+name of the path+name passed.

FileGetLongName ( "file" )

Parameters

file full path and file name to convert

Return Value

Success: | Returns the long path+name of the path+name passed.
Failure: | Returns the parameter and sets @error to 1.

Remarks

None.

Related

FileGetShortName

Example

$a = FileGetLongName("C:\PROGRA~1\")
;$a is probably "C:\Program Files"


Function FileGetShortcut

Function Reference

FileGetShortcut

Retrieves details about a shortcut.

FileGetShortcut ( "lnk" )

Parameters

lnk Full path and file name of the shortcut.

Return Value

Success: | Returns an array that contains the shortcut information. See Remarks.
Failure: | Sets @error to 1 if the shortcut could not be accessed.

Remarks

The array returned from this function is a single dimension array containing the following elements:
$array[0] = Shortcut target path
$array[1] = Working directory
$array[2] = Arguments
$array[3] = Description
$array[4] = Icon filename
$array[5] = Icon index
$array[6] = The shortcut state (@SW_SHOWNORMAL, @SW_SHOWMINNOACTIVE, @SW_SHOWMAXIMIZED)

Related

FileCreateShortcut

Example

; Sets a shortcut with ctrl+alt+t hotkey
FileCreateShortcut(@WindowsDir & "\Explorer.exe",@DesktopDir & "\Shortcut Test.lnk",@WindowsDir,"/e,c:\", "This is an Explorer link;-)", @SystemDir & "\shell32.dll", "^!t", "15", @SW_MINIMIZE)

; Read in the path of a shortcut
$details = FileGetShortcut(@DesktopDir & "\Shortcut Test.lnk")
MsgBox(0, "Path:", $details[0])


Function FileGetShortName

Function Reference

FileGetShortName

Returns the 8.3 short path+name of the path+name passed.

FileGetShortName ( "file" )

Parameters

file full path and file name to convert

Return Value

Success: | Returns the 8.3 short path+name of the path+name passed.
Failure: | Returns the parameter and sets @error to 1.

Remarks

None.

Related

FileGetLongName

Example

$a = FileGetShortName("C:\Program Files")
;$a is probably "C:\PROGRA~1"


Function FileGetSize

Function Reference

FileGetSize

Returns the size of a file in bytes.

FileGetSize ( "filename" )

Parameters

filename Filename to check.

Return Value

None.

Remarks

Does not work on directories.
Divide result by 1024 to get kilobyte equivalent, or divide by 1048576 to get megabyte equivalent.

Related

FileGetAttrib, FileGetTime, DriveSpaceTotal

Example

$size = FileGetSize("AutoIt.exe")


Function FileGetTime

Function Reference

FileGetTime

Returns the time and date information for a file.

FileGetTime ( "filename" [, option [, format]] )

Parameters

filename | Filename to check.
option | [optional] Flag to indicate which timestamp 0 = Modified (default) 1 = Created 2 = Accessed
format | [optional] to specify type of return 0 = return an array (default) 1 = return a string YYYYMMDDHHMMSS

Return Value

Success: | Returns an array or string that contains the file time information. See Remarks.
Failure: | Returns numeric 1 and sets @error to 1.

Remarks

The array is a single dimension array containing six elements:
$array[0] = year (four digits)
$array[1] = month (range 01 - 12)
$array[2] = day (range 01 - 31)
$array[3] = hour (range 00 - 23)
$array[4] = min (range 00 - 59)
$array[5] = sec (range 00 - 59)
Notice that return values are zero-padded.

Related

FileGetSize, FileGetAttrib, FileGetVersion, FileSetTime

Example

$t = FileGetTime(@Windowsdir & "\Notepad.exe", 1)

If Not @error Then
$yyyymd = $t[0] & "/" & $t[1] & "/" & $t[2]
MsgBox(0, "Creation date of notepad.exe", $yyyymd)
EndIf


Function FileGetVersion

Function Reference

FileGetVersion

Returns the "File" version information.

FileGetVersion ( "filename" )

Parameters

filename Filename to check.

Return Value

Success: | Returns a string containing the version information, eg "3.0.81.0".
Failure: | Returns "0.0.0.0" if no version information (or other error), and sets @error to 1.

Remarks

None.

Related

FileGetSize, FileGetTime

Example

$ver = FileGetVersion("Explorer.exe")
MsgBox(0, "Explorer version", $ver)


Function FileInstall

Function Reference

FileInstall

Include and install a file with the compiled script.

FileInstall ( "source", "dest" [, flag] )

Parameters

source | The source path of the file to compile. This must be a literal string; it cannot be a variable.
dest | The destination path with trailing backslash. This can be a variable.
flag | [optional] this flag determines whether to overwrite files if they already exist: 0 = (default) do not overwrite existing files 1 = overwrite existing files

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

The FileInstall function is designed to include files into a compiled AutoIt script. These included files can then be "extracted" during execution of the compiled script. Keep in mind that files such as images can greatly increase the size of a compiled script.
The source file must be a string and not a variable so that the compiler can extract the filename to include. The source cannot contain wildcards.

When this function is used from a non-compiled script, a copy operation is performed instead (to allow for easy testing pre-compilation).
Files maintain their original creation/modification timestamps when installed.

Related

#Include

Example

FileInstall("C:\test.au3", "D:\mydir\test.au3")


Function FileMove

Function Reference

FileMove

Moves one or more files

FileMove ( "source", "dest" [, flag] )

Parameters

source | The source path and filename of the file to move. (* wildcards are supported)
dest | The destination path and filename of the moved file. (* wildcards are supported)
flag | [optional] this flag determines whether to overwrite files if they already exist: 0 = (default) do not overwrite existing files 1 = overwrite existing files

Return Value

Success: | Returns 1.
Failure: | Returns 0 if source cannot be moved or if dest already exists and flag=0.

Remarks

If the source and destination paths are on different volumes a copy and delete operation is performed rather than a move.

Because AutoIt lacks a "FileRename" function, use FileMove to rename a file!

Related

FileCopy, FileDelete, FileRecycle, DirMove

Example

FileMove("C:\foo.au3", "D:\mydir\bak.au3")


Function FileOpen

Function Reference

FileOpen

Opens a text file for reading or writing.

FileOpen ( "filename", mode )

Parameters

filename | Filename of the text file to open.
mode | Mode (read or write) to open the file in. 0 = Read mode 1 = Write mode (append to end of file) 2 = Write mode (erase previous contents) Both write modes will create the file if it does not already exist.

Return Value

Success: | Returns a file "handle" or use with subsequent file functions.
Failure: | Returns -1 if error occurs.

Remarks

Up to 64 files can be open simultaneously by one AutoIt script. Exceeding this limit throws a run-time error and
A file can only be in either read or write mode; it cannot be in both.
When opening a file in write mode, the file will be created if it does not exist.
When finished working with a file, call the FileClose function to close the file. Autoit normally closes all files upon termination, but explicitly calling FileClose is still a good idea.

Related

FileClose, FileReadLine, FileWriteLine, FileRead

Example

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

FileClose($file)


Function FileOpenDialog

Function Reference

FileOpenDialog

Initiates a Open File Dialog.

FileOpenDialog ( "title", "init dir", "filter" [, options [, "default name"]] )

Parameters

title | Title text of the Dialog GUI.
init dir | Initial directory selected in the GUI file tree.
filter | File type filter such as "All (*.*)" or "Text files (*.txt)"
options | [optional] Dialog Options: To use more than one option, add the required values together. 1 = File Must Exist (if user types a filename) 2 = Path Must Exist (if user types a path) 4 = Allow MultiSelect 8 = Prompt to Create New File (if does not exist) 16 = Prompt to OverWrite File (see FileSaveDialog)
default name | [optional] Suggested file name for the user to open.

Return Value

Success: | Returns the full path of the file(s) chosen. Results for multiple selections are "Directory|file1|file2|..."
Failure: | Sets @error to 1.

Remarks

Separate the file filters with a semicolon as shown in the example.
Note: At this time, multiple groups of filters are not supported.

If default name is given, options must also be given. If none of the options are wanted, use 0 for options.

Special Windows folders (such as "My Documents") can be sometimes be set as the init dir; see Appendix.

Related

FileSaveDialog, FileSelectFolder, StringSplit

Example

$message = "Hold down Ctrl or Shift to choose multiple files."

$var = FileOpenDialog($message, "C:\Windows\", "Images (*.jpg;*.bmp)", 1 + 4 )

If @error Then
MsgBox(4096,"","No File(s) chosen")
Else
$var = StringReplace($var, "|", @CRLF)
MsgBox(4096,"","You chose " & $var)
EndIf


Function FileRead

Function Reference

FileRead

Read in a number of characters from a previously opened text file.

FileRead ( filehandle or "filename", count )

Parameters

filehandle | The handle of a file, as returned by a previous call to FileOpen. Alternatively you may use a string filename as the first parameter.
count | The number of characters to read.

Return Value

Success: | Returns the characters read.
Special: | Sets @error to -1 if end-of-file is reached.
Failure: | Sets @error to 1 if file not opened in read mode or other error.

Remarks

If a filename is given rather than a file handle - the file will be opened and closed during the function call - for parsing large text files this will be much slower than using filehandles.
Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function. Use either filehandles or filenames in your routines--not both!

Related

IniRead, FileClose, FileOpen, FileReadLine, FileWrite, FileWriteLine

Example

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

; Read in 1 character at a time until the EOF is reached
While 1
$chars = FileRead($file, 1)
If @error = -1 Then ExitLoop
MsgBox(0, "Char read:", $chars)
Wend

FileClose($file)


Function FileReadLine

Function Reference

FileReadLine

Read in a line of text from a previously opened text file.

FileReadLine ( filehandle or "filename" [, line] )

Parameters

filehandle | The handle of a file, as returned by a previous call to FileOpen. Alternatively you may use a string filename as the first parameter.
line | [optional] The line number to read. The first line of a text file is line 1 (not zero).

Return Value

Success: | Returns a line of text.
Special: | Sets @error to -1 if end-of-file is reached.
Failure: | Sets @error to 1 if file not opened in read mode or other error.

Remarks

Returns the text of the line read, any newline characters ( CHR(10) or @LF ) at the end of a line read in are automatically stripped.
If no line number to read is given, the "next" line will be read. ("Next" for a newly opened file is initially the first line.)
If a filename is given rather than a file handle - the file will be opened and closed during the function call - for parsing large text files this will be much slower than using filehandles.
Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function. Use either filehandles or filenames in your routines--not both!

Related

IniRead, FileClose, FileOpen, FileRead, FileWrite, FileWriteLine

Example

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

; Read in lines of text until the EOF is reached
While 1
$line = FileReadLine($file)
If @error = -1 Then ExitLoop
MsgBox(0, "Line read:", $line)
Wend

FileClose($file)


Function FileRecycle

Function Reference

FileRecycle

Sends a file or directory to the recycle bin.

FileRecycle ( "source" )

Parameters

source The source path of the file(s) or directory to Recycle. Wildcards are supported.

Return Value

Success: | Returns 1.
Failure: | Returns 0 (typically meaning the file is use or does not exist).

Remarks

See FileFindFirstFile for a discussion of wildcards.
To remove a directory, simply give the path without a trailing backslash.

Related

FileDelete, FileRecycleEmpty

Example

FileRecycle("C:\*.tmp")


Function FileRecycleEmpty

Function Reference

FileRecycleEmpty

Empties the recycle bin.

FileRecycleEmpty ( ["drive"] )

Parameters

source [optional] The drive letter to empty - if omitted the recycle bin for all drives is emptied.

Return Value

Success: | Returns 1.
Failure: | Returns 0 (the bin cannot be emptied - see below).

Remarks

For this function to work IE4+ must be available.

Related

FileDelete, FileRecycle

Example

FileRecycleEmpty("C:\")


Function FileSaveDialog

Function Reference

FileSaveDialog

Initiates a Save File Dialog.

FileSaveDialog ( "title", "init dir", "filter" [, options [, "default name"]] )

Parameters

title | Title text of the Dialog GUI.
init dir | Initial directory selected in the GUI file tree.
filter | File type filter such as "All (*.*)" or "Text files (*.txt)"
options | [optional] 1 = File Must Exist (if user types a filename) 2 = Path Must Exist (if user types a path) 4 = Allow MultiSelect 8 = Prompt to Create New File (if does not exist) 16 = Prompt to OverWrite File
default name | [optional] File name to suggest to the user to save the file with.

Return Value

Success: | Returns the full path of the file chosen. Results for multiple selections are "Directory|file1|file2|..."
Failure: | Sets @error to 1.

Remarks

Separate the file filters with a semicolon as shown in the example.
Note: At this time, multiple groups of filters are not supported.

If default name is given, options must also be given. If none of the options are wanted, use 0 for options.

Special Windows folders (such as "My Documents") can be sometimes be set as the init dir; see Appendix.

Related

FileOpenDialog, FileSelectFolder

Example

$MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"

$var = FileSaveDialog( "Choose a name.", $MyDocsFolder, "Scripts (*.aut;*.au3)", 3)
; option 3 = dialog remains until valid path/file selected

If @error Then
MsgBox(4096,"","Save cancelled.")
Else
MsgBox(4096,"","You chose " & $var)
EndIf


Function FileSelectFolder

Function Reference

FileSelectFolder

Initiates a Browse For Folder GUI.

FileSelectFolder ( "dialog text", "root dir" [, flag [, "initial dir"]] )

Parameters

dialog text | Text greeting in dialog.
root dir | Root directory of GUI file tree. Use "" for Desktop to be root.
flag | [optional] 1 = Show Create Folder Button (requires IE6.0 or later) 2 = Use New Dialog Style (requires IE5.0 or later) 4 = Show Edit Control (to type a foldername)
initial dir | Initial/start directory that will be selected if exist.

Return Value

Success: | Returns full path of the folder chosen.
Failure: | Returns a blank string and sets @error to 1 if user cancels/closes the window.

Remarks

The root dir will be chosen if the inital dir (if given) does not exist.
A nonexistent root dir will also cause the Desktop folder to be root.
The "Create Folder Button" option may require Windows XP with IE6 in order to work.
Special Windows folders (such as "My Documents") can be set at root by using the right CLSID detailed in the Appendix.

Related

FileSaveDialog, FileOpenDialog

Example

$var = FileSelectFolder("Choose a folder.", "")


Function FileSetAttrib

Function Reference

FileSetAttrib

Sets the attributes of one or more files.

FileSetAttrib ( "file pattern", "+-RASHNOT" [, recurse] )

Parameters

file pattern | File(s) to change, e.g. C:\*.au3, C:\Dir
+-RASHNOT | Attribute(s) to set/clear. e.g. "+A", "+RA-SH"
recurse | [optional] If this is set to 1, then directories are recursed into. Default is 0 (no recursion).

Return Value

Success: | Returns 1.
Failure: | Returns 0 if encountered any errors.

Remarks

The file pattern cannot contain spaces!
The attributes that can be modified with the function are + or -:
"R" = READONLY
"A" = ARCHIVE
"S" = SYSTEM
"H" = HIDDEN
"N" = NORMAL
"O" = OFFLINE
"T" = TEMPORARY

(Note that you cannot set the compressed/directory attributes with this function.)

Related

FileGetAttrib, FileGetTime, FileSetTime

Example

;mark all .au3 files in current directory as read-only and system
FileSetAttrib("*.au3", "+RS")
If @error Then MsgBox(4096,"Error", "Problem setting attributes."

;make all .bmp files in C:\ and sub-directories writable and archived
FileSetAttrib("C:\*.bmp", "-R+A", 1)
If @error Then MsgBox(4096,"Error", "Problem setting attributes."


Function FileSetTime

Function Reference

FileSetTime

Sets the timestamp of one of more files.

FileSetTime ( "file pattern", "time", type [, recurse] )

Parameters

file pattern | File(s) to change, e.g. C:\*.au3, C:\Dir
time | The new time to set in the format "YYYYMMDDHHMMSS" (Year, month, day, hours (24hr clock), seconds). If the time is blank "" then the current time is used.
type | The timestamp to change: 0 = Modified, 1 = Created, 2 = Accessed
recurse | [optional] If this is set to 1, then directories are recursed into. Default is 0 (no recursion).

Return Value

Success: | Returns 1.
Failure: | Returns 0 if error changing timestamp(s).

Remarks

Under Windows 9x you cannot change the timestamp of a directory; attempts to do so are ignored.

Related

FileGetTime, FileGetAttrib, FileSetAttrib

Example

;change file.au3's "modified" timestamp to 1st Nov 2003 and current time
$var = FileSetTime("file.au3", "20031101")


Function FileWrite

Function Reference

FileWrite

Append a line of text to the end of a previously opened text file.

FileWrite ( filehandle or "filename", "line" )

Parameters

filehandle | The handle of a file, as returned by a previous call to FileOpen. Alternatively, you may use a string filename as the first parameter.
line | The line of text to write to the text file. The line is written as is - no @CR or @LF characters are added.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if file not opened in writemode, file is read only, or file cannot otherwise be written to.

Remarks

The text file must be opened in write mode or the FileWrite command will fail.

If a filename is given rather than a file handle, the file will be opened and closed during the function call. For parsing large text files this will be much slower than using filehandles. However, filename will be created if it does not already exist.

Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function.Either use filehandles or filenames in your routines--not both.

Related

FileClose, FileOpen, FileRead, FileReadLine, FileWriteLine

Example

$file = FileOpen("test.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

FileWrite($file, "Line1")
FileWrite($file, "Still Line1" & @CRLF)
FileWrite($file, "Line2")

FileClose($file)


Function FileWriteLine

Function Reference

FileWriteLine

Append a line of text to the end of a previously opened text file.

FileWriteLine ( filehandle or "filename", "line" )

Parameters

filehandle | The handle of a file, as returned by a previous call to FileOpen. Alternatively, you may use a string filename as the first parameter.
line | The line of text to write to the text file. If the line does NOT end in @CR or @LF then a DOS linefeed (@CRLF) will be automatically added.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if file not opened in writemode, file is read only, or file cannot otherwise be written to.

Remarks

The text file must be opened in write mode or the FileWriteLine command will fail.

If a filename is given rather than a file handle, the file will be opened and closed during the function call. For parsing large text files this will be much slower than using filehandles. However, filename will be created if it does not already exist.

Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function.Either use filehandles or filenames in your routines--not both.

Related

FileClose, FileOpen, FileRead, FileReadLine, FileWrite

Example

$file = FileOpen("test.txt", 1)

; Check if file opened for writing OK
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf

FileWriteLine($file, "Line1")
FileWriteLine($file, "Line2" & @CRLF)
FileWriteLine($file, "Line3")

FileClose($file)


Function IniDelete

Function Reference

IniDelete

Deletes a value from a standard format .ini file.

IniDelete ( "filename", "section" [, "key"] )

Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.
key | [optional] The key name in the in the .ini file to delete. If the key name is not given the entire section is deleted.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if section/key is not found or if INI file is read-only.

Remarks

A standard ini file looks like:
[SectionName]
Key=Value
If filename is not found, a 0 byte file is created.

Related

IniRead, IniWrite, IniReadSection, IniReadSectionNames

Example

IniDelete("C:\Temp\myfile.ini", "section2", "key")


Function IniRead

Function Reference

IniRead

Reads a value from a standard format .ini file.

IniRead ( "filename", "section", "key", "default" )

Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.
key | The key name in the in the .ini file.
default | The default value to return if the requested key is not found.

Return Value

Success: | Returns the requested key value.
Failure: | Returns the default string if requested key not found.

Remarks

A standard ini file looks like:
[SectionName]
Key=Value

Related

IniDelete, IniWrite, FileReadLine, IniReadSection, IniReadSectionNames

Example

$var = IniRead("C:\Temp\myfile.ini", "section2", "key", "NotFound")
MsgBox(4096, "Result", $var)


Function IniReadSection

Function Reference

IniReadSection

Reads all key/value pairs from a section in a standard format .ini file.

IniReadSection ( "filename", "section" )

Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.

Return Value

Success: | Returns a 2 dimensional array where element[n][0] is the key and element[n][1] is the value.
Failure: | Sets @error on failure:
 | 1 if unable to read the section (The INI file may not exist or the section may not exist)
 | 2 if the section was empty, didn't exist, or no standard format data could be found

Remarks

A standard ini file looks like:
[SectionName]
Key=Value

The number of elements returned will be in $result[0][0]. If an @error occurs, no array is created.

Related

IniDelete, IniWrite, FileReadLine, IniRead, IniReadSectionNames

Example

$var = IniReadSection("C:\Temp\myfile.ini", "section2")
If @error Then
MsgBox(4096, "", "Error occured, probably no INI file.")
Else
For $i = 1 To $var[0][0]
MsgBox(4096, "", "Key: " & $var[$i][0] & @CRLF & "Value: " & $var[$i][1])
Next
EndIf


Function IniReadSectionNames

Function Reference

IniReadSectionNames

Reads all sections in a standard format .ini file.

IniReadSectionNames ( "filename" )

Parameters

filename The filename of the .ini file.

Return Value

Success: | Returns an array of all section names in the INI file.
Failure: | Sets @error on failure.

Remarks

A standard ini file looks like:
[SectionName]
Key=Value

The number of elements returned will be in $result[0]. If an @error occurs, no array is created.

Related

IniDelete, IniWrite, FileReadLine, IniRead, IniReadSection

Example

$var = IniReadSectionNames(@WindowsDir & "\win.ini")
If @error Then
MsgBox(4096, "", "Error occured, probably no INI file.")
Else
For $i = 1 To $var[0]
MsgBox(4096, "", $var[$i])
Next
EndIf


Function IniWrite

Function Reference

IniWrite

Writes a value to a standard format .ini file.

IniWrite ( "filename", "section", "key", "value" )

Parameters

filename | The filename of the .ini file.
section | The section name in the .ini file.
key | The key name in the in the .ini file.
value | The value to write/change.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if file is read-only.

Remarks

A standard ini file looks like:
[SectionName]
Key=Value
If file does not exist, it is created. Keys and/or sections are added to the end and are not sorted in any way.

Related

IniDelete, IniRead, FileWriteLine, IniReadSection, IniReadSectionNames

Example

IniWrite("C:\Temp\myfile.ini", "section2", "key", "this is a new value")


Function AutoItSetOption

Function Reference

AutoItSetOption

Changes the operation of various AutoIt functions/parameters.

AutoItSetOption ( "option", param )

Parameters

option | The option to change. See Remarks.
param | The parameter (varies by option). See Remarks.

Return Value

Returns the value of the previous setting.

Remarks

You may use Opt() as an alternative to AutoItSetOption().

AutoIt will halt with an error message if the requested option is unknown. Options are as follows:
Option | Param
CaretCoordMode | Sets the way coords are used in the caret functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = absolute screen coordinates (default) 2 = relative coords to the client area of the active window
ColorMode | Sets the way colors are defined, either RGB or BGR. RGB is the default but in previous versions of AutoIt (pre 3.0.102) BGR was the default: 0 = Colors are defined as RGB (0xRRGGBB) (default) 1 = Colors are defined as BGR (0xBBGGRR) (the mode used in older versions of AutoIt)
ExpandEnvStrings | Changes how literal strings and % symbols are interpreted. By default strings are treated literally, this option allows you to use %environment% variables inside strings, e.g., "The temp directory is: %temp%". 1 = expand environment variables (similar to AutoIt v2) 0 = do not expand environment variables (default) Without this option the usual way would be: "The temp directory is: " & EnvGet("temp")
ExpandVarStrings | Changes how literal strings and variable/macro ($ and @) symbols are interpreted. By default strings are treated literally, this option allows you to use variables and macros inside strings, e.g., "The value of var1 is $var1$". 1 = expand variables (when in this mode and you want to use a literal $ or @ then double it up: "This is a single dollar $$ sign". 0 = do not expand variables (default)
FtpBinaryMode | Changes how FTP files are transferred. 1 = Binary (default) 0 = ASCII
GUICloseOnESC | When ESC is pressed on a GUI the $GUI_EVENT_CLOSE message is sent. This option toggles this behavior on and off. 1 = Send the $GUI_EVENT_CLOSE message when ESC is pressed (default). 0 = Don't send the $GUI_EVENT_CLOSE message when ESC is pressed.
GUICoordMode | Alters the position of a control defined by GUICtrlSetPos. 1 = absolute coordinates (default) still relative to the dialog box. 0 = relative position to the start of the last control (upper left corner) 2 = cell positionining relative to current cell. A -1 for left or top parameter don't increment the start. So next line is -1,0; next cell is 0,-1; current cell is -1,-1
GUIOnEventMode | Enable/disable OnEvent functions notifications. 0 = (default) disable. 1 = enable.
GUIResizeMode | Change default resizing for a control. 0 = (default) no resizing. <1024 = anytype of resizing see GUICtrlSetResizing.
MouseClickDelay | Alters the length of the brief pause in between mouse clicks. Time in milliseconds to pause (default=10).
MouseClickDownDelay | Alters the length a click is held down before release. Time in milliseconds to pause (default=10).
MouseClickDragDelay | Alters the length of the brief pause at the start and end of a mouse drag operation. Time in milliseconds to pause (default=250).
MouseCoordMode | Sets the way coords are used in the mouse functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = absolute screen coordinates (default) 2 = relative coords to the client area of the active window
MustDeclareVars | If this option is used then all variables must be pre-declared with Dim, Local or Global before they can be used - removes the chance for misspelled variables causing bugs. 1 = Variables must be pre-declared 0 = Variables don't need to be pre-declared (default)
OnExitFunc | Sets the name of the function called when AutoIt exits (default is OnAutoItExit).
PixelCoordMode | Sets the way coords are used in the pixel functions, either absolute coords or coords relative to the current active window: 0 = relative coords to the active window 1 = absolute screen coordinates (default) 2 = relative coords to the client area of the active window
RunErrorsFatal | Sets if the script should terminate with a fatal error if a Run/RunWait function fails due to bad paths/file not found/Bad login IDs: 1 = fatal error (default) 0 = silent error (@error set to 1)
SendAttachMode | Specifies if AutoIt attaches input threads when using then Send() function. When not attaching (default mode=0) detecting the state of capslock/scrolllock and numlock can be unreliable under NT4. However, when you specify attach mode=1 the Send("{... down/up}") syntax will not work and there may be problems with sending keys to "hung" windows. ControlSend() ALWAYS attaches and is not affected by this mode. 0 = don't attach (default) 1 = attach
SendCapslockMode | Specifies if AutoIt should store the state of capslock before a Send function and restore it afterwards. 0 = don't store/restore 1 = store and restore (default)
SendKeyDelay | Alters the the length of the brief pause in between sent keystrokes. Time in milliseconds to pause (default=5). Sometimes a value of 0 does not work; use 1 instead.
SendKeyDownDelay | Alters the length of time a key is held down before released during a keystroke. For applications that take a while to register keypresses (and many games) you may need to raise this value from the default. Time in milliseconds to pause (default=1).
TrayIconDebug | If enabled shows the current script line in the tray icon tip to help debugging. 0 = no debug information (default) 1 = show debug
TrayIconHide | Hides the AutoIt tray icon. Note: The icon will still initially appear ~750 milliseconds. 0 = show icon (default) 1 = hide icon
WinDetectHiddenText | Specifies if hidden window text can be "seen" by the window matching functions. 0 = Do not detect hidden text (default) 1 = Detect hidden text
WinSearchChildren | Allows the window search routines to search child windows as well as top-level windows. 0 = Only search top-level windows (default) 1 = Search top-level and child windows
WinTextMatchMode | Alters the method that is used to match window text during search operations. 1 = Complete / Slow mode (default) 2 = Quick mode In quick mode AutoIt can usually only "see" dialog text, button text and the captions of some controls. In the default mode much more text can be seen (for instance the contents of the Notepad window). If you are having performance problems when performing many window searches then changing to the "quick" mode may help.
WinTitleMatchMode | Alters the method that is used to match window titles during search operations. 1 = Match the title from the start (default) 2 = Match any substring in the title 3 = Exact title match 4 = Advanced mode, see Window Titles & Text (Advanced)
WinWaitDelay | Alters how long a script should briefly pause after a successful window-related operation. Time in milliseconds to pause (default=250).

Related

Many!

Example

; copy any you want to change ;default value is listed first

Opt("CaretCoordMode", 1) ;1=absolute, 0=relative, 2=client
Opt("ColorMode", 0) ;0=RRGGBB color, 1=BBGGRR color
Opt("ExpandEnvStrings", 0) ;0=don't expand, 1=do expand
Opt("ExpandVarStrings", 0) ;0=don't expand, 1=do expand
Opt("FtpBinaryMode", 1) ;1=binary, 0=ASCII
Opt("GUICloseOnESC", 1) ;1=ESC won't close, 0=ESC closes
Opt("GUICoordMode", 1) ;1=absolute, 0=relative, 2=cell
Opt("GUIOnEventMode", 0) ;0=disabled, 1=OnEvent mode enabled
Opt("GUIResizeMode", 0) ;0=no resizing, <1024 special resizing
Opt("MouseClickDelay", 10) ;10 milliseconds
Opt("MouseClickDownDelay", 10) ;10 milliseconds
Opt("MouseClickDragDelay", 250) ;250 milliseconds
Opt("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client
Opt("MustDeclareVars", 0) ;0=no, 1=require pre-declare
Opt("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client
Opt("RunErrorsFatal", 1) ;1=fatal, 0=silent set @error
Opt("SendAttachMode", 0) ;0=don't attach, 1=do attach
Opt("SendCapslockMode", 1) ;1=store and restore, 0=don't
Opt("SendKeyDelay", 5) ;5 milliseconds
Opt("SendKeyDownDelay", 1) ;1 millisecond
Opt("TrayIconDebug", 0) ;0=no info, 1=debug line info
Opt("TrayIconHide", 0) ;0=show, 1=hide tray icon
Opt("WinWaitDelay", 250) ;250 milliseconds
Opt("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
Opt("WinTextMatchMode", 1) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced
Opt("WinWaitDelay", 250) ;250 milliseconds


Function PixelChecksum

Function Reference

PixelChecksum

Generates a checksum for a region of pixels.

PixelChecksum ( left, top, right, bottom [, step] )

Parameters

left | left coordinate of rectangle.
top | top coordinate of rectangle.
right | right coordinate of rectangle.
bottom | bottom coordinate of rectangle.
step | [optional] Instead of checksumming each pixel use a value larger than 1 to skip pixels (for speed). E.g. A value of 2 will only check every other pixel. Default is 1.

Return Value

Returns the checksum value of the region.

Remarks

Performing a checksum of a region is very time consuming, so use the smallest region you are able to reduce CPU load. On some machines a checksum of the whole screen could take many seconds!

A checksum only allows you to see if "something" has changed in a region - it does not tell you exactly what has changed.

When using a step value greater than 1 you must bear in mind that the checksumming becomes less reliable for small changes as not every pixel is checked.

Related

PixelChecksum, PixelGetColor, PixelCoordMode (Option), PixelSearch

Example

; Wait until something changes in the region 0,0 to 50,50

; Get initial checksum
$checksum = PixelChecksum(0,0, 50,50)

; Wait for the region to change, the region is checked every 100ms to reduce CPU load
While $checksum = PixelChecksum(0,0, 50, 50)
Sleep(100)
WEnd

MsgBox(0, "", "Something in the region has changed!")


Function PixelGetColor

Function Reference

PixelGetColor

Returns a pixel color according to x,y pixel coordinates.

PixelGetColor ( x , y )

Parameters

x | x coordinate of pixel.
y | y coordinate of pixel.

Return Value

Success: | Returns decimal value of pixel's color.
Failure: | Returns -1 if invalid coordinates.

Remarks

Earlier versions of AutoIt (prior to v3.0.102) used the BGR format for defining color - newer versions use RGB by default but this can be changed using the ColorMode option.

Related

ColorMode (Option), PixelSearch, PixelCoordMode (Option), MouseGetPos

Example

$var = PixelGetColor( 10 , 100 )
MsgBox(0,"The decmial color is", $var)
MsgBox(0,"The hex color is", Hex($var, 6))


Function PixelSearch

Function Reference

PixelSearch

Searches a rectangle of pixels for the pixel color provided.

PixelSearch ( left, top, right, bottom, color [, shade-variation] [, step]] )

Parameters

left | left coordinate of rectangle.
top | top coordinate of rectangle.
right | right coordinate of rectangle.
bottom | bottom coordinate of rectangle.
colour | Colour value of pixel to find (in decimal or hex).
shade-variation | [optional] A number between 0 and 255 to indicate the allowed number of shades of variation of the red, green, and blue components of the colour. Default is 0 (exact match).
step | [optional] Instead of searching each pixel use a value larger than 1 to skip pixels (for speed). E.g. A value of 2 will only check every other pixel. Default is 1.

Return Value

Success: | Returns a two-element array of pixel's coordinates. (Array[0] = x, Array[1] = y)
Failure: | Sets @error to 1 if color is not found.

Remarks

The search is performed top-to-bottom, left-to-right, and the first match is returned.

Earlier versions of AutoIt (prior to v3.0.102) used the BGR format for defining color - newer versions use RGB by default but this can be changed using the ColorMode option.

Performing a search of a region can be time consuming, so use the smallest region you are able to reduce CPU load.

Related

ColorMode (Option), PixelChecksum, PixelGetColor, PixelCoordMode (Option)

Example

; Find a pure red pixel in the range 0,0-20,300
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000 )
If Not @error Then
MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
EndIf

; Find a pure red pixel or a red pixel within 10 shades variations of pure red
$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000, 10 )
If Not @error Then
MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
EndIf


Function SoundPlay

Function Reference

SoundPlay

Play a sound file.

SoundPlay ( "filename" [, wait] )

Parameters

filename | Name of the file to be played (typically a WAV or MP3)
wait | [optional] This flag determines if the script should wait for the sound to finish before continuing: 1 = wait until sound has finished 0 = continue script while sound is playing (default)

Return Value

None. (Always returns 1 regardless of success.)

Remarks

Terminating the script will stop the sound (if it is still playing).

Related

SoundSetWaveVolume

Example

SoundPlay("C:\Windows\media\tada.wav")


Function SoundSetWaveVolume

Function Reference

SoundSetWaveVolume

Sets the system wave volume by percent.

SoundSetWaveVolume ( percent )

Parameters

percent percentage number between 0 and 100

Return Value

Success: | None.
Failure: | Sets @error to 1 if percent is invalid.

Remarks

This controls the Wave volume, not the master volume control. Also, a value of Zero does not set mute status.

Related

SoundPlay

Example

SoundSetWaveVolume(50)


Function GUICreate

Function Reference

GUICreate

Create a GUI window.

GUICreate ( "title" [, width [, height [, left [, top [, style [, exStyle [, parent]]]]]]] )

Parameters

title | The title of the dialog box.
width | [optional] The width of the window.
height | [optional] The height of the window.
left | [optional] The left side of the dialog box. By default (-1), the window is centered. If defined, top must also be defined.
top | [optional] The top of the dialog box. Default (-1) is centered
style | [optional] defines the style of the window. See GUI Control Styles Appendix. Use -1 for the default style which includes a combination of $WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU styles. Some styles are always included: $WS_CLIPSIBLINGS, and $WS_SYSMENU if $WS_MAXIMIZEBOX or $WS_SIZEBOX is specified.
exStyle | [optional] defines the extended style of the window. See the Extended Style Table below. -1 is the default.
parent | [optional] The handle of another previously created window - this new window then becomes a child of that window.

Return Value

Success: | Returns a windows handle.
Failure: | Returns 0 if the window cannot be created and sets @error to 1.

Remarks

By default the dialog box is non sizable and non maximizable. So WS_SIZEBOX or WS_MAXIMIZEBOX can be used in the style parameter.
If WS_SIZEBOX is use the first dialog box will be use as the minimum size and when expanding the control will be automatically position.
As defining only one style just set this style dont forget to combine it with default ones, i.e. just defining WS_SIZEBOX will not set WS_MINIMIZEBOX, WS_CAPTION, WS_POPUP, WS_SYSMENU. So the best case to define a resizeable window is to use WS_OVERLAPPEDWINDOW.

To add styles to default style just BitOr($GUI_SS_DEFAULT_GUI, newstyle,...).

Extended Style table
Extended Style | result
$WS_EX_ACCEPTFILES | Allow an edit or input control within the created GUI window to receive filenames via drag and drop. The control must have also the $GUI_ACCEPTFILES state set by GUICtrlSetState.
$WS_EX_APPWINDOW | Forces a top-level window onto the taskbar when the window is visible.
$WS_EX_CLIENTEDGE | Specifies that a window has a border with a sunken edge.
$WS_EX_CONTEXTHELP | Includes a question mark in the title bar of the window. Cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX.
$WS_EX_DLGMODALFRAME | Creates a window that has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the style parameter.
$WS_EX_OVERLAPPEDWINDOW | Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles.
$WS_EX_STATICEDGE | Creates a window with a three-dimensional border style intended to be used for items that do not accept user input.
$WS_EX_TOPMOST | Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.
$WS_EX_TRANSPARENT | The window appears transparent because the bits of underlying sibling windows have already been painted.
$WS_EX_TOOLWINDOW | Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog box that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by typing ALT+SPACE.
$WS_EX_WINDOWEDGE | Specifies that a window has a border with a raised edge.
$WS_EX_LAYERED | Creates a layered window. Note that this cannot be used for child windows.

To use the values specified above you must #include <GUIConstants.au3> in your script.

Note: The handle returned from this function is a real windows handle, which means it can be used in the same way as the result of WinGetHandle.

Related

GUISet..., GUICtrlCreate..., GUIGetMsg, GUIDelete, WinGetHandle

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW) ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Functions

GUI Control creation Function Reference

Below is a complete list of the GUI control creation functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
GUICtrlCreateAvi | Creates an AVI video control for the GUI.
GUICtrlCreateButton | Creates an Button control for the GUI.
GUICtrlCreateCheckbox | Creates an Checkbox control for the GUI.
GUICtrlCreateCombo | Creates an Combobox control for the GUI.
GUICtrlCreateContextMenu | Creates a context menu for a control or entire GUI window.
GUICtrlCreateDate | Creates a date control for the GUI.
GUICtrlCreateDummy | Creates a Dummy control for the GUI.
GUICtrlCreateEdit | Creates an Edit control for the GUI.
GUICtrlCreateGroup | Creates a Group control for the GUI.
GUICtrlCreateIcon | Creates an Icon control for the GUI.
GUICtrlCreateInput | Creates an Input control for the GUI.
GUICtrlCreateLabel | Creates a static Label control for the GUI.
GUICtrlCreateList | Creates a List control for the GUI.
GUICtrlCreateListView | Creates a ListView control for the GUI.
GUICtrlCreateListViewItem | Creates a ListView item.
GUICtrlCreateMenu | Creates a Menu control for the GUI.
GUICtrlCreateMenuItem | Creates a MenuItem control for the GUI.
GUICtrlCreatePic | Creates a Picture control for the GUI.
GUICtrlCreateProgress | Creates a Progress control for the GUI.
GUICtrlCreateRadio | Creates a Radio button control for the GUI.
GUICtrlCreateSlider | Creates a Slider control for the GUI.
GUICtrlCreateTab | Creates a Tab control for the GUI.
GUICtrlCreateTabItem | Creates a TabItem control for the GUI.
GUICtrlCreateTreeView | Creates a TreeView control for the GUI.
GUICtrlCreateTreeViewItem | Creates a TreeViewItem control for the GUI.
GUICtrlCreateUpdown | Creates an UpDown control for the GUI.


Function GUICtrlCreateAvi

Function Reference

GUICtrlCreateAvi

Creates an AVI video control for the GUI.

GUICtrlCreateAvi ( filename, subfileid, left, top [, width [, height [, style [, exStyle]]]] )

Parameters

filename | The filename of the video. Only .avi files are supported.
subfileid | id of the subfile to be used. If the file only contains one video then use -1.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $ACS_TRANSPARENT $ACS_TRANSPARENT is always used unless $ACS_NONTRANSPARENT is specified.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To start the video as soon as the control is created use the $ACS_AUTOPLAY style.
You can can start and stop the animation by setting the state to 1 or 0 with GUICtrlSetState. See example.

To add styles to default style just BitOr($GUI_SS_DEFAULT_AVI, newstyle,...).

Related

GUICoordMode (option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate ("My GUI Animation",300,200)
$ani1 = GUICtrlCreateAvi (@SystemDir & "\shell32.dll",150, 50,10)

$buttonstart = GUICtrlCreateButton ("start",50,150,70,22)
$buttonstop = GUICtrlCreateButton ("stop",150,150,70,22)

GUISetState( )

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

Select
case $msg = $GUI_EVENT_CLOSE
ExitLoop

case $msg = $buttonstart
GUICtrlSetState ($ani1, 1)

case $msg = $buttonstop
GUICtrlSetState ($ani1, 0)

EndSelect
Wend


Function GUICtrlCreateButton

Function Reference

GUICtrlCreateButton

Creates a Button control for the GUI.

GUICtrlCreateButton ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the button control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $WS_TABSTOP, $BS_PUSHBUTTON, $BS_NOTIFY
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

A Button control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage to specify the picture to use.

To add styles to default style just BitOr($GUI_SS_DEFAULT_BUTTON, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered

Opt("GUICoordMode",2)
GUICtrlCreateButton ("OK", 10, 30, 50)
GUICtrlCreateButton ( "Cancel", 0, -1)

GUISetState () ; will display an dialog box with 2 button

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateCheckbox

Function Reference

GUICtrlCreateCheckbox

Creates a Checkbox control for the GUI.

GUICtrlCreateCheckbox ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control checkbox.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $WS_TABSTOP, $BS_AUTOCHECKBOX
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

A Checkbox control can display an icon or image by using the $BS_ICON or $BS_BITMAP style. Use GUICtrlSetImage to specify the picture to use.

To add styles to default style just BitOr($GUI_SS_DEFAULT_CHECKBOX, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered

$checkCN = GUICtrlCreateCheckbox ("CHECKBOX 1", 10, 10, 120, 20)

GUISetState () ; will display an dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateCombo

Function Reference

GUICtrlCreateCombo

Creates a ComboBox control for the GUI.

GUICtrlCreateCombo ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text which will appear in the combo control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $CBS_DROPDOWN, $CBS_AUTOHSCROLL, $WS_VSCROLL forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

Under Windows XP/2003 window will adapt the size of the opened combo. On other Windows versions you can defined this size with the "height" parameter.

To add styles to default style just BitOr($GUI_SS_DEFAULT_COMBO, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI combo") ; will create a dialog box that when displayed is centered

GUICtrlCreateCombo ("item1", 10,10) ; create first item
GUICtrlSetData(-1,"item2|item3","item3") ; add other item snd set a new default

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateContextMenu

Function Reference

GUICtrlCreateContextMenu

Creates a context menu for a control or entire GUI window.

GUICtrlCreateContextMenu ( [controlID] )

Parameters

controlID [optional] Control identifier as returned by GUICtrlCreate...

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

After creating the context menu main control with this function, each menu item can be created by using GUICtrlCreateMenuItem.
Sub-menus can be created using GUICtrlCreateMenu.

If you use no parameters or -1 in this function then the context menu that is created is associated with the entire GUI window rather than an individual control.

Only one context menu per control is possible. If you wish to create a new context menu one you have to delete the existing menu first.

Note: You can't create context menus for controls that already have system context menus, i.e. edit or input controls.

Related

GUICtrlCreateMenuItem, GUICtrlCreateMenu, GUICtrlSetState, GUICtrlDelete

Example

#include <GUIConstants.au3>

GUICreate("My GUI Context Menu",300,200)

$contextmenu = GUICtrlCreateContextMenu ()

$button = GUICtrlCreateButton("OK",100,100,70,20)
$buttoncontext = GUICtrlCreateContextMenu($button)
$buttonitem = GUICtrlCreateMenuitem("About button",$buttoncontext)

$newsubmenu = GUICtrlCreateMenu ("new", $contextmenu)
$textitem = GUICtrlCreateMenuitem ("text",$newsubmenu)

$fileitem = GUICtrlCreateMenuitem ("Open",$contextmenu)
$saveitem = GUICtrlCreateMenuitem ("Save",$contextmenu)
GUICtrlCreateMenuitem ("",$contextmenu) ; separator

$infoitem = GUICtrlCreateMenuitem ("Info",$contextmenu)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateDate

Function Reference

GUICtrlCreateDate

Creates a date control for the GUI.

GUICtrlCreateDate ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The preselected date.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $DTS_LONGDATEFORMAT forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To add styles to default style just BitOr($GUI_SS_DEFAULT_DATE, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSetState, GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

; example1
GUICreate ( "My GUI get date", 200,200,800,200)
$date=GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )
GUISetState ()

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

MsgBox(0,"Date",GUICtrlRead($date))
GUIDelete()

; example2
$DTS_TIMEFORMAT = 9
GUICreate("My GUI get time")
$n=GUICtrlCreateDate ( "", 20, 20, 100, 20, $DTS_TIMEFORMAT)
GUISetState ()

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE

MsgBox(0,"Time", GUICtrlRead($n))


Function GUICtrlCreateDummy

Function Reference

GUICtrlCreateDummy

Creates a Dummy control for the GUI.

GUICtrlCreateDummy ( )

Parameters

None.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

This control can receive messages through a GUISendToDummy call. The control will "notify" as normal and the value sent with GUISendToDummy can be read with GUICtrlRead.

Related

GUICtrlSendToDummy, GUICtrlSetOnEvent, GUICtrlRead, GUICtrlSetData

Example

#include <GUIConstants.au3>

GUICreate("GUICtrlCreateDummy",250,200, 100,200)
GUISetBkColor (0x00E0FFFF) ; will change background color

$user = GUICtrlCreateDummy()
$button = GUICtrlCreateButton ("event",75,170,70,20)
$cancel = GUICtrlCreateButton ("Cancel",150,170,70,20)
GUISetState()

Do
$msg = GUIGetMsg ()

Select
Case $msg = $button
GUICtrlSendToDummy($user)
Case $msg = $cancel
GUICtrlSendToDummy($user)
Case $msg = $user
; special action before closing
; ...
exit
EndSelect
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlCreateEdit

Function Reference

GUICtrlCreateEdit

Creates an Edit control for the GUI.

GUICtrlCreateEdit ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL forced styles : $ES_MULTILINE, $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To add styles to default style just BitOr($GUI_SS_DEFAULT_EDIT, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSetState, GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered

$myedit=GUICtrlCreateEdit ("First line"& @CRLF, 176,32,121,97,$ES_AUTOVSCROLL+$WS_VSCROLL)

GUISetState ()

; will be append dont' forget 3rd parameter
GUICtrlSetData ($myedit, "Second line",1)

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateGroup

Function Reference

GUICtrlCreateGroup

Creates a Group control for the GUI.

GUICtrlCreateGroup ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

A group control is the thin line you see around controls (usually only Radio button) that visually groups them together. Only one Radio button within a Group can be selected at once.
If you want to have multiple groups without the visible line then you must use GUIStartGroup() to group your Radio buttons.

Related

GUICoordMode (Option), GUIStartGroup

Example

#include <GUIConstants.au3>

GUICreate("My GUI group") ; will create a dialog box that when displayed is centered

GUICtrlCreateGroup ("Group 1", 190, 60, 90, 140)
$radio_1 = GUICtrlCreateRadio ("Radio 1", 210, 90, 50, 20)
$radio_2 = GUICtrlCreateRadio ("Radio 2", 210, 110, 60, 50)
GUICtrlCreateGroup ("",-99,-99,1,1) ;close group

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateIcon

Function Reference

GUICtrlCreateIcon

Creates an Icon control for the GUI.

GUICtrlCreateIcon ( filename, iconID, left, top [, width [, height [, style [, exStyle]]]] )

Parameters

filename | filename of the icon to be loaded.
iconID | Icon identifier if the file contain multiple icon. Otherwise -1.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $SS_NOTIFY forced styles : $WS_TABSTOP, $SS_ICON
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

To update the icon after the dialog box is displayed use GUICtrlSetImage

To add styles to default style just BitOr($GUI_SS_DEFAULT_ICON, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSetImage, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

;example1 ---------------------------
GUICreate(" My GUI Icons")

$icon = GUICtrlCreateIcon ("shell32.dll",10, 20,20)
$icon2 = GUICtrlCreateIcon ("explorer.icl",10, 20,80)
$icon3 = GUICtrlCreateIcon ("explorer.icl",6, 80,80)
$n1=GUICtrlCreateIcon (@windowsdir & "\cursors\horse.ani",-1, 20,120,32,32)
$n2=GUICtrlCreateIcon ("shell32.dll",7 ,20,160,32,32)
GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

; example2 ---------------------------
Opt("GUICoordMode",1)

GUICreate("My GUI icon Race", 350,74,-1,-1)
GUICtrlCreateLabel ("", 331,0,1,74,5)
$n1=GUICtrlCreateIcon (@windowsdir & "\cursors\dinosaur.ani", -1, 0,0,32,32)
$n2=GUICtrlCreateIcon ( @windowsdir & "\cursors\horse.ani", -1, 0,40,32,32)

GUISetState (@SW_SHOW)

Dim $a = 0, $b = 0
While ($a < 300) And ($b < 300)
$a = $a + int(Random(0,1)+0.5)
$b = $b + int(Random(0,1)+0.5)
GUICtrlSetPos($n1, $a,0)
GUICtrlSetPos($n2, $b,40)
Sleep(20)
WEnd
sleep(1000)


Function GUICtrlCreateInput

Function Reference

GUICtrlCreateInput

Creates an Input control for the GUI.

GUICtrlCreateInput ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $ES_LEFT, $ES_AUTOHSCROLL forced styles : $WS_TABSTOP and $ES_MULTILINE is always reset.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

For defining an input control for entering passwords (input is hidden with an asterisk) use the $ES_PASSWORD style.

If you want to drag & drop filename onto this control just add the WS_EX_ACCEPTFILES extended style on the GUICreate() and set the state to $GUI_ACCEPTFILES.

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate(" My GUI input acceptfile", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 0x00000018); WS_EX_ACCEPTFILES
$file = GUICtrlCreateInput ( "", 10, 5, 300, 20)
GUICtrlSetState(-1,$GUI_ACCEPTFILES)
GUICtrlCreateInput ("", 10, 35, 300, 20) ; will not accept drag&drop files
$btn = GUICtrlCreateButton ("Ok", 40, 75, 60, 20)

GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()
Select
Case $msg = $btn
exitloop
EndSelect
Wend

MsgBox (4096, "drag drop file", GUICtrlRead($file))


Function GUICtrlCreateLabel

Function Reference

GUICtrlCreateLabel

Creates a static Label control for the GUI.

GUICtrlCreateLabel ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $SS_NOTIFY, $SS_LEFT
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

To add styles to default style just BitOr($GUI_SS_DEFAULT_LABEL, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

GUISetHelp("notepad") ; will run notepad if F1 is typed
Opt("GUICoordMode",2)
GUICtrlCreateLabel ("Done", 10, 30, 50) ; first cell 50 width
GUICtrlCreateLabel ("Done 2", -1, 0) ; next line
GUICtrlCreateLabel ("Done 3", 0, 0) ; next line and next cell
GUICtrlCreateLabel ("Done 4", 0, -1) ; next cell same line

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateList

Function Reference

GUICtrlCreateList

Creates a List control for the GUI.

GUICtrlCreateList ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : $LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY forced styles : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

The different list entries that can be selected can be set with GUICtrlSetData

To limit horizontal scrolling use GUICtrlSetLimit

To add styles to default style just BitOr($GUI_SS_DEFAULT_LIST, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSetLimit, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GLOBAL $MESSAGE = "The following buttons have been clicked"
GUICreate("My GUI list") ; will create a dialog box that when displayed is centered

$add=GUICtrlCreateButton ("Add", 64,32,75,25)
$clear=GUICtrlCreateButton ("Clear", 64,72,75,25)
$mylist=GUICtrlCreateList ("buttons that have been clicked", 176,32,121,97)
GUICtrlSetLimit(-1,200) ; to limit horizontal scrolling
GUICtrlSetData(-1,$MESSAGE)
$close=GUICtrlCreateButton ("my closing button", 64,160,175,25)

GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
$msg = GUIGetMsg()

Select
case $msg = $add
GUICtrlSetData($mylist,"You clicked button No1|")
case $msg = $clear
GUICtrlSetData($mylist,"")
Case $msg = $close
MsgBox(0,"", "the closing button has been clicked",2)
Exit
EndSelect
Wend


Function GUICtrlCreateListView

Function Reference

GUICtrlCreateListView

Creates a ListView control for the GUI.

GUICtrlCreateListView ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | definition of column heading.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $LVS_SHOWSELALWAYS, $LVS_SINGLESEL forced style : $LVS_REPORT
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To add items to a ListView control use GUICtrlCreateListViewItem

The ListView will always appear as in the Explorer view ""Details"" (LVS_REPORT style is forced).
You can control initial column size by padding blanks to the column heading definition. The column can be extend during the GUICtrlCreateListViewItem according to item size. Size of a column will be up to around 25 characters. No resizing will be done during an update by GUICtrlSetData.

Other views and sorting the list by clicking the column name (as in Explorer) is not currently implemented.

To have the entire line visually selected use the extended style LVS_EX_FULLROWSELECT.

To add styles to default style just BitOr($GUI_SS_DEFAULT_LISTVIEW, newstyle,...).

Related

GUICtrlCreateListViewItem, GUICoordMode (Option), GUICtrlSetData, GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES)
GUISetBkColor (0x00E0FFFF) ; will change background color

$listview = GUICtrlCreateListView ("col1 |col2|col3 ",10,10,200,150);,$LVS_SORTDESCENDING)
$button = GUICtrlCreateButton ("Value?",75,170,70,20)
$item1=GUICtrlCreateListViewItem("item2|col22|col23",$listview)
$item2=GUICtrlCreateListViewItem("item1|col12|col13",$listview)
$item3=GUICtrlCreateListViewItem("item3|col32|col33",$listview)
$input1=GUICtrlCreateInput("",20,200, 150)
GUICtrlSetState(-1,$GUI_ACCEPTFILES) ; to allow drag and dropping
GUISetState()
GUICtrlSetData($item2,"ITEM1",)
GUICtrlSetData($item3,"||COL33",)
GUICtrlDelete($item1)

Do
$msg = GUIGetMsg ()

Select
Case $msg = $button
MsgBox(0,"listview item",GUICtrlRead(GUICtrlRead($listview)),2)
Case $msg = $listview
MsgBox(0,"listview", "clicked="& GUICtrlGetState($listview),2)
EndSelect
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlCreateListViewItem

Function Reference

GUICtrlCreateListViewItem

Creates a ListView item.

GUICtrlCreateListViewItem ( "text", listviewID )

Parameters

text | subitemtext separated with |.
listviewID | controlID of the ListView control holding the item.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

This function creates the individual ListView items that can be selected. The items function as normal controls and can be set with GUICtrlSetData.
Items can be deleted as any other control with GUICtrlDelete.
ListView items can be dragged and drop into an Edit or Input control with a $GUI_ACCEPTFILES state.
See GUICtrlCreateListView about resizing of the column.

Related

GUICtrlCreateListView, GUICtrlSetData, GUICtrlSetState, GUICtrlDelete, GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate("listview items",220,250, 100,200,-1,$WS_EX_ACCEPTFILES)
GUISetBkColor (0x00E0FFFF) ; will change background color

$listview = GuiCtrlCreateListView ("col1 |col2|col3 ",10,10,200,150);,$LVS_SORTDESCENDING)
$button = GuiCtrlCreateButton ("Value?",75,170,70,20)
$item1=GuiCtrlCreateListViewItem("item2|col22|col23",$listview)
$item2=GuiCtrlCreateListViewItem("............item1|col12|col13",$listview)
$item3=GuiCtrlCreateListViewItem("item3|col32|col33",$listview)
$input1=GuiCtrlCreateInput("",20,200, 150)
GuiCtrlSetState(-1,$GUI_ACCEPTFILES) ; to allow drag and dropping
GuiSetState()
GUICtrlSetData($item2,"|ITEM1",)
GUICtrlSetData($item3,"||COL33",)
GUICtrlDelete($item1)

Do
$msg = GuiGetMsg ()

Select
Case $msg = $button
MsgBox(0,"listview item",GUICtrlRead(GUICtrlRead($listview)),2)
Case $msg = $listview
MsgBox(0,"listview", "clicked="& GuiCtrlGetState($listview),2)
EndSelect
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlCreateMenu

Function Reference

GUICtrlCreateMenu

Creates a Menu control for the GUI.

GUICtrlCreateMenu ( "submenutext" [, menuID [, menuentry]] )

Parameters

submenutext | The submenu text.
menuID | [optional] If defined, allow to create a submenu in the refered menu. If equal -1 it refers to first level menu.
menuentry | [optional] Allow to define the entry number to be created. The entries are numbered starting 0.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

Related

GUICtrlSetState, GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI menu",300,200)

Global $defaultstatus = "Ready"
Global $status

$filemenu = GUICtrlCreateMenu ("&File")
$fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$helpmenu = GUICtrlCreateMenu ("?")
$saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
GUICtrlSetState(-1,$GUI_DISABLE)
$infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)
$exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
$recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)

$separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View",-1,1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
GUICtrlSetState(-1,$GUI_CHECKED)
$okbutton = GUICtrlCreateButton ("OK",50,130,70,20)
GUICtrlSetState(-1,$GUI_FOCUS)
$cancelbutton = GUICtrlCreateButton ("Cancel",180,130,70,20)

$statuslabel = GUICtrlCreateLabel ($defaultstatus,0,165,300,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

GUISetState ()
While 1
$msg = GUIGetMsg()

If $msg = $fileitem Then
$file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")
If @error <> 1 Then GUICtrlCreateMenuitem ($file,$recentfilesmenu)
EndIf
If $msg = $viewstatusitem Then
If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
GUICtrlSetState($statuslabel,$GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
GUICtrlSetState($statuslabel,$GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop
If $msg = $infoitem Then Msgbox(0,"Info","Only a test...")
WEnd
GUIDelete()

Exit


Function GUICtrlCreateMenuitem

Function Reference

GUICtrlCreateMenuitem

Creates a MenuItem control for the GUI.

GUICtrlCreateMenuitem ( "text", menuID [, menuentry [, menuradioitem]] )

Parameters

text | The text of the control.
menuID | Allow to create a submenu in the refered menu. If equal -1 it refers to first level menu.
menuentry | [optional] Allow to define the entry number to be created. The entries are numbered starting 0.
menuradionitem | [optional] 0 (default) = create a normal menuitem, 1 = create a menuradioitem

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

If the Text parameter is a "" then a separator line is created. GUICtrlSetState can be use as for other control. See example.

Related

GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI menu",300,200)

Global $defaultstatus = "Ready"
Global $status

$filemenu = GUICtrlCreateMenu ("&File")
$fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)
GUICtrlSetState(-1,$GUI_DEFBUTTON)
$helpmenu = GUICtrlCreateMenu ("?")
$saveitem = GUICtrlCreateMenuitem ("Save",$filemenu)
GUICtrlSetState(-1,$GUI_DISABLE)
$infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)
$exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)
$recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)

$separator1 = GUICtrlCreateMenuitem ("",$filemenu,2) ; create a separator line

$viewmenu = GUICtrlCreateMenu("View",-1,1) ; is created before "?" menu
$viewstatusitem = GUICtrlCreateMenuitem ("Statusbar",$viewmenu)
GUICtrlSetState(-1,$GUI_CHECKED)
$okbutton = GUICtrlCreateButton ("OK",50,130,70,20)
GUICtrlSetState(-1,$GUI_FOCUS)
$cancelbutton = GUICtrlCreateButton ("Cancel",180,130,70,20)

$statuslabel = GUICtrlCreateLabel ($defaultstatus,0,165,300,16,BitOr($SS_SIMPLE,$SS_SUNKEN))

GUISetState ()
While 1
$msg = GUIGetMsg()

If $msg = $fileitem Then
$file = FileOpenDialog("Choose file...",@TempDir,"All (*.*)")
If @error <> 1 Then GUICtrlCreateMenuitem ($file,$recentfilesmenu)
EndIf
If $msg = $viewstatusitem Then
If BitAnd(GUICtrlRead($viewstatusitem),$GUI_CHECKED) = $GUI_CHECKED Then
GUICtrlSetState($viewstatusitem,$GUI_UNCHECKED)
GUICtrlSetState($statuslabel,$GUI_HIDE)
Else
GUICtrlSetState($viewstatusitem,$GUI_CHECKED)
GUICtrlSetState($statuslabel,$GUI_SHOW)
EndIf
EndIf
If $msg = $GUI_EVENT_CLOSE Or $msg = $cancelbutton Or $msg = $exititem Then ExitLoop
If $msg = $infoitem Then Msgbox(0,"Info","Only a test...")
WEnd
GUIDelete()

Exit


Function GUICtrlCreatePic

Function Reference

GUICtrlCreatePic

Creates a Picture control for the GUI.

GUICtrlCreatePic ( filename, left, top [, width [, height [, style [, exStyle]]]] )

Parameters

filename | filename of the icon to be loaded.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $SS_NOTIFY forced style : $SS_BITMAP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

To update the icon after the dialog box is displayed just use GUICtrlSetImage

If you want to have a picture having the same size as the file content just use width=height=0.

To have a transparent picture it is needed to use a .gif image with the transparency color set and to create the window with WS_EX_LAYERED extended style.

To add styles to default style just BitOr($GUI_SS_DEFAULT_PIC, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSetImage, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>
GUICreate("My GUI picture",350,300,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) ; will create a dialog box that when displayed is centered

GUISetBkColor (0xE0FFFF)
$n=GUICtrlCreatePic(@Systemdir & "\oobe\images\mslogo.jpg",50,50, 200,50)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

GUISetState ()
; resize the control
$n=GUICtrlSetPos($n,50,50,200,100)
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateProgress

Function Reference

GUICtrlCreateProgress

Creates a Progress control for the GUI.

GUICtrlCreateProgress ( left, top [, width [, height [, style [, exStyle]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To update the bar position just use GUICtrlSetData.

To add styles to default style just BitOr($GUI_SS_DEFAULT_PROGRESS, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI Progressbar",220,100, 100,200)
$progressbar1 = GUICtrlCreateProgress (10,10,200,20)
GUICtrlSetColor(-1,32250); not working with Windows XP Style
$progressbar2 = GUICtrlCreateProgress (10,40,200,20,$PBS_SMOOTH)
$button = GUICtrlCreateButton ("Start",75,70,70,20)
GUISetState ()

$wait = 20; wait 20ms for next progressstep
$s = 0; progressbar-saveposition
do
$msg = GUIGetMsg()
If $msg = $button Then
GUICtrlSetData ($button,"Stop")
For $i = $s To 100
If GUICtrlRead($progressbar1) = 50 Then Msgbox(0,"Info","The half is done...", 1)
$m = GUIGetMsg ()

If $m = -3 Then ExitLoop

If $m = $button Then
GUICtrlSetData ($button,"Next")
$s = $i;save the current bar-position to $s
ExitLoop
Else
$s=0
GUICtrlSetData ($progressbar1,$i)
GUICtrlSetData ($progressbar2,(100 - $i))
Sleep($wait)
EndIf
Next
if $i >100 then
; $s=0
GUICtrlSetData ($button,"Start")
endif
EndIf
until $msg = $GUI_EVENT_CLOSE


Function GUICtrlCreateRadio

Function Reference

GUICtrlCreateRadio

Creates a Radio button control for the GUI.

GUICtrlCreateRadio ( "text", left, top [, width [, height [, style [, exStyle]]]] )

Parameters

text | The text of the control.
left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $BS_AUTORADIOBUTTON and $WS_TABSTOP if first radio in the group.
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To add styles to default style just BitOr($GUI_SS_DEFAULT_RADIO, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>
GUICreate("My GUI radio") ; will create a dialog box that when displayed is centered

$radio1 = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20)
GUICtrlSetState ($radio1,$GUI_CHECKED)
$radio2 = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20)

GUISetState () ; will display an dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateSlider

Function Reference

GUICtrlCreateSlider

Creates a Slider control for the GUI.

GUICtrlCreateSlider ( left, top [, width [, height [, style [, exStyle]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $TBS_AUTOTICKS
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To obtain the value of the control see GUICtrlRead.
To set or change information in the control see GUICtrlSet....

To update the bar position just use GUICtrlSetData.
To set the min and max value use GUICtrlSetLimit.

To add styles to default style just BitOr($GUI_SS_DEFAULT_SLIDER, newstyle,...).

Related

GUICoordMode (Option), GUICtrlSetData, GUICtrlSetLimit, GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("slider",220,100, 100,200)
GUISetBkColor (0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider (10,10,200,20)
GUICtrlSetLimit(-1,200,0) ; change min/max value
$button = GUICtrlCreateButton ("Value?",75,70,70,20)
GUISetState()
GUICtrlSetData($slider1,45) ; set cursor

$start=TimerInit()
Do
$n = GUIGetMsg ()

If $n = $button Then
MsgBox(0,"slider1",GUICtrlRead($slider1),2)
$start=TimerInit()
EndIf
Until $n = $GUI_EVENT_CLOSE


Function GUICtrlCreateTab

Function Reference

GUICtrlCreateTab

Creates a Tab control for the GUI.

GUICtrlCreateTab ( left, top [, width [, height [, style [, exStyle]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default ( -1) : none. forced styles : $WS_TABSTOP, $WS_CLIPSIBLINGS
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

This control is just a control in which the tabitem controls will be created and after the specific control related to a specific tabitem will be created with GUICtrlCreate... controls.

To set or change information in the control see GUICtrlSet....

To add styles to default style just BitOr($GUI_SS_DEFAULT_TAB, newstyle,...).

Related

GUICtrlCreateTabItem, GUICoordMode (Option), GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI Tab") ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab=GUICtrlCreateTab (10,10, 200,100)

$tab0=GUICtrlCreateTabitem ("tab0")
GUICtrlCreateLabel ("label0", 30,80,50,20)
$tab0OK=GUICtrlCreateButton ("OK0", 20,50,50,20)
$tab0input=GUICtrlCreateInput ("default", 80,50,70,20)

$tab1=GUICtrlCreateTabitem ( "tab----1")
GUICtrlCreateLabel ("label1", 30,80,50,20)
$tab1combo=GUICtrlCreateCombo ("", 20,50,60,40)
GUICtrlSetData(-1,"Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK=GUICtrlCreateButton ("OK1", 80,50,50,20)

$tab2=GUICtrlCreateTabitem ("tab2")
GUICtrlSetState(-1,$GUI_SHOW) ; will be display first
GUICtrlCreateLabel ("label2", 30,80,50,20)
$tab2OK=GUICtrlCreateButton ("OK2", 140,50,50)

GUICtrlCreateTabitem ("") ; end tabitem definition

GUICtrlCreateLabel ("label3", 20,130,50,20)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateTabItem

Function Reference

GUICtrlCreateTabItem

Creates a TabItem control for the GUI.

GUICtrlCreateTabItem ( "text" )

Parameters

text The text of the control.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

For setting more information see GUICtrlSet....

To select a specific tab to be shown when the dialog box open just issue a GUICtrlSetState(-1,$GUI_SHOW) see example

To terminate the tab control just create a last "tabitem" control with a null text "". The "tabitem" control cannot be painted (too much code ...)

Related

GUICtrlSetState, GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUI Tab") ; will create a dialog box that when displayed is centered

GUISetBkColor(0x00E0FFFF)
GUISetFont(9, 300)

$tab=GUICtrlCreateTab (10,10, 200,100)

$tab0=GUICtrlCreateTabitem ("tab0")
GUICtrlCreateLabel ("label0", 30,80,50,20)
$tab0OK=GUICtrlCreateButton ("OK0", 20,50,50,20)
$tab0input=GUICtrlCreateInput ("default", 80,50,70,20)

$tab1=GUICtrlCreateTabitem ( "tab----1")
GUICtrlCreateLabel ("label1", 30,80,50,20)
$tab1combo=GUICtrlCreateCombo ("", 20,50,60,40)
GUICtrlSetData(-1,"Trids|CyberSlug|Larry|Jon|Tylo", "Jon") ; default Jon
$tab1OK=GUICtrlCreateButton ("OK1", 80,50,50,20)

$tab2=GUICtrlCreateTabitem ("tab2")
GUICtrlSetState(-1,$GUI_SHOW) ; will be display first
GUICtrlCreateLabel ("label2", 30,80,50,20)
$tab2OK=GUICtrlCreateButton ("OK2", 140,50,50)

GUICtrlCreateTabitem ("") ; end tabitem definition

GUICtrlCreateLabel ("label3", 20,130,50,20)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlCreateTreeView

Function Reference

GUICtrlCreateTreeView

Creates a TreeView control for the GUI.

GUICtrlCreateTreeView ( left, top [, width [, height [, style [, exStyle]]]] )

Parameters

left | The left side of the control. If -1 is used then left will be computed according to GUICoordMode.
top | The top of the control. If -1 is used then top will be computed according to GUICoordMode.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS forced style : $WS_TABSTOP
exStyle | [optional] Defines the extended style of the control. See Extended Style Table.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

To set or change information in the control see GUICtrlSet....

To add styles to default style just BitOr($GUI_SS_DEFAULT_TREEVIEW, newstyle,...).

Related

GUICtrlCreateTreeViewItem, GUICoordMode (Option), GUICtrlSet..., GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate("My GUI with treeview",350,212)

$treeview = GUICtrlCreateTreeView (6,6,100,150,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewitem ("General",$treeview)
$displayitem = GUICtrlCreateTreeViewitem ("Display",$treeview)
$aboutitem = GUICtrlCreateTreeViewitem ("About",$generalitem)
$compitem = GUICtrlCreateTreeViewitem ("Computer",$generalitem)
$useritem = GUICtrlCreateTreeViewitem ("User",$generalitem)
$resitem = GUICtrlCreateTreeViewitem ("Resolution",$displayitem)
$otheritem = GUICtrlCreateTreeViewitem ("Other",$displayitem)

$startlabel = GUICtrlCreateLabel ("TreeView Demo",190,90,100,20)
$aboutlabel = GUICtrlCreateLabel ("This little scripts demonstates the using of a treeview-control.",190,70,100,60)
GUICtrlSetState(-1,$GUI_HIDE)
$compinfo = GUICtrlCreateLabel ("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack,120,30,200,80)
GUICtrlSetState(-1,$GUI_HIDE)

$okbutton = GUICtrlCreateButton ("OK",100,185,70,20)
$cancelbutton = GUICtrlCreateButton ("Cancel",180,185,70,20)

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
GUIChangeItems($aboutlabel,$compinfo,$startlabel,$startlabel)

Case $msg = $aboutitem
GUICtrlSetState ($compinfo,$GUI_HIDE)
GUIChangeItems($startlabel,$startlabel,$aboutlabel,$aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel,$aboutlabel,$compinfo,$compinfo)
EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart,$hideend,$showstart,$showend)
Local $idx,$hidestart,$hideend,$showstart,$showend

For $idx = $hidestart To $hideend
GUICtrlSetState ($idx,$GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState ($idx,$GUI_SHOW)
Next
EndFunc


Function GUICtrlCreateTreeViewItem

Function Reference

GUICtrlCreateTreeViewItem

Creates a TreeViewItem control for the GUI.

GUICtrlCreateTreeViewItem ( "text", treeviewID )

Parameters

text | The text of the control.
treeviewID | treeview identifier as return by treeview or treeviewitem creation if subtree is created.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

For setting more information see GUICtrlSet....

Related

GUICtrlCreateTreeView, GUICtrlSet..., GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate("My GUI with treeview",350,212)

$treeview = GUICtrlCreateTreeView (6,6,100,150,BitOr($TVS_HASBUTTONS,$TVS_HASLINES,$TVS_LINESATROOT,$TVS_DISABLEDRAGDROP,$TVS_SHOWSELALWAYS),$WS_EX_CLIENTEDGE)
$generalitem = GUICtrlCreateTreeViewitem ("General",$treeview)
$displayitem = GUICtrlCreateTreeViewitem ("Display",$treeview)
$aboutitem = GUICtrlCreateTreeViewitem ("About",$generalitem)
$compitem = GUICtrlCreateTreeViewitem ("Computer",$generalitem)
$useritem = GUICtrlCreateTreeViewitem ("User",$generalitem)
$resitem = GUICtrlCreateTreeViewitem ("Resolution",$displayitem)
$otheritem = GUICtrlCreateTreeViewitem ("Other",$displayitem)

$startlabel = GUICtrlCreateLabel ("TreeView Demo",190,90,100,20)
$aboutlabel = GUICtrlCreateLabel ("This little scripts demonstates the using of a treeview-control.",190,70,100,60)
GUICtrlSetState(-1,$GUI_HIDE)
$compinfo = GUICtrlCreateLabel ("Name:" & @TAB & @ComputerName & @LF & "OS:" & @TAB & @OSVersion & @LF & "SP:" & @TAB & @OSServicePack,120,30,200,80)
GUICtrlSetState(-1,$GUI_HIDE)

$okbutton = GUICtrlCreateButton ("OK",100,185,70,20)
$cancelbutton = GUICtrlCreateButton ("Cancel",180,185,70,20)

GUISetState ()
While 1
$msg = GUIGetMsg()
Select
Case $msg = $cancelbutton Or $msg = $GUI_EVENT_CLOSE
ExitLoop

Case $msg = $generalitem
GUIChangeItems($aboutlabel,$compinfo,$startlabel,$startlabel)

Case $msg = $aboutitem
GUICtrlSetState ($compinfo,$GUI_HIDE)
GUIChangeItems($startlabel,$startlabel,$aboutlabel,$aboutlabel)

Case $msg = $compitem
GUIChangeItems($startlabel,$aboutlabel,$compinfo,$compinfo)
EndSelect
WEnd

GUIDelete()
Exit

Func GUIChangeItems($hidestart,$hideend,$showstart,$showend)
Local $idx,$hidestart,$hideend,$showstart,$showend

For $idx = $hidestart To $hideend
GUICtrlSetState ($idx,$GUI_HIDE)
Next
For $idx = $showstart To $showend
GUICtrlSetState ($idx,$GUI_SHOW)
Next
EndFunc


Function GUICtrlCreateUpdown

Function Reference

GUICtrlCreateUpdown

Creates an UpDown control for the GUI.

GUICtrlCreateUpdown ( inputcontrolID [,style] )

Parameters

inputcontrolID | The controlID of the input control in which the updown control will be created.
style | [optional] Defines the style of the control. See GUI Control Styles Appendix. default (-1) : $UDS_ALIGNRIGHT forced style : $UDS_SETBUDDYINT and $UDS_ALIGNRIGHT if no align defined.

Return Value

Success: | Returns the identifier (controlID) of the new control.
Failure: | Returns 0.

Remarks

Max and min value can be set with GUICtrlSetLimit.
By default Windows decrease the value when clicking the upper arrow button.

Related

GUICtrlCreateInput, GUICtrlSetData, GUICtrlSetLimit

Example

#include "GUIConstants.au3"

$title = "My GUI UpDown"
GUICreate($title,-1,-1,-1,-1, $WS_SIZEBOX)

$input = GUICtrlCreateInput ("2",10,10, 50, 20)
$updown = GUICtrlCreateUpdown($input)

; Attempt to resize input control
GUICtrlSetPos($input, 10,10, 100, 40 )

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

msgbox(0,"Updown",GUICtrlRead($input))


Function GUICtrlDelete

Function Reference

GUICtrlDelete

Deletes a control.

GUICtrlDelete ( controlID )

Parameters

controlID The control identifier (controlID) as returned by a GUICtrlCreate... function.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

This function does not currently work on context menu controls.

Related

GUICreate, GUICtrlCreate...

Example

#include <GUIConstants.au3>

GUICreate ( "My GUI delete control", 200,200,800,200)
$date=GUICtrlCreateDate ("1953/04/25", 10,10,185,20 )
$del=GUICtrlCreateButton("Delete control", 50,50,70,20 )
GUISetState ()

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
if $msg = $del then
GUICtrlDelete($date)
GUICtrlDelete($del)
endif
Until $msg = $GUI_EVENT_CLOSE


Functions

GUI Control Management Function Reference

Below is a complete list of the GUI control update functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
GUICtrlSetBkColor | Sets the background color of a control.
GUICtrlSetColor | Sets the text color of a control.
GUICtrlSetData | Modifies the data for a control.
GUICtrlSetCursor | Sets mouse cursor icon for a particular control.
GUICtrlSetFont | Sets the Font parameter for a control.
GUICtrlSetImage | Sets the bitmap or icon image to use for a control.
GUICtrlSetLimit | Limit the number of characters/pixels for a control.
GUICtrlSetOnEvent | Defines a user-defined function to be called when a control is clicked.
GUICtrlSetPos | Changes the position of a control within the GUI window.
GUICtrlSetResizing | Defines the resizing method used by a control.
GUICtrlSetState | Changes the state of a control.
GUICtrlSetStyle | Changes the style of a control.
GUICtrlSetTip | Sets the tip text associated with a control.

Function | Description
GUICtrlRecvMsg | Retrieve infos from a control.
GUICtrlSendMsg | Send a message to a control..
GUICtrlSendToDummy | Sends a message to a Dummy control.


Function GUICtrlSetBkColor

Function Reference

GUICtrlSetBkColor

Sets the background color of a control.

GUICtrlSetBkColor ( controlID, backgroundcolor )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
backgroundcolor | The RGB color to use.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Only Label and Progress controls can currently be colored.

Progress controls cannot be painted if the "Windows XP style" is used.

Earlier versions of AutoIt (prior to v3.0.102) used the BGR format for defining color - newer versions use RGB by default but this can be changed using the ColorMode option.

Related

ColorMode (Option), GUICtrlCreate..., GUICtrlSetColor

Example

#include <GUIConstants.au3>

GUICreate("My GUI background color") ; will create a dialog box that when displayed is centered

GUICtrlCreateLabel ("my label", 10,20)
GUICtrlSetBkColor(-1,0x00ff00) ; Green

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetColor

Function Reference

GUICtrlSetColor

Sets the text color of a control.

GUICtrlSetColor ( controlID, textcolor)

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
textcolor | The RGB color to use.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Only Label and Progress controls can currently be colored.

Progress controls cannot be painted if the "Windows XP style" is used.

Earlier versions of AutoIt (prior to v3.0.102) used the BGR format for defining color - newer versions use RGB by default but this can be changed using the ColorMode option.

Related

ColorMode (Option), GUICtrlCreate..., GUICtrlSetBkColor

Example

#include <GUIConstants.au3>

GUICreate("My GUI color text") ; will create a dialog box that when displayed is centered

GUICtrlCreateLabel ("my Red label", 10,20)
GUICtrlSetColor(-1,0xff0000) ; Red

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetCursor

Function Reference

GUICtrlSetCursor

Sets mouse cursor icon for a particular control.

GUICtrlSetCursor ( controlID, cursorID )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
cursorID | cursor ID as used by Windows SetCursor API (use -1 for the default cursor for the control)

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Unlike GUISetCursor which changes the cursor for an entire window, this function sets the cursor that is used when the mouse is hovering over the specified control.

If the cursorID is invalid the standard arrow will be displayed.

For a list of valid cursor IDs see MouseGetCursor.

Related

GUISetCursor

Example

#include <GUIConstants.au3>

GUICreate("put cursor over label", 300, 100)
GUICtrlCreateLabel("label",125,40)
GUICtrlSetCursor(-1, 4)
GUISetState ()

While GUIGetMsg()<> $GUI_EVENT_CLOSE
WEnd
Exit


Function GUICtrlSetData

Function Reference

GUICtrlSetData

Modifies the data for a control.

GUICtrlSetData ( controlID, data [, default] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
data | For Combo, List, ListViewItem : itemtext separated with | For Progress : percent value For Slider : value For Group, Label, Button, Checkbox, Radio, Combo, List, Input, Edit, TabItem : text update For Date : date or time depending the style of the control For Dummy : value.
default | [optional] for Combo, List : the value that will be the default. for Edit, Input : if defined and not "" the "data" string is inserted not overriding the previous value at the cursor point.

Return Value

Success: | Returns 1.
Failure: | Returns 0.
 | Returns -1 in case of invalid data

Remarks

For Combo or List control :
If the "data" corresponds to an already existing entry it is set as the default.
If the "data" starts with | or is an empty string "" the previous list is destroyed.

For ListViewItem control :
To update a specific column just forget about the others ie "||update" to update 3rd column.

Related

GUICtrlCreate..., GUICtrlSet..., GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

GUICtrlCreateCombo ("", 10,10)

GUICtrlSetData(-1,"item1|item2|item3", "item3")

GUISetState () ; will display an empty dialog box with a combo control with focus on

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetFont

Function Reference

GUICtrlSetFont

Sets the font for a control.

GUICtrlSetFont (controlID, size [, weight [, attribute [, fontname]]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
size | Fontsize (default is 9).
weight | [optional] Font weight (default 400 = normal).
attribute | [optional] To define italic:2 underlined:4 strike:8 char format (add together the values of all the styles required, 2+4 = italic and underlined).
fontname | [optional] The name of the font to use.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

By default, controls use the font set by GUISetFont.

Size can be with decimal as 8.5.

See the Appendix for a complete list of fonts and the operating systems under which they are supported.

Related

GUICtrlCreate..., GUISetFont

Example

#include <GUIConstants.au3>

GUICreate ("My GUI") ; will create a dialog box that when displayed is centered

$font="Comic Sans MS"
GUICtrlCreateLabel ("underlined label",10,20)
GUICtrlSetFont (-1,9, 400, 4, $font) ; will display underlined characters

GUICtrlCreateLabel ("italic label", 10,40)
GUICtrlSetFont (-1,9, 400, 2, $font) ; will display underlined characters

GUISetFont (9, 400, 8, $font) ; will display underlined characters
GUICtrlCreateLabel ("strike label",10,60)

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetImage

Function Reference

GUICtrlSetImage

Sets the bitmap or icon image to use for a control.

GUICtrlSetImage ( controlID, filename [, iconID [, icontype]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
filename | The filename containing the picture to be display on the control.
iconID | [optional] Icon identifier if the file contain multiple icons. Otherwise -1.
icontype | [optional] To select a specific icon size : 0 = small, 1 = normal (default). for TreeViewItem the icon size : 2 = selected, 4 for nonselected item.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

If used on a Button control the image will be displayed on the button. Images can also be set for Checkbox controls as long as the $BS_PUSHLIKE style is used. In both case the $BS_ICON or $BS_BITMAP styles are needed to select the type of the picture used.

Related

GUICtrlCreatePic, GUICtrlCreateIcon, GUICtrlCreateButton, GUICtrlCreateCheckbox

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

GUICtrlCreateButton ("my picture button", 10,20,40,40, $BS_ICON)
GUICtrlSetImage (-1, "shell32.dll",22)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetLimit

Function Reference

GUICtrlSetLimit

Limits the number of characters/pixels for a control.

GUICtrlSetLimit ( controlID, max [, min] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
max | For List controls it is the extent you can scroll horizontally in pixels. For Input/Edit controls it is the max number of characters that can be entered.
min | [optional] For Slider and UpDown controls you can specify a min value.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICtrlCreateList, GUICtrlCreateInput, GUICtrlCreateEdit

Example

#include <GUIConstants.au3>

GUICreate("My GUI limit input 3 chars") ; will create a dialog box that when displayed is centered

GUICtrlCreateInput("", 10,20)
GUICtrlSetLimit(-1,3) ; to limit the entry to 3 chars

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetOnEvent

Function Reference

GUICtrlSetOnEvent

Defines a user-defined function to be called when a control is clicked.

GUICtrlSetOnEvent ( controlID, "function" )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
function | The name of the user function to call.

Return Value

Success: | Returns 1.
Failure: | Returns 0,

Remarks

OnEvent functions are only called when the option GUIOnEventMode is set to 1 - when in this mode GUIGetMsg is NOT used at all.

Within the called user function the control identifier can be retrieved with @GUI_CTRLID.
If needed the windows handle and the control handle can be retrieved with @GUI_WINHANDLE or @GUI_CTRLHANDLE.

Related

GUICreate, GUICtrlCreate..., GUIGetMsg, GUIOnEventMode (Option), GUISetOnEvent

Example

#include <GUIConstants.au3>

Opt("GUICoordMode",2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)

$parent1 = GUICreate("Parent1")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

$ok1 = GUICtrlCreateButton ("OK", 10, 30, 50)
GUICtrlSetOnEvent(-1, "OKPressed")

$cancel1 = GUICtrlCreateButton ( "Cancel", 0, -1)
GUICtrlSetOnEvent(-1, "CancelPressed")

GUISetState(@SW_SHOW)

; Just idle around
While 1
Sleep(10)
Wend

; END

Func OKPressed()
MsgBox(0, "OK Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
EndFunc

Func CancelPressed()
MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
EndFunc

Func SpecialEvents()

Select
Case @GUI_CTRLID = $GUI_EVENT_CLOSE
MsgBox(0, "Close Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
Exit

Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

Case @GUI_CTRLID = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

EndSelect

EndFunc


Function GUICtrlSetPos

Function Reference

GUICtrlSetPos

Changes the position of a control within the GUI window.

GUICtrlSetPos ( controlID, left, top [, width [, height]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
left | The left side of the control.
top | The top of the control.
width | [optional] The width of the control.
height | [optional] The height of the control .

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICtrlCreate...

Example

#include <GUIConstants.au3>

GUICreate("My GUI position") ; will create a dialog box that when displayed is centered

$right = 0
$label=GUICtrlCreateLabel ( "my moving label", 10,20)

$button = GUICtrlCreateButton ("Click to close", 50,50)
GUICtrlSetState(-1,$GUI_FOCUS) ; the focus is on this button

GUISetState ()

While 1
$msg = GUIGetMsg()

if $msg = $button Or $msg = $GUI_EVENT_CLOSE then Exit
If $right = 0 then
$right = 1
GUICtrlSetPos ($label, 20,20)
else
$right = 0
GUICtrlSetPos ($label, 10,20)
endif
Sleep(100)
Wend


Function GUICtrlSetResizing

Function Reference

GUICtrlSetResizing

Defines the resizing method used by a control.

GUICtrlSetResizing ( controlID, resizing )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
resizing | See the Docking Values table below for values that can be used (add together multiple values if required).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

When a GUI window is resized the controls within react - how they react is determined by this function. To be able to resize a GUI window it needs to have been created with the $WS_SIZEBOX and $WS_SYSMENU styles. See GUICreate.

Docking Values Table
Resizing | Value | No displacement of
$GUI_DOCKLEFT | 2 | Left side
$GUI_DOCKRIGHT | 4 | Right side
$GUI_DOCKHCENTER | 8 | Position will not move relative to horizontal center
$GUI_DOCKTOP | 32 | Top side
$GUI_DOCKBOTTOM | 64 | Bottom side
$GUI_DOCKVCENTER | 128 | Position will not move relative to vertical center
$GUI_DOCKWIDTH | 256 | Width will not change
$GUI_DOCKHEIGHT | 512 | Height will not change
$GUI_DOCKSIZE | 768 | Size will not change (256+512)
$GUI_DOCKMENUBAR | 544 | 512+32 so the control will stay on the top of window with no changing Height
$GUI_DOCKSTATEBAR | 576 | 512+64 so the control stay at the bottom of the window with no changing Height
$GUI_DOCKALL | 802 | 2+32+256+512 so the control will not move during resizing

Related

None.

Example

#include <GUIConstants.au3>

Opt("GUICoordMode", 2)
GUICreate ("My InputBox",190,114,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) ; start the definition
GUISetIcon ("Eiffel Tower.ico")

GUISetFont (8,-1,"Arial")

GUICtrlCreateLabel ("Prompt", 8,7) ; add prompt info
GUICtrlSetResizing (-1,$GUI_DOCKLEFT+$GUI_DOCKTOP)

$nEdit = GUICtrlCreateInput ("Default", -1,3,175,20,$ES_PASSWORD) ; add the input area
GUICtrlSetState ($nEdit,$GUI_FOCUS)
GUICtrlSetResizing ($nEdit,$GUI_DOCKBOTTOM+$GUI_DOCKHEIGHT)

$nOk = GUICtrlCreateButton ("OK",-1,3,75,24) ; add the button that will close the GUI
GUICtrlSetResizing ($nOk,$GUI_DOCKBOTTOM+$GUI_DOCKSIZE+$GUI_DOCKVCENTER)

$nCancel = GUICtrlCreateButton ("Annuler", 25,-1) ; add the button that will close the GUI
GUICtrlSetResizing ($nCancel,$GUI_DOCKBOTTOM+$GUI_DOCKSIZE+$GUI_DOCKVCENTER)

GUISetState () ; to display the GUI

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetState

Function Reference

GUICtrlSetState

Changes the state of a control.

GUICtrlSetState ( controlID, state )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
state | See the State table below.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

State table
State | Comments
No Change | 0
$GUI_UNCHECKED | Radio or Checkbox will be unchecked
$GUI_CHECKED | Radio or Checkbox will be checked
$GUI_INDETERMINATE | Checkbox having the tristate attribute will be greyed
$GUI_AVISTART | Avi control will start playing
$GUI_AVISTOP | Avi control will stop playing
$GUI_AVICLOSE | Avi control will stop playing and release resource
$GUI_ACCEPTFILES | Input or Edit control will accept drag and drop of files
$GUI_SHOW | Control will be visible. On Tabitem control will select the first tab to be displayed
$GUI_HIDE | Control will not be visible
$GUI_ENABLE | Control will be enabled
$GUI_DISABLE | Control will be greyed out
$GUI_FOCUS | Control will be given input focus
$GUI_DEFBUTTON | Control will be set as the default button on the window

State values can be summed up as for example $GUI_DISABLE + $GUI_HIDE sets the control in an disabled and hidden state.

If an AVI control has to be hidden with $GUI_HIDE it should be closed with $GUI_AVICLOSE.

State of a "contextmenu" or "menu" control cannot be changed.

Related

ColorMode (Option), GUICtrlCreate..., GUICtrlSetData

Example

#include <GUIConstants.au3>

GUICreate("My GUI state") ; will create a dialog box that when displayed is centered

GUICtrlCreateLabel ("my disable label", 10,20)
GUICtrlSetState(-1,$GUI_DISABLE) ; the label is in disable state

GUICtrlCreateButton ("my button", 50,50)
GUICtrlSetState(-1,$GUI_FOCUS) ; the focus is on this button

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetStyle

Function Reference

GUICtrlSetStyle

Changes the style of a control.

GUICtrlSetStyle ( controlID, style [, exStyle] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
style | Defines the style of the control. See GUI Control Styles Appendix.
exStyle | [optional] Defines the extended Style of the control. See Extended Style Table.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICtrlCreate...

Example

#include <GUIConstants.au3>

GUICreate("My GUI style") ; will create a dialog box that when displayed is centered

GUICtrlCreateLabel ( "my label which will split on several lines", 10,20, 100, 100)
;GUICtrlSetStyle (-1, $SS_RIGHT )

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUICtrlSetTip

Function Reference

GUICtrlSetTip

Sets the tip text associated with a control.

GUICtrlSetTip ( controlID, tiptext )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
tiptext | Tip text that will be displayed when the mouse is hovered over the control.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICtrlSet...

Example

#include <GUIConstants.au3>

GUICreate("My GUI control tip") ; will create a dialog box that when displayed is centered

GUICtrlCreateLabel ("my label", 10,20)
GUICtrlSetTip(-1,"tip of my label")

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Functions

GUI update Function Reference

Below is a complete list of the GUI update functions available in AutoIt. Click on a function name for a detailed description.

Function | Description
GUISetBkColor | Sets the background color of the GUI window.
GUISetCoord | Sets absolute coordinates for next control.
GUISetCursor | Sets the mouse cursor icon for a GUI window.
GUISetFont | Sets the default font for a GUI window.
GUISetHelp | Sets an executable file that will be run when F1 is pressed.
GUISetIcon | Sets the icon used in a GUI window.
GUISetState | Changes the state of a GUI window.


Function GUISetBkColor

Function Reference

GUISetBkColor

Sets the background color of the GUI window.

GUISetBkColor ( background [, winhandle] )

Parameters

background | Background color of the dialog box.
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Earlier versions of AutoIt (prior to v3.0.102) used the BGR format for defining color - newer versions use RGB by default but this can be changed using the ColorMode option.

Related

ColorMode (Option), GUICreate

Example

#include <GUIConstants.au3>

GUICreate ("My GUI") ; will create a dialog box that when displayed is centered

GUISetBkColor (0xE0FFFF) ; will change background color

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetCoord

Function Reference

GUISetCoord

Sets absolute coordinates for next control.

GUISetCoord ( left, top [, width [, height [, winhandle]]] )

Parameters

left | The left side of the control.
top | The top of the control.
width | [optional] The width of the control (default is the previously used width).
height | [optional] The height of the control (default is the previously used height).
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

To be used specially in Opt ("GUICoordMode", 2). It allows you to set the current position to a precise point and from that postion to create controls by row (x_offset,-1) or by columns (-1, y_offset).

Related

GUICtrlCreate...

Example

#include <GUIConstants.au3>

Opt ("GUICoordMode", 2) ; relative to cell mode

GUICreate ("My GUI Set Coord", 200, 100)
GUICtrlCreateCheckbox ("Check #1", 20, 10, 75)
GUICtrlCreateCheckbox ("Notify #2", 10, -1) ; next cell in the line

GUISetCoord(20,60)

GUICtrlCreateButton ("OK #3", -1,-1)
GUICtrlCreateButton ("Cancel #4", 10, -1)
GUICtrlSetState( -1, $GUI_FOCUS)

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetCursor

Function Reference

GUISetCursor

Sets the mouse cursor icon for a GUI window.

GUISetCursor ( [cursorID [, override [, winhandle]]] )

Parameters

cursorID | [optional] Cursor Id (See Remarks).
override | [optional] Force the requested cursor even when over controls (see below). 0 = (default) Don't override a control's default cursor. 1= override control's default cursor.
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used Window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

If the cursorID is invalid the standard arrow will be displayed.

Usually when you move the cursor over an edit control or other control the cursor changes shape. The "override" option allows you to force the requested cursor to be shown at all times. Note: If you have changed a controls cursor with GUICtrlSetCursor then this control cursor will always be shown.

For a list of valid cursor IDs see MouseGetCursor.

Related

GUICtrlSetCursor

Example

#include <GUIConstants.au3>

$IDC = -1
$newIDC = 0

HotkeySet("{Esc}", "Increment")

GUICreate("Press Esc to Increment", 400, 400,0,0,0x04CF0000, 0x00000110)

GUISetState ()

While GUIGetMsg()<> $GUI_EVENT_CLOSE
If $newIDC <> $IDC Then
$IDC = $newIDC
GUISetCursor($IDC)
EndIf
ToolTip("GUI Cursor #" & $IDC)
WEnd
Exit

Func Increment()
$newIDC = $IDC + 1
If $newIDC > 15 Then $newIDC = 0
EndFunc


Function GUISetFont

Function Reference

GUISetFont

Sets the default font for a GUI window.

GUISetFont (size [, weight [, attribute [, fontname [, winhandle]]]] )

Parameters

size | Fontsize (default is 9).
weight | [optional] Font weight (default 400 = normal).
attribute | [optional] To define italic:2 underlined:4 strike:8 char format (add together the values of all the styles required, 2+4 = italic and underlined).
fontname | [optional] Font to use. (OS default GUI font is used if the font is "" or is not found).
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

See the Appendix for a complete list of fonts and the operating systems under which they are supported.

Size can be with decimal as 8.5.

Related

GUICtrlSetFont

Example

#include <GUIConstants.au3>

GUICreate ("My GUI default font") ; will create a dialog box that when displayed is centered

$font="Comic Sans MS"
GUISetFont (9, 400, 4, $font) ; will display underlined characters
GUICtrlCreateLabel ("underlined label",10,20)

GUISetFont (9, 400, 2, $font) ; will display underlined characters
GUICtrlCreateLabel ("italic label", 10,40)

GUISetFont (9, 400, 8, $font) ; will display underlined characters
GUICtrlCreateLabel ("strike label",10,60)

GUISetState ()

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetHelp

Function Reference

GUISetHelp

Sets an executable file that will be run when F1 is pressed.

GUISetHelp ( helpfile [, winhandle] )

Parameters

helpfile | file that will be run if F1 is pressed when the GUI is active.
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICreate

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

GUISetHelp("notepad") ; will run notepad if F1 is typed

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetIcon

Function Reference

GUISetIcon

Sets the icon used in a GUI window.

GUISetIcon ( iconfile [, iconID [, winhandle]] )

Parameters

iconfile | used to display the icon in the title area.
iconID | [optional] The ID of the icon in the iconfile. (Default is -1).
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICreate

Example

#include <GUIConstants.au3>

GUICreate ("My GUI new icon") ; will create a dialog box that when displayed is centered

GUISetIcon ("autosave.ico") ; will change icon

GUISetState ( ); will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUISetOnEvent

Function Reference

GUISetOnEvent

Defines a user function to be called when a control is clicked.

GUISetOnEvent ( specialID, "function" [, winhandle] )

Parameters

specialID | See the State table below.
function | The name of the user function to call.
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

OnEvent functions are only called when the option GUIOnEventMode is set to 1 - when in this mode GUIGetMsg is NOT used at all.

Special ID table
Special Id | Comments
$GUI_EVENT_CLOSE | dialog box being closed (either by defined button or system menu).
$GUI_EVENT_MINIMIZE | dialog box minimized with Windows title bar button.
$GUI_EVENT_RESTORE | dialog box restored by click on task bar icon.
$GUI_EVENT_MAXIMIZE | dialog box maximized with Windows title bar button.
$GUI_EVENT_MOUSEMOVE | the mouse cursor has moved
$GUI_EVENT_PRIMARYDOWN | the primary mouse button was pressed
$GUI_EVENT_PRIMARYUP | the primary mouse button was released
$GUI_EVENT_SECONDARYDOWN | the secondary mouse button was pressed
$GUI_EVENT_SECONDARYUP | the secondary mouse button was released

Related

GUIOnEventMode (Option), GUICtrlSetOnEvent

Example

#include <GUIConstants.au3>

Opt("GUICoordMode",2)
Opt("GUIResizeMode", 1)
Opt("GUIOnEventMode", 1)

$parent1 = GUICreate("Parent1")
GUISetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GUISetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")

$ok1 = GUICtrlCreateButton ("OK", 10, 30, 50)
GUICtrlSetOnEvent(-1, "OKPressed")

$cancel1 = GUICtrlCreateButton ( "Cancel", 0, -1)
GUICtrlSetOnEvent(-1, "CancelPressed")

GUISetState(@SW_SHOW)

; Just idle around
While 1
Sleep(10)
Wend

; END

Func OKPressed()
MsgBox(0, "OK Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
EndFunc

Func CancelPressed()
MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
EndFunc

Func SpecialEvents()

Select
Case @GUI_CTRLID = $GUI_EVENT_CLOSE
MsgBox(0, "Close Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
Exit

Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

Case @GUI_CTRLID = $GUI_EVENT_RESTORE
MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)

EndSelect

EndFunc


Function GUISetState

Function Reference

GUISetState

Changes the state of a GUI window.

GUISetState ( [flag [, winhandle]] )

Parameters

flag | [optional] @SW_SHOW = Shows a previously hidden window (default) @SW_HIDE = Hide window @SW_MINIMIZE = Minimize window @SW_RESTORE = Undoes a window minimization @SW_DISABLE = Disables the window @SW_ENABLE = Enables the window
winhandle | [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

When windows are created they are intially hidden so you must use this function to display them (@SW_SHOW).

Related

GUICreate

Example

#include <GUIConstants.au3>

GUICreate ("My GUI") ; start the definition

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend


Function GUIDelete

Function Reference

GUIDelete

Deletes a GUI window and all controls that it contains.

GUIDelete ( [winhandle] )

Parameters

winhandle [optional] Windows handle as returned by GUICreate (default is the previous used).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

GUICreate

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

GUIDelete(); ; will return 1


Function GUICtrlGetState

Function Reference

GUICtrlGetState

Gets the current state of a control

GUICtrlGetState ( [controlID] )

Parameters

controlID [optional] The control identifier (controlID) as returned by a GUICtrlCreate... function.

Return Value

Returns the state. See GUICtrlSetState for values.

Remarks

As opposed to GUICtrlRead this function returns only the state of a control (disabled/hidden/etc)

Exceptions:
For ListView controls it returns the number of the clicked column.

Related

GUICtrlRead, GUICtrlSetState

Example

#include <GUIConstants.au3>

GUICreate ("My GUI (GetControlState)")
$n=GUICtrlCreateCheckbox ("checkbox",10,10)
GUICtrlSetState (-1,1) ; checked

GUISetState () ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg()

If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

msgbox (0,"state",StringFormat("GUICtrlRead=%d\nGUICtrlGetState=%d",GUICtrlRead($n),GUICtrlGetState($n)))


Function GUICtrlRead

Function Reference

GUICtrlRead

Read state or data of a control.

GUICtrlRead ( controlID )

Parameters

controlID The control identifier (controlID) as returned by a GUICtrlCreate... function.

Return Value

Success: | Returns depending the control (see below).
Failure: | Returns 0.
Type | Value
Checkbox, Radio | state of the button. See State table
Combo, List | The value selected
Input, Edit | The text entered
Button | The display text
Date | The selected date
Progress | Current percentage
Slider | Current value
Tab | The number of the tabitem selected
Menu, MenuItem | State of the menu/item. See State table
TreeView | Control identifier (controlID) of the selected TreeViewItem
TreeViewItem | State of the TreeViewItem
ListView | Control identifier (controlID) of the selected ListViewItem. 0 means no item is selected
Dummy | The value set by GUICtrlSendToDummy or GUICtrlSetData

Remarks

None.

Related

GUICtrlSet..., GUIGetMsg

Example

#include <GUIConstants.au3>

GUICreate("My GUICtrlRead") ; will create a dialog box that when displayed is centered

$n1=GUICtrlCreateList ("", 10,10,-1,100 )

GUICtrlSetData(-1,"item1|item2|item3", "item2")

$n2=GUICtrlCreateButton ("button",0,100)
GUICtrlSetState(-1,$GUI_FOCUS) ; the focus is on this button

GUISetState () ; will display an empty dialog box
; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
if $msg = $n2 then
msgbox(0,"list=", GUICtrlRead($n1)) ; display the value
endif
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlRecvMsg

Function Reference

GUICtrlRecvMsg

Send a message to a control and retrieve information in lParam.

GUICtrlRecvMsg ( controlID , msg [, wParam [, lParamType]] )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
msg | type of message to be send to the control as defined in the Windows controls documentation.
wParam | [optional] An integer first param to be send to the control.
lParamType | [optional] Define the type of lParam that will be returned: 0 (default) for wParam and lParam, 1 for lParam String, 2 for lParam RECT struct.

Return Value

Success: | Returns the value returned by the SendMessage Windows API.
Failure: | Returns 0.

Remarks

This function allows the sending of special Windows messages directly to the control using the SendMessage API. It is used to enable special control features not available with the simple GUICtrlRead() and GUICtrlSet...() range of functions.

If the wParam and lParamType parameters are not specified then an array of two elements is returned (LPwParam, LPlParam).

The RECT is returned in an array of 4 elements (Left, Top, Right, Bottom).

Related

GUICtrlSendMsg, GUICtrlSet..., GUIGetMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

$nEdit = GUICtrlCreateEdit ("line 0", 10,10)
GUICtrlCreateButton ("Ok", 20,200,50)

GUISetState ()

for $n=1 to 5
GUICtrlSetData ($nEdit, @CRLF & "line "& $n)
next

$EM_GETSEL = 0x00B0

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
if $msg >0 then
$a=GUICtrlRecvMsg($nEdit, $EM_GETSEL)
GUICtrlSetState($nEdit,$GUI_FOCUS) ; set focus back on edit control

; will display the wParam and lParam values return by the control
MsgBox(0,"Current selection",StringFormat("start=%d end=%d", $a[0], $a[1]))
endif
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlSendMsg

Function Reference

GUICtrlSendMsg

Send a message to a control.

GUICtrlSendMsg ( controlID, msg , wParam, lParam )

Parameters

controlID | The control identifier (controlID) as returned by a GUICtrlCreate... function.
msg | type of message to be send to the control as defined in the Windows control documentation.
wParam | The first param to send to the control.
lParam | The second param to send to the control.

Return Value

Success: | Returns the value returned by the SendMessage Windows API.
Failure: | Returns 0.

Remarks

This function allows the sending of special Windows messages directly to the control using the SendMessage API. It is used to enable special control features not available with the simple GUICtrlRead() and GUICtrlSet...() range of functions.

The parameters (wParam and lParam) can be an integer or a string.

GUICtrlSendMsg should be used for messages that have no special return types. For more advanced messages where you must be able to receive extra data you must use GUICtrlRecvMsg().

Related

GUICtrlRecvMsg, GUICtrlCreate..., GUICtrlSet..., GUIMsg, GUICtrlRead

Example

#include <GUIConstants.au3>

GUICreate("My GUI") ; will create a dialog box that when displayed is centered

$nEdit = GUICtrlCreateEdit ("line 0", 10,10)
GUICtrlCreateButton ("Ok", 20,200,50)
GUISetState ()

for $n=1 to 5
GUICtrlSetData ($nEdit,@CRLF & "line "& $n)
next

$EM_LINEINDEX = 0x00BB
$EM_LINEFROMCHAR = 0x00C9

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
if $msg >0 then
$n=GUICtrlSendMsg ($nEdit, $EM_LINEINDEX,-1,0)
$nline=GUICtrlSendMsg( $nEdit, $EM_LINEFROMCHAR,$n,0)
GUICtrlSetState ($nEdit,256) ; set focus

MsgBox (0,"Currentline",$nLine)
endif
Until $msg = $GUI_EVENT_CLOSE


Function GUICtrlSendToDummy

Function Reference

GUICtrlSendToDummy

Sends a message to a Dummy control.

GUICtrlSendToDummy ( controlID [, state] )

Parameters

controlID | The control identifier (controlID) as returned by GUICtrlCreateDummy
state | [optional] value that can be retrieved later on by GUICtrlRead

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

When this function is called a notification that can be handled through the message loop or with a OnEvent function is generated (as if the control had been "clicked" on).

Related

GUICtrlCreateDummy, GUICtrlSetOnEvent, GUICtrlRead

Example

#include <GUIConstants.au3>
Opt("GUIOnEventMode", 1)

GUICreate("GUISendToDummy",220,200, 100,200)
GUISetBkColor (0x00E0FFFF) ; will change background color
GUICtrlSetOnEvent($GUI_EVENT_CLOSE, "OnClick") ; to handle click on button

$user = GUICtrlCreateDummy()
GUICtrlSetOnEvent(-1, "Onexit") ; to handle click on button
$button = GUICtrlCreateButton ("event",75,170,70,20)
GUICtrlSetOnEvent(-1, "OnClick") ; to handle click on button
GUISetState()

While 1
Sleep (100)
Wend

Exit

Func OnClick()
GUICtrlSendToDummy($user) ; fired dummy control
EndFunc

Func OnExit()
; special action before exiting
Exit
EndFunc


Function GUIGetCursorInfo

Function Reference

GUIGetCursorInfo

Gets the mouse cursor position relative to GUI window.

GUIGetCursorInfo ( [winhandle] )

Parameters

winhandle [optional] The handle of the window to use. If omitted the "current" window will be used.

Return Value

If successful, returns a two-element array that containing the cursor information:
$array[0] = X coord (horizontal)
$array[1] = Y coord (vertical)
$array[2] = Primary down (1 if pressed, 0 if not pressed)
$array[3] = Secondary down (1 if pressed, 0 if not pressed)
$array[4] = ID of the control that the cursor is hovering over (or 0 if none)

Remarks

The coordinates given are relative to the GUI window (known as client coords).

If the "winhandle" parameter is used then the specified window becomes the new "current" window.

Related

None.

Example

#include <GUIConstants.au3>
$IDC = 0
HotkeySet("{Esc}", "GetPos")

GUICreate("Press Esc to Get Pos", 400, 400)
$x=GUICtrlCreateLabel ("0", 10, 10,50)
$y=GUICtrlCreateLabel ("0", 10, 30,50)
GUISetState()

; Run the GUI until the dialog is closed
Do
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
Exit

Func GetPos()
$a=GUIGetCursorInfo()
GUIctrlSetData($x,$a[0])
GUIctrlSetData($y,$a[1])
EndFunc


Function GUIGetMsg

Function Reference

GUIGetMsg

Polls the GUI to see if any events have ocurred.

GUIGetMsg ( [advanced] )

Parameters

advanced [optional] return extended information in an array.
0 = (default) Returns a single event.
1 = returns an array containing the event and extended information.

Return Value

Returns an event, or an array depending on the "advanced" parameter.
The "event" returned is the control ID of the control sending the message, or it is a special event (like the window is closing, minimizing). Or if there is no message, the event is 0.

Event IDs
0 | No event
Control ID | the ID of the control sending the message
$GUI_EVENT_CLOSE | dialog box being closed (either by defined button or system menu).
$GUI_EVENT_MINIMIZE | dialog box minimized with Windows title bar button.
$GUI_EVENT_RESTORE | dialog box restored by click on task bar icon.
$GUI_EVENT_MAXIMIZE | dialog box maximized with Windows title bar button.
$GUI_EVENT_MOUSEMOVE | the mouse cursor has moved
$GUI_EVENT_PRIMARYDOWN | the primary mouse button was pressed
$GUI_EVENT_PRIMARYUP | the primary mouse button was released
$GUI_EVENT_SECONDARYDOWN | the secondary mouse button was pressed
$GUI_EVENT_SECONDARYUP | the secondary mouse button was released

When using the "advanced" parameter the information is returned in an array with extended information:
$array[0] = 0 or Event ID or Control ID
$array[1] = The window handle the event is from
$array[2] = The control handle the event is from (if applicable)
$array[3] = The current X position of the mouse cursor (relative to the GUI window)
$array[4] = The current Y position of the mouse cursor (relative to the GUI window)

If the GUIOnEventMode option is set to 1 then the return from GUIGetMsg is always 0 and the @error is set to 1.

Remarks

This function automatically idles the CPU when required so that it can be safely used in tight loops without hogging all the CPU.

Related

GUICreate, GUICtrlCreate..., GUICtrlRead, GUIOnEventMode (Option)

Example

;-------------------------------------------------------------------------------------
; Example - Press the button to see the value of the radio boxes
; The script also detects state changes (closed/minimized/timeouts, etc).

#include <GUIConstants.au3>

Opt("GUICoordMode", 1)
GUICreate("Radio Box Demo", 400,280)

; Create the controls
$button_1 = GUICtrlCreateButton ("B&utton 1", 30, 20, 120, 40)
$group_1 = GUICtrlCreateGroup ("Group 1", 30, 90, 165, 160)
GUIStartGroup()
$radio_1 = GUICtrlCreateRadio ("Radio &0", 50, 120, 70, 20)
$radio_2 = GUICtrlCreateRadio ("Radio &1", 50, 150, 60, 20)
$radio_3 = GUICtrlCreateRadio ("Radio &2", 50, 180, 60, 20)

; Init our vars that we will use to keep track of GUI events
$radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
$radioval2 = 2

; Show the GUI
GUISetState ()

; In this message loop we use variables to keep track of changes to the radios, another
; way would be to use GUICtrlRead() at the end to read in the state of each control
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
MsgBox(0, "", "Dialog was closed")
Exit
Case $msg = $GUI_EVENT_MINIMIZE
MsgBox(0,"", "Dialog minimized",2)
Case $msg = $GUI_EVENT_MAXIMIZE
MsgBox(0,"", "Dialog restored",2)

Case $msg = $button_1
MsgBox(0, "Default button clicked", "Radio " & $radioval1 )

Case $msg >= $radio_1 AND $msg <= $radio_3
$radioval1 = $msg - $radio_1

EndSelect
WEnd


Function GUIStartGroup

Function Reference

GUIStartGroup

Defines that any subsequent controls that are created will be "grouped" together.

GUIStartGroup ( [winhandle] )

Parameters

winhandle [optional] Windows handle as returned by GUICreate (default is the previously used window).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

This function is generally used when working with radio button controls. When you click a radio button all other radio buttons in the same grouping are reset. The GUIStartGroup function allows you to easily define these groups.

Related

GUICtrlCreateGroup

Example

#include <GUIconstants.au3>

Opt("GUICoordMode", 1)

GUICreate("Radio Box Grouping Demo", 400,280)

; Create the controls
$button_1 = GUICtrlCreateButton ("B&utton 1", 30, 20, 120, 40)
$group_1 = GUICtrlCreateGroup ("Group 1", 30, 90, 165, 160)
GUIStartGroup()
$radio_1 = GUICtrlCreateRadio ("Radio &0", 50, 120, 70, 20)
$radio_2 = GUICtrlCreateRadio ("Radio &1", 50, 150, 60, 20)
$radio_3 = GUICtrlCreateRadio ("Radio &2", 50, 180, 60, 20)
GUIStartGroup()
$radio_4 = GUICtrlCreateRadio ("Radio &A", 120, 120, 70, 20)
$radio_5 = GUICtrlCreateRadio ("Radio &B", 120, 150, 60, 20)
$radio_6 = GUICtrlCreateRadio ("Radio &C", 120, 180, 60, 20)
GUIStartGroup()
$input_1 = GUICtrlCreateInput ("Input 1", 200, 20, 160, 30)
$input_2 = GUICtrlCreateInput ("Input 2", 200, 70, 160, 30)

; Set the defaults (radio buttons clicked, default button, etc)
GUICtrlSetState($radio_1, $GUI_CHECKED)
GUICtrlSetState($radio_6, $GUI_CHECKED)
GUICtrlSetState($button_1, $GUI_FOCUS + $GUI_DEFBUTTON)

; Init our vars that we will use to keep track of radio events
$radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button
$radioval2 = 2

GUISetState ()

; In this message loop we use variables to keep track of changes to the radios, another
; way would be to use GUICtrlRead() at the end to read in the state of each control. Both
; methods are equally valid
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit

Case $msg = $button_1
MsgBox(0, "Button", "Radio " & $radioval1 & @LF & "Radio " & Chr($radioval2 + Asc("A")) & @LF & GUICtrlRead($input_1) & @LF & GUICtrlRead($input_2))

Case $msg = $radio_1 OR $msg = $radio_2 OR $msg = $radio_3
$radioval1 = $msg - $radio_1

Case $msg = $radio_4 OR $msg = $radio_5 OR $msg = $radio_6
$radioval2 = $msg - $radio_4

EndSelect
WEnd


Function GUISwitch

Function Reference

GUISwitch

Switches the current window used for GUI functions.

GUISwitch ( winhandle )

Parameters

winhandle The handle of the window to switch to.

Return Value

Success: | Returns the handle of the previously current.
Failure: | Returns a NULL handle.

Remarks

Many of the GUI specific functions work on the "current" window - this is usually the last window created with GUICreate. This function allows you to make another window "current".

Related

GUICreate, GUIDelete

Example

#include <GUIConstants.au3>

$parent1= GUICreate("Parent1")
$parent2= GUICreate("Parent2", -1, -1, 100, 100)

GUISwitch($parent2)
GUISetState()
Do
$msg=GUIGetMsg()
until $msg = $GUI_EVENT_CLOSE

GUISwitch($parent1)
GUISetState()
Do
$msg=GUIGetMsg()
until $msg = $GUI_EVENT_CLOSE


Function HotKeySet

Function Reference

HotKeySet

Sets a hotkey that calls a user function.

HotKeySet ( "key" [, "function"] )

Parameters

key | The key(s) to use as the hotkey. Same format as Send().
function | [optional] The name of the function to call when the key is pressed. Leave blank to unset a previous hotkey.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Up to 64 simultaneous hotkeys per script may be registered.

If two AutoIt scripts set the same HotKeys, you should avoid running those scripts simultaneously. (The second script cannot capture the hotkey unless the first script terminates or unregisters the key prior to the second script setting the hotkey.)

A hotkey press *typically* interrupts the active AutoIt function/statement and runs its user function until it completes or is interrupted. Exceptions are as follows:
1) If the current function is a "blocking" function, then the keypresses are buffered and execute as soon as the blocking function completes. MsgBox and FileSelectFolder are examples of blocking functions. Try the behavior of Shift-Alt-d in the Example.
2) If you have paused the script by clicking on the AutoIt Tray icon, any hotkeys pressed during this paused state are ignored.

The following hotkeys cannot be set:

Ctrl+Alt+Delete | It is reserved by Windows
F12 | It is also reserved by Windows, according to its API.
NumPad's Enter Key | Instead, use {Enter} which captures both Enter keys on the keyboard.
Win+B,D,E,F,L,M,R,U; and Win+Shift+M | These are built-in Windows shortcuts. Note: Win+B and Win+L might only be reserved on Windows XP and above.
Alt, Ctrl, Shift, Win | These are the modifier keys themselves!
Other | Any global hotkeys a user has defined using third-party software, any combos of two or more "base keys" such as '{F1}{F2}', and any keys of the form '{LALT}' or '{ALTDOWN}'.

When you set a hotkey, AutoIt captures the keypress and does not pass it on to the active application--with one exception: The Lock keys (NumLock, CapsLock, and ScrollLock) still toggle their respective state! If you wish to send the captured hotkey to the active application you must unregister the hotkey before invoking Send or must use ControlSend:

; capture and pass along a keypress
HotKeySet("{Esc}", "captureEsc")
Func captureEsc()
; ... can do stuff here
HotKeySet("{Esc}")
Send("{Esc}")
HotKeySet("{Esc}", "captureEsc")
EndFunc

Related

Send, ControlSend

Example

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d

;;;; Body of program would go here ;;;;
While 1
Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0)
WEnd
ToolTip("")
EndFunc

Func Terminate()
Exit 0
EndFunc

Func ShowMessage()
MsgBox(4096,"","This is a message.")
EndFunc


Function Send

Function Reference

Send

Sends simulated keystrokes to the active window.

Send ( "keys" [, flag] )

Parameters

keys | The sequence of keys to send.
flag | [optional] Changes how "keys" is processed: flag = 0 (default), Text contains special characters like + and ! to indicate SHIFT and ALT key presses. flag = 1, keys are sent raw.

Return Value

None.

Remarks

See the Appendix for some tips on using Send. AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to send (see {ASC} at the bottom of the table below).

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

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

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

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

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

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

'#'
The hash now sends a Windows keystroke; therefore, Send("#r") would send Win+r which launches the Run dialog box.

You can set SendCapslockMode to make CAPS LOCK disabled at the start of a Send operation and restored upon completion.
However, if a user is holding down the Shift key when a Send function begins, text may be sent in uppercase.
One workaround is to Send("{SHIFTDOWN}{SHIFTUP}") before the other Send operations.

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

N.B. Windows does not allow the simulation of the "CTRL-ALT-DEL" combination!
Send Command (if zero flag) | Resulting Keypress
{!} | !
{#} | #
{+} | +
{^} | ^
{{} | {
{}} | }
{SPACE} | SPACE
{ENTER} | ENTER key on the main keyboard
{ALT} | ALT
{BACKSPACE} or {BS} | BACKSPACE
{DELETE} or {DEL} | DELETE
{UP} | Cursor up
{DOWN} | Cursor down
{LEFT} | Cursor left
{RIGHT} | Cursor right
{HOME} | HOME
{END} | END
{ESCAPE} or {ESC} | ESCAPE
{INSERT} or {INS} | INS
{PGUP} | PageUp
{PGDN} | PageDown
{F1} - {F12} | Function keys
{TAB} | TAB
{PRINTSCREEN} | Print Screen key
{LWIN} | Left Windows key
{RWIN} | Right Windows key
{NUMLOCK on} | NUMLOCK (on/off/toggle)
{CAPSLOCK off} | CAPSLOCK (on/off/toggle)
{SCROLLLOCK toggle} | SCROLLLOCK (on/off/toggle)
{CTRLBREAK} | Ctrl+Break
{PAUSE} | PAUSE
{NUMPAD0} - {NUMPAD9} | Numpad digits
{NUMPADMULT} | Numpad Multiply
{NUMPADADD} | Numpad Add
{NUMPADSUB} | Numpad Subtract
{NUMPADDIV} | Numpad Divide
{NUMPADDOT} | Numpad period
{NUMPADENTER} | Enter key on the numpad
{APPSKEY} | Windows App key
{LALT} | Left ALT key
{RALT} | Right ALT key
{LCTRL} | Left CTRL key
{RCTRL} | Right CTRL key
{LSHIFT} | Left Shift key
{RSHIFT} | Right Shift key
{SLEEP} | Computer SLEEP key
{ALTDOWN} | Holds the ALT key down until {ALTUP} is sent
{SHIFTDOWN} | Holds the SHIFT key down until {SHIFTUP} is sent
{CTRLDOWN} | Holds the CTRL key down until {CTRLUP} is sent
{LWINDOWN} | Holds the left Windows key down until {LWINUP} is sent
{RWINDOWN} | Holds the right Windows key down until {RWINUP} is sent
{ASC nnnn} | Send the ALT+nnnn key combination
{BROWSER_BACK} | 2000/XP Only: Select the browser "back" button
{BROWSER_FORWARD} | 2000/XP Only: Select the browser "forward" button
{BROWSER_REFRESH} | 2000/XP Only: Select the browser "refresh" button
{BROWSER_STOP} | 2000/XP Only: Select the browser "stop" button
{BROWSER_SEARCH} | 2000/XP Only: Select the browser "search" button
{BROWSER_FAVORITES} | 2000/XP Only: Select the browser "favorites" button
{BROWSER_HOME} | 2000/XP Only: Launch the browser and go to the home page
{VOLUME_MUTE} | 2000/XP Only: Mute the volume
{VOLUME_DOWN} | 2000/XP Only: Reduce the volume
{VOLUME_UP} | 2000/XP Only: Increase the volume
{MEDIA_NEXT} | 2000/XP Only: Select next track in media player
{MEDIA_PREV} | 2000/XP Only: Select previous track in media player
{MEDIA_STOP} | 2000/XP Only: Stop media player
{MEDIA_PLAY_PAUSE} | 2000/XP Only: Play/pause media player
{LAUNCH_MAIL} | 2000/XP Only: Launch the email application
{LAUNCH_MEDIA} | 2000/XP Only: Launch media player
{LAUNCH_APP1} | 2000/XP Only: Launch user app1
{LAUNCH_APP2} | 2000/XP Only: Launch user app2

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

(When using 2 digit ASCII codes you must use a leading 0, otherwise an obselete 437 code page is used).

To send UNICODE characters enter the character code, for example this sends a Chinese character
Send("{ASC 2709}")

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

To hold a key down (generally only useful for games)
Send("{a down}") ;Holds the A key down
Send("{a up}") ;Releases the A key

To set the state of the capslock, numlock and scrolllock keys
Send("{NumLock on}") ;Turns the NumLock key on
Send("{CapsLock off}") ;Turns the CapsLock key off
Send("{ScrollLock toggle}") ;Toggles the state of ScrollLock

If you with to use a variable for the count, try
$n = 4
Send("+{TAB " & $n & "}")

If you wish to send the ASCII value A four times, then try
$x = Chr(65)
Send("{" & $x & " 4}")

Most laptop computer keyboards have a special Fn key. This key cannot be simulated.

Note, by setting the flag parameter to 1 the above "special" processing will be disabled. This is useful when you want to send some text copied from a variable and you want the text sent exactly as written.

For example, open Folder Options (in the control panel) and try the following:
Send("{TAB}") | Navigate to next control (button, checkbox, etc)
Send("+{TAB}") | Navigate to previous control.
Send("^{TAB}") | Navigate to next WindowTab (on a Tabbed dialog window)
Send("^+{TAB}") | Navigate to previous WindowTab.
Send("{SPACE}") | Can be used to toggle a checkbox or click a button.
Send("{+}") | Usually checks a checkbox (if it's a "real" checkbox.)
Send("{-}") | Usually unchecks a checkbox.
Send("{NumPadMult}") | Recursively expands folders in a SysTreeView32.

Use Alt-key combos to access menu items. Also, open Notepad and try the following:
Send("!f") Send Alt+f, the access key for Notepad's file menu. Try other letters!

Send("{DOWN}") | Move down a menu.
Send("{UP}") | Move up a menu.
Send("{LEFT}") | Move leftward to new menu or expand a submenu.
Send("{RIGHT}") | Move rightward to new menu or collapse a submenu.
See Windows' Help--press Win+F1--for a complete list of keyboard shortcuts if you don't know the importance of Alt+F4, PrintScreen, Ctrl+C, and so on.

Related

SendAttachmode (Option), SendKeyDelay (Option), SendKeyDownDelay (Option), ControlSend

Example

Send("#r")
WinWaitActive("Run")
Send("notepad.exe{Enter}")
WinWaitActive("Untitled -")
Send("Today's time/date is {F5}")


Function Abs

Function Reference

Abs

Calculates the absolute value of a number.

Abs ( expression )

Parameters

expression Any valid numeric expression.

Return Value

Returns absolute value of expression.

Remarks

A string has a value of zero.

Related

None.

Example

$var = Abs(-123.45) ;value is 123.45


Function ACos

Function Reference

ACos

Calculates the arcCosine of a number.

ACos ( expression )

Parameters

expression Any value between -1 and 1 inclusive.

Return Value

Returns the trigonometric arccosine of expression. Result is in radians.

Remarks

ACos(x) is mathematically defined only for -1 < x < 1, so ACos tends to return -1.#IND for other values of x.

Related

Sin, Cos, Tan, ASin, ATan

Example

$x = ACos(0.5)

$pi = 3.14159265358979
$radToDeg = 180 / $pi
$y = ACos(-1) * $radToDeg ;arcCosine of -1 returns 180°


Function ASin

Function Reference

ASin

Calculates the arcsine of a number.

ASin ( expression )

Parameters

expression Any value between -1 and 1 (inclusive).

Return Value

Returns the trigonometric arcsine of expression. Result is in radians.

Remarks

ASin(x) is mathematically defined only for -1 < x < 1, so ASin tends to return -1.#IND for other values of x.

Related

Sin, Cos, Tan, ACos, ATan

Example

$x = ASin(0.5)

$pi = 3.14159265358979
$radToDeg = 180 / $pi
$y = ASin(1) * $radToDeg ;arcsine of 1 returns 90°


Function ATan

Function Reference

ATan

Calculates the arctangent of a number.

ATan ( expression )

Parameters

expression Any valid numeric expression.

Return Value

Returns the trigonometric arctangent of expression. Result is in radians.

Remarks

The result of 4 * ATan(1) is pi.

Related

Sin, Cos, Tan, ASin, ACos

Example

$x = ATan(0.5)

$pi = 4 * ATan(1) ;equals 3.14159265358979
$radToDeg = 180 / $pi
$y = ATan(1) * $radToDeg ;arctangent of 1 returns 45°


Function BitAND

Function Reference

BitAND

Performs a bitwise AND operation.

BitAND ( value1, value2 [, value n] )

Parameters

value1 | The first number.
value2 | The second number.
value n | [optional] The nth number - up to 255 values can be specified.

Return Value

Returns the value of the parameters bitwise-AND'ed together.

Remarks

Remember hex notation can be used for numbers.
Remember that AND returns 1 iff both bits are 1 and returns 0 otherwise.

Related

BitNOT, BitOR, BitShift, BitXOR, Hex

Example

$x = BitAND(13, 7) ;x == 5 because 1101 AND 0111 = 0101

$x = BitAND(2, 3, 6) ;x == 2 because 0010 AND 0011 AND 0110 = 0010


Function BitNOT

Function Reference

BitNOT

Performs a bitwise NOT operation.

BitNOT ( value )

Parameters

value The number to operate on.

Return Value

Returns the bitwise NOT of the value.
Bit operations are performed as 32-bit integers.

Remarks

Remember hex notation can be used for numbers.
Remember that in 2's-complement notation, BitNOT is functionally equivalent to adding 1 and negating the result.
Also remember that NOT changes a 0 bit to 1 and vice-versa.

Related

BitAND, BitOR, BitShift, BitXOR, Hex

Example

$x = BitNot(5)

#cs Comments:
Result is -6 because for 32-bit numbers
5 == 00000000000000000000000000000101 binary
-6 == 11111111111111111111111111111010 binary
and the first bit is signed
#ce


Function BitOR

Function Reference

BitOR

Performs a bitwise OR operation.

BitOR ( value1, value2 [, value n] )

Parameters

value1 | The first number.
value2 | The second number.
value n | [optional] The nth number - up to 255 values can be specified.

Return Value

Returns the two parameters bitwise-OR'ed together.

Remarks

Remember hex notation can be used for numbers.
Remember that OR returns 0 if both bits are 0 and returns 1 otherwise.

Related

BitAND, BitNOT, BitShift, BitXOR, Hex

Example

$x = BitOR(3, 6) ;x == is 7 because 0011 OR 0110 = 0111

$x = BitOR(3, 15, 32) ;x == 47 because 0011 OR 1111 OR 00100000 = 00101111


Function BitShift

Function Reference

BitShift

Performs a bit shifting operation.

BitShift ( value, shift )

Parameters

value | The first number to operate on.
shift | Number of bits to shift to the right (negative numbers shift left).

Return Value

Returns the value shifted by the required number of bits.
Bit operations are performed as 32-bit integers.

Remarks

Remember hex notation can be used for numbers.
Left shifts are equivalent to halving; right shifts to doubling.

Related

BitAND, BitNOT, BitOR, BitXOR, Hex

Example

$x = BitShift(14, 2)
; x == 3 because 1110b right-shifted twice is 11b == 3

$y = BitShift(14, -2)
; y == 48 because 1110b left-shifted twice is 111000b == 56

$z = BitShift( 1, -31)
; z == -2147483648 because in 2's-complement notation, the
; 32nd digit from the right has a negative sign.


Function BitXOR

Function Reference

BitXOR

Performs a bitwise exclusive OR (XOR) operation.

BitXOR ( value1, value2 [, value n] )

Parameters

value1 | The first number.
value2 | The second number.
value n | [optional] The nth number - up to 255 values can be specified.

Return Value

Returns the value of the parameters bitwise-XOR'ed together.
Bit operations are performed as 32-bit integers.

Remarks

Remember hex notation can be used for numbers.
Remember that XOR returns 1 if exactly one bit is 1 and returns 0 otherwise.

Related

BitAND, BitNOT, BitOR, BitShift, Hex

Example

$x = BitXOR(10, 6) ;x == 12 because 1010b XOR 0110b == 1100

$x = BitXOR(2, 3, 6) ;x == 7 because 0010 XOR 0011 XOR 0110 = 0111


Function Cos

Function Reference

Cos

Calculates the cosine of a number.

Cos ( expression )

Parameters

expression Value in radians.

Return Value

Returns the trigonometric cosine of number.

Remarks

1° = pi / 180 radians.

Related

Sin, Tan, ASin, ACos, ATan

Example

$pi = 3.14159265358979
$x = cos($pi / 4)

$degToRad = $pi / 180
$y = Cos(90 * $degToRad) ;cosine of 90°


Function Exp

Function Reference

Exp

Calculates e to the power of a number.

Exp ( expression )

Parameters

expression Any valid numeric expression.

Return Value

Returns e raised to the power of expression.

Remarks

e is the base of the natural logarithm and is approximately 2.71828182845905

Related

Log

Example

$x = Exp(5) ;returns 148.413159102577


Function Log

Function Reference

Log

Calculates the natural logarithm of a number.

Log ( expression )

Parameters

expression Any positive number.

Return Value

Success: | Returns the parameter's natural logarithm.
Failure: | Tends to return -1.#IND for non-positive parameters.

Remarks

@error is always 0

Related

Exp

Example

$x = Log(1000) ;returns 6.90775527898214

$y = Log10(1000) ;returns 3

; user-defined function for common log
Func Log10($x)
Return Log($x) / Log(10) ;10 is the base
EndFunc


Function Mod

Function Reference

Mod

Performs the modulus operation.

Mod ( value1, value2 )

Parameters

value1 | The dividend.
value2 | The divisor.

Return Value

Success: | Returns the remainder when value1 is divided by value2.
Failure: | Returns -1.#IND if the divisor is zero.

Remarks

quotient = dividend / divisor
This function works with floats as well as integers.

Related

None.

Example

$n = 18
If mod($n, 2) = 0 Then
MsgBox(0,"", $n & " is an even number.")
Else
MsgBox(0, "", $n & " is an odd number.")
EndIf

$x = mod(4, 7) ;$x == 4 because the divisor > dividend

$y = mod(1, 3/4) ;$y == 0.25 because the divisor is a float


Function Random

Function Reference

Random

Generates a pseudo-random float-type number.

Random ( [Min [, Max [, Flag]]] )

Parameters

Min | [optional] The smallest number to be generated. The default is 0.
Max | [optional] The largest number to be generated. The default is 1.
Flag | [optional] If this is set to 1 then an integer result will be returned. Default is a floating point number.

Return Value

Success: | Returns a pseudo-random number between Min and Max.
Failure: | Returns 0 and sets @error flag:
 | 0 success.
 | 1 Bad parameters.

Remarks

By default the Random function works with decimal/floating point numbers. If you want to only have integer/whole number results then set the Flag to 1.

If only one argument is provided, then it is interpreted to be the Max.

The result will be in the range of Min to Max INCLUSIVE when using integers (just short of Max when using floats).

Comments based on the original source

This function uses the Mersenne Twister random number generator, MT19937, written by Takuji Nishimura, Makoto Matsumoto, Shawn Cokus, Matthe Bellew and Isaku Wada.

The Mersenne Twister is an algorithm for generating random numbers. It was designed with consideration of the flaws in various other generators. The period, 219937-1, and the order of equidistribution, 623 dimensions, are far greater. The generator is also fast; it avoids multiplication and division, and it benefits from caches and pipelines. For more information see the inventors' web page at http://www.math.keio.ac.jp/~matumoto/emt.html

Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The names of its contributors may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Related

Int, Round

Example

;Flip of coin
If Random() < 0.5 Then ; Returns a value between 0 and 1.
$msg = "Heads. 50% Win"
Else
$msg = "Tails. 50% Loss"
Endif
MsgBox(0,"Coin toss", $msg )

;Roll of a die
msgBox(0, "Roll of die", "You rolled a " & Random(1, 6, 1) )

;In the middle of a stock market simulation game
$StockPriceChange = Random(-10, 10, 1) ; generate an integer between -10 and 10
$StockPrice = $StockPrice + $StockPriceChange
If $StockPriceChange < 0 Then
MsgBox(4096, "Stock Change", "Your stock dropped to $" & $StockPrice)
ElseIf $StockPriceChange > 0 Then
MsgBox(4096, "Stock Change", "Your stock rose to $" & $StockPrice)
Else
MsgBox(4096, "Stock Change", "Your stock stayed at $" & $StockPrice)
Endif

;Random letter
If Random() < 0.5 Then
;Capitals
$Letter = Chr(Random(Asc("A"), Asc("Z"), 1))
Else
;Lower case
$Letter = Chr(Random(Asc("a"), Asc("z"), 1))
Endif


Function Round

Function Reference

Round

Returns a number rounded to a specified number of decimal places.

Round ( expression [, decimalplaces] )

Parameters

expression | Any valid numeric expression.
decimalplaces | [optional] Number indicating how many places to the right of the decimal are included in the rounding. If omitted, Round returns an integer.

Return Value

Returns rounded number.

Remarks

The decimalplaces parameter can be negative which allows you to round to the ones, tens, hundred, etc. place. Note that up to fifteen digits of a number are displayed, and note that decimalplaces will never pad a number with trailing zeros.

Related

Int, Number

Example

$x = Round(-1.582, 1) ;returns -1.6
$y = Round(3.1415, 9) ;no change
$z = round(123.5, -1) ;returns 120


Function Sin

Function Reference

Sin

Calculates the sine of a number.

Sin ( expression )

Parameters

expression Value in radians.

Return Value

Returns the trigonometric sine of number.

Remarks

1° = pi / 180 radians.

Related

Cos, Tan, ASin, ACos, ATan

Example

$pi = 3.14159265358979
$x = sin($pi / 4) ;returns 0.707106781186547 which you should recognize as sqrt(2)/2

$degToRad = $pi / 180
$y = Sin(90 * $degToRad) ;sine of 90°


Function Sqrt

Function Reference

Sqrt

Calculates the square-root of a number.

Sqrt ( expression )

Parameters

number Any nonnegative expression to get the square-root of.

Return Value

Success: | Returns the square-root.
Failure: | Returns 0 and sets @error to 1 if parameter is negative.

Remarks

To compute an nth root, use the power operator: x ^ (1/n)
MsgBox(0,"The cube root of 27 is", 27 ^ (1/3) )

Related

Exp, Log

Example

$x = Sqrt(2) ;returns 1.4142135623731
$y = sqrt(9) ;returns 3


Function Tan

Function Reference

Tan

Calculates the tangent of a number.

Tan ( expression )

Parameters

expression Value in radians.

Return Value

Returns the trigonometric tangent of number.

Remarks

1° = pi / 180 radians.
Note that Tan is "infinite" for ... -3PI/2, -PI/2, PI/2, 3PI/2, 5PI/2, ... and tends to return 1.63317787283838e+016 for such multiples of Pi-halves.

Related

Sin, Cos, ASin, ACos, ATan

Example

$pi = 3.14159265358979
$x = tan($pi / 4)

$degToRad = $pi / 180
$y = Tan(90 * $degToRad) ;tangent of 90°


Function InputBox

Function Reference

InputBox

Displays an input box to ask the user to enter a string.

InputBox ( "title", "Prompt" [, "Default" [, "password char" [, Width, Height [, Left, Top [, TimeOut]]]]] )

Parameters

title | The title of the input box.
prompt | A message to the user indicating what kind of input is expected.
default | The value that the input box starts with.
password char | [optional] The character to replace all typed characters with. If you want the actual typed character to appear, define with an empty string ("") (default) or a space for the first character. If you provide a multiple-char string, only the first char is used for character masking. There are special meanings for the second and subsequent characters. See Remarks.
width | [optional] The width of the window. If defined, height must also be defined. Use -1 for default width.
height | [optional] The height of the window. If defined, width must also be defined. Use -1 for default height.
left | [optional] The left side of the input box. By default, the box is centered. If defined, top must also be defined.
top | [optional] The top of the input box. By default, the box is centered. If defined, left must also be defined.
timeout | [optional] How many seconds to wait before automatically cancelling the InputBox.

Return Value

Success: | Returns the string that was entered.
Failure: | Returns an empty string and sets @error as follows:
@Error | 0 = The string returned is valid.
 | 1 = The Cancel button was pushed.
 | 2 = The Timeout time was reached.
 | 3 = The InputBox failed to open. This is usually caused by bad arguments.

Remarks

BlockInput(1) prevents Windows 98/Me users from inputting data.

The InputBox is user-resizable, but has a minimum size of approximately 190 x 115 pixels. Default size is approximately 250 x 190 pixels.

The string returned will not exceed 254 characters and if input contains carriage returns or linefeeds, the result will be truncated at the first occurrence of those characters.

The second and subsequent characters of the password field can be used to restrict input. Use a space to fill the first character to still see the characters typed. Putting an M after the first character indicates that input is Mandatory; i.e. you must enter something. Nothing will happen if you press the Ok button when there is nothing in the InputBox. It will not close and return the string.

You can also specify the maximum length in the end of the password field. Just enter a number as the last character to specify the length of the string.

Related

MsgBox

Example

;Places the input box in the top left corner displaying the characters as they
;are typed.
$answer = InputBox("Question", "Where were you born?", "Planet Earth", "", _
-1, -1, 0, 0)

;Asks the user to enter a password. Don't forget to validate it!
$passwd = InputBox("Security Check", "Enter your password.", "", "*")

;Asks the user to enter a 1 or 2 character response. The M in the password
;field indicates that blank string are not accepted and the 2 indicates that the
;responce will be at most 2 characters long.
$value = InputBox("Testing", "Enter the 1 or 2 character code.", "", " M2")


Function MsgBox

Function Reference

MsgBox

Displays a simple message box with optional timeout.

MsgBox ( flag, "title", "text" [, timeout] )

Parameters

flag | The flag indicates the type of message box and the possible button combinations. See remarks.
title | The title of the message box.
text | The text of the message box.
timeout | [optional] Timeout in seconds. After the timeout has elapsed the message box will be automatically closed.

Return Value

Success: | Returns the ID of the button pressed.
Failure: | Returns -1 if the message box timed out.
Button Pressed | Return Value
OK | 1
CANCEL | 2
ABORT | 3
RETRY | 4
IGNORE | 5
YES | 6
NO | 7
TRY AGAIN ** | 10
CONTINUE ** | 11

Remarks

The flag parameter can be a combination of the following values:

decimal flag | Button-related Result | hexadecimal flag
0 | OK button | 0x0
1 | OK and Cancel | 0x1
2 | Abort, Retry, and Ignore | 0x2
3 | Yes, No, and Cancel | 0x3
4 | Yes and No | 0x4
5 | Retry and Cancel | 0x5
6 ** | Cancel, Try Again, Continue | 0x6
decimal flag | Icon-related Result | hexadecimal flag
0 | (No icon) | 0x0
16 | Stop-sign icon | 0x10
32 | Question-mark icon | 0x20
48 | Exclamation-point icon | 0x30
64 | Icon consisting of an 'i' in a circle | 0x40
decimal flag | Default-related Result | hexadecimal flag
0 | First button is default button | 0x0
256 | Second button is default button | 0x100
512 | Third button is default button | 0x200
decimal flag | Modality-related Result | hexadecimal flag
0 | Application | 0x0
4096 | System modal (dialog has an icon) | 0x1000
8192 | Task modal | 0x2000
decimal flag | Miscellaneous-related Result | hexadecimal flag
0 | (nothing else special) | 0x0
262144 | MsgBox has top-most attribute set | 0x40000
524288 | title and text are right-justified | 0x80000

** Only valid on Windows 2000/XP and above.

For example, to specify a SYSTEMMODAL box with the YES/NO buttons the flag value would be 4096+4 (or 4100) If using hexadecimal flags, that would be 0x1000+0x4 (or 0x1004).

A message box appears centered on screen and resizes according to the text it contains. However, the title could get truncated if the SYSTEMMODAL flag (4096) is used.

Related

InputBox, ToolTip, TrayTip, SplashTextOn

Example

MsgBox(4096, "Test", "This box will time out in 10 seconds", 10)


Function ProgressOff

Function Reference

ProgressOff

Turns Progress window off.

ProgressOff ( )

Parameters

None.

Return Value

None.

Remarks

None.

Related

ProgressSet, ProgressOn

Example

ProgressOff()


Function ProgressOn

Function Reference

ProgressOn

Creates a customizable progress bar window.

ProgressOn ( "title", "maintext" [, "subtext" [, x pos [, y pos [, opt]]]] )

Parameters

title | Title for progress window.
maintext | Text for Main, Bold, Upper label.
subtext | [optional] text for Sub, Normal, Lower label. (default is blank)
x pos | [optional] position from left (in pixels) of progress window. (default is centered)
y pos | [optional] position from top (in pixels) of progress window. (default is centered)
opt | [optional] Default is 'always on top/with title' Add up the following options you want: 1 = borderless, titleless window 2 = Without "always on top" attribute 16 = Window can be moved

Return Value

None.

Remarks

To skip an optional parameter, leaving it's default value intact, use:
"" for string parameters
-1 for numeric parameters
If ProgressOn is called while a progress window already exists, the window is redrawn/moved. (If you want multiple simultaneous progress windows, you need to use multiple scripts.)

Related

ProgressOff, ProgressSet

Example

ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
sleep(1000)
ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()


Function ProgressSet

Function Reference

ProgressSet

Sets the position and/or text of a previously created Progress bar window.

ProgressSet ( percent [, "subtext" [, "maintext"]] )

Parameters

percent | Percentage (value between 0. and 100.) to set the progress bar at.
subtext | [optional] Set the text for the Sub, Normal, Lower label.
maintext | [optional] Set the text for the Main, Bold, Upper label.

Return Value

None.

Remarks

Notice that the subtext argument comes before maintext.

Related

ProgressOff, ProgressOn

Example

ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
sleep(1000)
ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()


Function SplashImageOn

Function Reference

SplashImageOn

Creates a customizable image popup window.

SplashImageOn ( "title", "file" [, width [, height [, x pos [, y pos [, opt]]]]] )

Parameters

title | Title for splash window.
file | full path\filename of image (BMP, GIF, or JPG)
width | [optional] width of window in pixels. (default is 500)
height | [optional] height of window in pixels. (default is 400)
x pos | [optional] position from left (in pixels) of splash window. (default is centered)
y pos | [optional] position from top (in pixels) of splash window. (default is centered)
opt | [optional] Add up the options you want. Default is 'always on top/with title' 1 = Thin bordered titleless window 2 = Without "always on top" attribute 16 = Windows can be moved

Return Value

None.

Remarks

To skip an optional parameter, leaving it's default value intact, use a value of -1.

The image is scaled to specified width and height and should be a Bitmap, GIF, or JPEG image. Icons (ICOs) will not display, though the window still appears. PNG images throw an error message of failing to load, and so do invalid files/paths.

Images are not embedded in the executable unless you use FileInstall

Only one SplashImage/Text window is allowed at one time; so if you wish to cycle through multiple images/text, simply call SplashImageOn/SplashTextOn again with the new information.

Related

SplashOff, SplashTextOn

Example

$destination = @TempDir & "\mySplash.bmp"
FileInstall("C:\foo.bmp", $destination) ;source must be literal string

SplashImageOn("Splash Screen", $destination)
Sleep(3000)
SplashOff()


Function SplashOff

Function Reference

SplashOff

Turns SplashText or SplashImage off.

SplashOff ( )

Parameters

None.

Return Value

None.

Remarks

None.

Related

SplashImageOn, SplashTextOn

Example

SplashTextOn("Example", "Splash Screen")
Sleep(5000)
SplashOff()


Function SplashTextOn

Function Reference

SplashTextOn

Creates a customizable text popup window.

SplashTextOn ( "title", "text" [, w [, h [, x pos [, y pos [, opt [, "fontname" [, "fontsz" [, "fontwt"]]]]]]]] )

Parameters

title | Title for splash window.
text | Text for splash window.
w | [optional] Width of window in pixels. (default 500)
h | [optional] Height of window in pixels. (default 400)
x pos | [optional] Position from left (in pixels) of splash window. (default is centered)
y pos | [optional] Position from top (in pixels) of splash window. (default is centered)
opt | [optional] Add them up - default is 'center justified/always on top/with title' 0 = Center justified/always on top/with title (default) 1 = Thin bordered titleless window 2 = Without "always on top" attribute 4 = Left justified text 8 = Right justified text 16 = Windows can be moved
fontname | [optional] Font to use. (OS default GUI font is used if the font is "" or is not found)
fontsz | [optional] Font size. (default is 12; standard sizes are 6 8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72)
fontwt | [optional] Font weight (0 - 1000, default = 400 = normal). A value > 1000 is treated as zero.

Return Value

None.

Remarks

To skip an optional parameter, leaving it's default value intact, use:
"" for a string parameters
-1 for a numeric parameters

Only one SplashImage/Text window is allowed at one time; so if you wish to cycle through multiple images/text, simply call SplashImageOn/SplashTextOn again with the new information.

Even better is to use ControlSetText to update text without flicker...

Standard font names include:
Arial, Comic Sans MS, Courier New, Lucida Console, Microsoft Sans Serif, System, Tahoma, Times New Roman, and WingDings
See Appendix for a complete font list

Related

SplashOff, SplashImageOn, ControlSetText, ToolTip

Example

SplashTextOn("Title", "Message goes here.", -1, -1, -1, -1, 4, "", 24)
Sleep(3000)
SplashOff()

;; FLICKER
$message = ""
SplashTextOn("TitleFoo", $message, -1, -1, -1, -1, 4, "")
For $x = 1 to 20
$message = $message & $x & @LF
SplashTextOn("TitleFoo", $message, -1, -1, -1, -1, 4, "")
Sleep(100)
Next

;; SMOOTH
$message = ""
SplashTextOn("TitleFoo", $message, -1, -1, -1, -1, 4, "")
For $x = 1 to 20
$message = $message & $x & @LF
ControlSetText("TitleFoo", "", "Static1", $message)
sleep(100)
Next


Function ToolTip

Function Reference

ToolTip

Creates a tooltip anywhere on the screen.

ToolTip ( "text" [, x [, y]] )

Parameters

text | The text of the tooltip. (An empty string clears a displaying tooltip)
x, y | [optional] The x,y position of the tooltip.

Return Value

None.

Remarks

If the x and y coordinates are omitted the, tip is placed near the mouse cursor. If the coords would cause the tooltip to run off screen, it is repositioned to visible.
Tooltip appears until it is cleared, until script terminates, or sometimes until it is clicked upon. You may use @CR or @LF to create multi-line tooltips.

Related

TrayTip

Example

; This will create a tooltip in the upper left of the screen
ToolTip("This is a tooltip", 0, 0)
Sleep(2000) ; Sleep to give tooltip time to display


Function TrayTip

Function Reference

TrayTip

Displays a balloon tip from the AuotIt Icon. (2000/XP only)

TrayTip ( "title", "text", timeout [, option] )

Parameters

title | Text appears in bold at the top of the balloon tip. (63 characters maximum)
text | Message the balloon tip will display. (255 characters maximum)
timeout | A rough estimate of the time the balloon tip should be displayed. (Windows has a min and max of about 10-30 seconds but does not always honor a time in that range.)
option | [optional] See Remarks. 0=No icon (default), 1=Info icon, 2=Warning icon, 3=Error icon

Return Value

None.

Remarks

TrayTip works for only Windows 2000/XP or better.

A Tray tip will close if the AutoIt tray icon disappears. Consequently, the TrayTip may not appear if AutoItSetOption("TrayIconHide", 1) is set or if the user has disabled balloon tips via registry settings!

Windows XP usually plays a sound when displaying a balloon tip. This sound can be disabled by adding 16 to the options parameter or by setting an empty title.

To clear a balloon tip that is being displayed, call another tip with an empty text string (and any title).

Related

MsgBox, ToolTip, TrayIconHide (Option)

Example

TrayTip("I'm a title", "I'm the message", 5, 1)
MsgBox(4096,"", "Press OK to see another tip.")
TrayTip("clears any tray tip","",0)
TrayTip("", "A different tray tip.", 5)
Sleep(5000)


Function AdlibDisable

Function Reference

AdlibDisable

Disables the adlib functionality.

AdlibDisable ( )

Parameters

None.

Return Value

None.

Remarks

None.

Related

AdlibEnable

Example

AdlibDisable()


Function AdlibEnable

Function Reference

AdlibEnable

Enables Adlib functionality.

AdlibEnable ( "function" [, time] )

Parameters

function | The name of the adlib function to call.
time | [optional] how often in milliseconds to call the function. Default is 250 ms.

Return Value

None.

Remarks

Every 250 ms (or time ms) the specified "function" is called--typically to check for unforeseen errors. For example, you could use adlib in a script which causes an error window to pop up unpredictably.
The adlib function should be kept simple as it is executed often and during this time the main script is paused. Also, the time parameter should be used carefully to avoid CPU load.

Related

AdlibDisable, Call

Example

AdlibEnable("myadlib")
;...
Exit

Func myadlib()
If WinActive("Error") Then
;...
EndIf
EndFunc


Function AutoItWinGetTitle

Function Reference

AutoItWinGetTitle

Retrieves the title of the AutoIt window.

AutoItWinGetTitle ( )

Parameters

None.

Return Value

None.

Remarks

None.

Related

AutoItWinSetTitle, WinGetTitle

Example

$a = AutoItWinGetTitle()


Function AutoItWinSetTitle

Function Reference

AutoItWinSetTitle

Changes the title of the AutoIt window.

AutoItWinSetTitle ( "newtitle" )

Parameters

newtitle The new title to give to the window.

Return Value

None.

Remarks

The AutoIt window is usually hidden. The purpose of changing the title is to allow other programs (or other AutoIt scripts) to interact with AutoIt.

Related

AutoItWinGetTitle, WinSetTitle

Example

AutoItWinSetTitle("My AutoIt Window")


Function BlockInput

Function Reference

BlockInput

Disable/enable the mouse and keyboard.

BlockInput ( flag )

Parameters

flag 1 = Disable user input
0 = Enable user input

Return Value

None.

Remarks

If BlockInput is enabled, the Alt keypress cannot be sent!
The table below shows how BlockInput behavior depends on Windows' version; however, pressing Ctrl+Alt+Del on any platform will re-enable input due to a Windows API feature.

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

If you are using Windows XP then you should be aware that a hotfix released inbetween SP1 and SP2 limited Blockinput so that the ALT key could NOT be sent. This is fixed in XP SP2.

Note that functions such as WinMove() will still work on Windows 98/Me when BlockInput is enabled.

Related

Send

Example

If @OSVersion &lt;&gt; "WIN_98" And @OSVersion &lt;&gt; "WIN_ME" Then
BlockInput(1)
EndIf

Run("notepad")
WinWaitActive("Untitled - Notepad")
Send("{F5}") ;pastes time and date

BlockInput(0)


Function Break

Function Reference

Break

Enables or disables the users' ability to exit a script from the tray icon menu.

Break ( mode )

Parameters

mode Sets the script break mode:
1 = Break is enabled (user can quit) (default)
0 = Break is disabled (user cannot quit)

Return Value

None.

Remarks

Please only disable break with good reason.
AutoIt normally creates a tray icon when running, and right-clicking this icon allows the user to pause or exit the script. If Break is enabled (1), then the user cannot terminate the script this way.

Related

None.

Example

Break(0) ;Disable break


Function Call

Function Reference

Call

Calls a user-defined function contained in a string parameter.

Call ( "function" )

Parameters

function The name of the user function to call.

Return Value

Success: | Returns the return value of the called function.
Failure: | Sets @error to 1 if the function does not exist.

Remarks

The function cannot take any parameters and cannot be a built-in AutoIt function.

Related

AdlibEnable

Example

For $i = 1 to 2
$ret = Call("test" & $i)
MsgBox(4096,"", $ret)
Next

Func test1()
Return "Hello"
EndFunc

Func test2()
Return "Bye"
EndFunc


Function CDTray

Function Reference

CDTray

Opens or closes the CD tray.

CDTray ( "drive", "status" )

Parameters

drive | The drive letter of the CD tray to control, in the format D:, E:, etc.
status | Specifies if you want the CD tray to be open or closed: "open" or "closed"

Return Value

Success: | Returns 1.
Failure: | Returns 0 if drive is locked via CD burning software or if the drive letter is not a CD drive.

Remarks

CDTray works as expected with virtual CD drives such as DAEMON Tools.
CDTray does not work on non-local/mapped CD drives; CDTray must be run from the computer whose drive it affects.
CDTray("X:", "close") tends to return 0 even on laptop-style cd trays that can only be closed manually.

Related

DriveGetType, DriveStatus

Example

; Open the CD tray on drive E:
CDTray("E:", "open")


Function ConsoleWrite

Function Reference

ConsoleWrite

Writes data to a stream that text editors can sometimes read.

ConsoleWrite ( "data" )

Parameters

data The data you wish to output.

Return Value

None.

Remarks

The purpose for this function is to write to a console which many popular text editors can read.

This does not write to a DOS console.

Related

None.

Example

$var = "Test"
ConsoleWrite("var=" & $var)
; Running this in a text editor which can trap console output should produce "var=Test"


Function SetError

Function Reference

SetError

Manually set the value of the @error macro.

SetError ( code )

Parameters

code The required value (integer) to set the @error macro to.

Return Value

None.

Remarks

The @error code is only valid until the next function is called. Consequently, you may need to backup the status of @error in a variable if you are testing it in a While-WEnd loop.

Related

SetExtended

Example

$result = myDiv(5, 0)
If @error Then
MsgBox(4096,"Error", "Division by Zero")
Else
MsgBox(4096, "Result", $result)
EndIf
Exit

Func myDiv($dividend, $divisor)
If $dividend = 0 And $divisor = 0 Then
SetError(2) ;indeterminate form 0/0
ElseIf $divisor = 0 Then
SetError(1) ;plain division by zero
EndIf
Return $dividend / $divisor
EndFunc


Function SetExtended

Function Reference

SetExtended

Manually set the value of the @extended macro.

SetExtended ( code )

Parameters

code The required value (integer) to set the @extended macro to.

Return Value

None.

Remarks

The @extended code is only valid until the next function is called. Consequently, you may need to backup the status of @extended in a variable if you are testing it in a While-WEnd loop.

Related

SetError

Example

SetExtended(10)
MsgBox(4096, "Value of @Extended is", @extended)


Function MouseClick

Function Reference

MouseClick

Perform a mouse click operation.

MouseClick ( "button" [, x, y [, clicks [, speed ]]] )

Parameters

button | The button to click: "left", "right", "middle", "main", "menu", "primary", "secondary".
x, y | [optional] The x/y coordinates to move the mouse to. If no x and y coords are given, the current position is used.
clicks | [optional] The number of times to click the mouse. Default is 1.
speed | [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.

Return Value

None.

Remarks

If the button is an empty string, the left button will be clicked.

If the button is not in the list, then @Error will be set to 1.

If the user has swapped the left and right mouse buttons in the control panel, then the behaviour of the buttons is different. "Left" and "right" always click those buttons, whether the buttons are swapped or not. The "primary" or "main" button will be the main click, whether or not the buttons are swapped. The "secondary" or "menu" buttons will usually bring up the context menu, whether the buttons are swapped or not.

Button | Normal | Swapped
"" | Left | Left
"left" | Left | Left
"middle" | Middle | Middle
"right" | Right | Right
"primary" | Left | Right
"main" | Left | Right
"secondary" | Right | Left
"menu" | Right | Left

Related

MouseClickDrag, MouseGetPos, MouseMove, MouseCoordMode (Option)

Example

; Double click at the current mouse pos
MouseClick("left")
MouseClick("left")

; Double click at 0,500
MouseClick("left", 0, 500, 2)

; SAFER VERSION of Double click at 0,500

Dim $primary
Dim $secondary
;Determine if user has swapped right and left mouse buttons
$k = RegRead("HKEY_CURRENT_USER\Control Panel\Mouse", "SwapMouseButtons")

; It's okay to NOT check the success of the RegRead operation
If $k = 1 Then
$primary = "right"
$secondary = "left"
Else ;normal (also case if could not read registry key)
$primary = "left"
$secondary = "right"
EndIf
MouseClick($primary, 0, 500, 2)
Exit


Function MouseClickDrag

Function Reference

MouseClickDrag

Perform a mouse click and drag operation.

MouseClickDrag ( "button", x1, y1, x2, y2 [, speed] )

Parameters

button | The button to click: "left", "right", "middle", "main", "menu", "primary", "secondary".
x1, y1 | The x/y coords to start the drag operation from.
x2, y2 | The x/y coords to start the drag operation to.
speed | [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.

Return Value

None.

Remarks

If the button is an empty string, the left button will be clicked.

If the button is not in the list, then @Error will be set to 1.

If the user has swapped the left and right mouse buttons in the control panel, then the behaviour of the buttons is different. "Left" and "right" always click those buttons, whether the buttons are swapped or not. The "primary" or "main" button will be the main click, whether or not the buttons are swapped. The "secondary" or "menu" buttons will usually bring up the context menu, whether the buttons are swapped or not. See the table in MouseClick for more explaination

Related

MouseClick, MouseGetPos, MouseMove, MouseCoordMode (Option)

Example

; Left click drag from 0,200 to 600, 700
MouseClickDrag("left", 0, 200, 600, 700)


Function MouseDown

Function Reference

MouseDown

Perform a mouse down event at the current mouse position.

MouseDown ( "button" )

Parameters

button The button to click: "left", "right", "middle", "main", "menu", "primary", "secondary".

Return Value

None.

Remarks

MouseClick.
Use responsibly: For every MouseDown there should eventually be a corresponding MouseUp event.

Related

MouseUp, MouseClick, MouseClickDrag, MouseGetPos, MouseMove, MouseCoordMode (Option)

Example

MouseDown("left")
Sleep(100)
MouseUp("left")


Function MouseGetCursor

Function Reference

MouseGetCursor

Returns a cursor ID Number of the current Mouse Cursor.

MouseGetCursor ( )

Parameters

None.

Return Value

Returns a cursor ID Number:
0 = UNKNOWN (this includes pointing and grabbing hand icons)
1 = APPSTARTING
2 = ARROW
3 = CROSS
4 = HELP
5 = IBEAM
6 = ICON
7 = NO
8 = SIZE
9 = SIZEALL
10 = SIZENESW
11 = SIZENS
12 = SIZENWSE
13 = SIZEWE
14 = UPARROW
15 = WAIT

Remarks

None.

Related

MouseGetPos

Example

sleep(2000) ;allow time to move mouse before reporting ID

;create an array that tells us the meaning of an ID Number
$IDs = StringSplit("AppStarting|Arrow|Cross|Help|IBeam|Icon|No|_
Size|SizeAll|SizeNESW|SizeNS|SizeNWSE|SizeWE|UpArrow|Wait", "|")
$IDs[0] = "Unknown"

$cursor = MouseGetCursor()
MsgBox(4096, "ID = " & $cursor, "Which means " & $IDs[$cursor])


Function MouseGetPos

Function Reference

MouseGetPos

Retrieves the current position of the mouse cursor.

MouseGetPos ( )

Parameters

None.

Return Value

Returns a two-element array that containing the mouse coordinates:
$array[0] = X coord (horizontal)
$array[1] = Y coord (vertical)

Remarks

See MouseCoordMode for relative/absolute position settings. If relative positioning, numbers may be negative.

Related

MouseClick, MouseClickDrag, MouseMove, MouseCoordMode (Option)

Example

$pos = MouseGetPos()
MsgBox(0, "Mouse x,y:", $pos[0] & "," & $pos[1])


Function MouseMove

Function Reference

MouseMove

Moves the mouse pointer.

MouseMove ( x, y [, speed] )

Parameters

x | The screen x coordinate to move the mouse to.
y | The screen y coordinate to move the mouse to.
speed | [optional] the speed to move the mouse in the range 1 (fastest) to 100 (slowest). A speed of 0 will move the mouse instantly. Default speed is 10.

Return Value

User mouse movement is hindered during a non-instantaneous MouseMove operation.
If MouseCoordMode is relative positioning, numbers may be negative.

Remarks

None.

Related

MouseClick, MouseClickDrag, MouseGetPos, MouseCoordMode (Option)

Example

MouseMove(10, 100)
MouseMove(700, 700, 0)


Function MouseUp

Function Reference

MouseUp

Perform a mouse up event at the current mouse position.

MouseUp ( "button" )

Parameters

button The button to click: "left", "right", "middle", "main", "menu", "primary", "secondary".

Return Value

None.

Remarks

MouseClick.
Use responsibly: For every MouseDown there should eventually be a corresponding MouseUp event.

Related

MouseDown, MouseClick, MouseClickDrag, MouseGetPos, MouseMove, MouseCoordMode (Option)

Example

MouseDown("left")
Sleep(100)
MouseUp("left")


Function MouseWheel

Function Reference

MouseWheel

Moves the mouse wheel up or down. NT/2000/XP ONLY.

MouseWheel ( "direction" [, clicks] )

Parameters

direction | "up" or "down"
clicks | [optional] The number of times to move the wheel. Default is 1.

Return Value

None.

Remarks

If the direction is not recognized, @Error is set to 1.

This function only works on NT, 2000, XP and later operating systems.

Related

MouseClick, MouseClickDrag, MouseGetPos, MouseMove, MouseCoordMode (Option)

Example

; Move the wheel up 10 times
MouseWheel("up", 10)


Function FtpSetProxy

Function Reference

FtpSetProxy

Sets the internet proxy to use for ftp access.

FtpSetProxy ( mode [, "proxy:port" [, "username", "password"]] )

Parameters

mode | The proxy mode to use: 0 = (default) Use current Internet Explorer settings for proxy. 1 = Use no proxy (direct access) 2 = Use the proxy specified
proxy:port | [optional] The address and port of the proxy to use. See remarks below.
username | [optional] If required, the username for the proxy
password | [optional] If required, the password for the proxy

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Internet Explorer 3 or greater must be installed for this function to work.

Only CERN proxy servers are supported.

Proxy servers are usually made up of a web address and port number. Most ISPs use the port number of 8080. If your proxy was "www.proxy.com" and port was "8080" then you would use this to set the proxy:
FtpSetProxy(2, "www.proxy.com:8080")

Most proxy servers do not require a username and password.

Related

HttpSetProxy, InetGet, InetGetSize

Example

; Use no proxy
FtpSetProxy(1)

; Use IE defaults for proxy
FtpSetProxy(0)

; Use the proxy "www-cache.myisp.net" on port 8080
FtpSetProxy(0, "www-cache.myisp.net:8080")


Function HttpSetProxy

Function Reference

HttpSetProxy

Sets the internet proxy to use for http access.

HttpSetProxy ( mode [, "proxy:port" [, "username", "password"]] )

Parameters

mode | The proxy mode to use: 0 = (default) Use current Internet Explorer settings for proxy. 1 = Use no proxy (direct access) 2 = Use the proxy specified
proxy:port | [optional] The address and port of the proxy to use. See remarks below.
username | [optional] If required, the username for the proxy
password | [optional] If required, the password for the proxy

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Internet Explorer 3 or greater must be installed for this function to work.

Only CERN proxy servers are supported.

Proxy servers are usually made up of a web address and port number. Most ISPs use the port number of 8080. If your proxy was "www.proxy.com" and port was "8080" then you would use this to set the proxy:
HttpSetProxy(2, "www.proxy.com:8080")

Most proxy servers do not require a username and password.

Related

FtpSetProxy, InetGet, InetGetSize

Example

; Use no proxy
HttpSetProxy(1)

; Use IE defaults for proxy
HttpSetProxy(0)

; Use the proxy "www-cache.myisp.net" on port 8080
HttpSetProxy(2, "www-cache.myisp.net:8080")


Function InetGet

Function Reference

InetGet

Downloads a file from the internet using the http or ftp protocol.

InetGet ( "URL", "filename" [, reload [, background]] )

Parameters

URL | URL of the file to download. See remarks below.
filename | Local filename to download to.
reload | [optional] 0 = (default) Get the file from local cache if available 1 = Forces a reload from the remote site
background | [optional] 0 = (default) Wait until the download is complete before continuing. 1 = return immediately and download in the background (see remarks).

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

Internet Explorer 3 or greater must be installed for this function to work.

The URL parameter should be in the form "http://www.somesite.com/path/file.html" - just like an address you would type into your web browser.

To use a username and password when connecting simply prefix the servername with "username:password@", e.g.
"http://myuser:mypassword@www.somesite.com"

The InetGet function works with http:// https:// and ftp:// - to change the transfer type when using ftp see the FtpBinaryMode option.

"background" Parameter

By default the function waits until the download has finished before returning. Sometimes with large downloads this is not always wanted. If the background parameter is set to 1 the function returns immediately and the download continues in the background. When in this mode two macros are used to keep track:
@InetGetActive = 1 while downloading, or 0 when finished.
@InetGetBytesRead = the number of bytes downloaded, or -1 if there has been an error.

Note, only one download can be active at once, if you call the function again before a download is complete it will fail.

To abort a download call the function with just the first parameter set to "abort" like so:

InetGet("abort")

Related

FtpBinaryMode (Option), FtpSetProxy, InetGetSize, HttpSetProxy

Example

InetGet("http://www.mozilla.org", "C:\foo.html")
InetGet("http://www.autoitscript.com", "C:\mydownload.htm", 1)
InetGet("ftp://ftp.mozilla.org/pub/mozilla.org/README", "README.txt", 1)

; Advanced example - downloading in the background
InetGet("http://www.nowhere.com/somelargefile.exe", "test.exe", 1, 1)

While @InetGetActive
TrayTip("Downloading", "Bytes = " & @InetGetBytesRead, 10, 16)
Sleep(250)
Wend

MsgBox(0, "Bytes read", @InetGetBytesRead)


Function InetGetSize

Function Reference

InetGetSize

Returns the size (in bytes) of a file located on the internet.

InetGetSize ( "URL" )

Parameters

URL URL of the file to download. See remarks below.

Return Value

Success: | Returns the size of the file in bytes.
Failure: | Returns 0 and sets @error to 1.

Remarks

Internet Explorer 3 or greater must be installed for this function to work. (For ftp:// URLs IE 5 is required!)

The URL parameter should be in the form "http://www.somesite.com/path/file.html" - just like an address you would type into your web browser.

To use a username and password when connecting simply prefix the servername with "username:password@", e.g.
"http://myuser:mypassword@www.somesite.com"

Not all servers will correctly give the filesize, especially when using a proxy server.

Related

InetGet

Example

$size = InetGetSize("http://www.autoitscript.com/autoit3/files/unstable/autoit/AutoIt3.exe")
MsgBox(0, "Size of remote file:", $size)


Function Ping

Function Reference

Ping

Pings a host and returns the roundtrip-time.

Ping ( address or hostname [, timeout] )

Parameters

address/hostname | Can be i.e. "www.hiddensoft.com" or "178.50.76.4".
timeout | [optional] Is the time to wait for an answer in milliseconds (default is 4000).

Return Value

Success: | Returns the roundtrip-time in milliseconds ( greater than 0 ).
Failure: | Returns 0 if host is not pingable or other network errors occured and sets @error. (See Remarks)

Remarks

When the function fails (returns 0) @error contains extended information:
1 = Host is offline
2 = Host is unreachable
3 = Bad destination
4 = Other errors

Related

None.

Example

$var = Ping("www.hiddensoft.com",250)
If $var Then ; also possible: If @error = 0 Then ...
Msgbox(0,"Status","Online, roundtrip was:" & $var)
Else
Msgbox(0,"Status","An error occured with number: " & @error)
EndIf


Function DllCall

Function Reference

DllCall

Dynamically calls a function in a DLL.

DllCall ( "dll", "return type", "function" [, "type1", param1 [, "type n", param n]] )

Parameters

dll | The filename of the DLL to use. eg. "user32.dll". A handle obtained from DllOpen can also be used (See Remarks).
return type | The return type of the function (see below).
function | The name of the function in the DLL to call, eg. "MessageBox"
type | [optional] The type of the parameter (see remarks).
param | [optional] The actual parameter (see remarks).

Return Value

See remarks.

Remarks

If a dll filename is given then the DLL is automatically loaded and then closed at the end of the call. If you want to manually control the loading and unloading of the DLL then you should use DllOpen and DllClose and use a handle instead of a filename in this function.

You can have as many "types" and "param" as you like. See the examples below that use a number of parameters.

Valid Types are:

Type | Details
none | no value (only valid for return type - equivalent to void in C)
short | a 16 bit integer
int | a 32 bit integer
long | a 32 bit integer
short_ptr | a pointer to a 16 bit integer
int_ptr | a pointer to a 32 bit integer
long_ptr | a pointer to a 32 bit integer
str | a string
wstr | a wide character string (converted to/from an ANSI string during the call)
hwnd | a window handle
ptr | a general pointer (void *)

If the function call fails then @error is set to 1. Otherwise an array is returned that contains the function return value and a copy of all the parameters (including parameters that the function may have modified).
$return[0] = function return value
$return[1] = param1
$return[2] = param2
...
$return[n] = paramn

Related

None.

Example

; Example 1 - calling the MessageBox API directly
$result = DllCall("user32.dll", "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0)

; Example 2 - calling a function that modifies parameters
$hwnd = WinGetHandle("Untitled - Notepad")
$result = DllCall("user32.dll", "int", "GetWindowText", "hwnd", $hwnd, "str", "", "int", 32768)
msgbox(0, "", $result[0]) ; number of chars returned
msgbox(0, "", $result[2]) ; Text returned in param 2


Function DllClose

Function Reference

DllClose

Closes a previously opened DLL.

DllClose ( dllhandle )

Parameters

dllhandle The handle of a dll, as returned by a previous call to DllOpen.

Return Value

None.

Remarks

If dllhandle is invalid, an AutoIt runtime error will be thrown, and the script will terminate!
Upon termination, AutoIt automatically closes any dlls it opened--but calling DllClose is still a good idea.

Related

DllCall, DllOpen

Example

$dll = DllOpen("user32.dll")
$result = DllCall($dll, "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0)
DllClose($dll)


Function DllOpen

Function Reference

DllOpen

Opens a dll file for use in DllCall.

DllOpen ( "filename" )

Parameters

filename Filename of the dll file to open.

Return Value

Success: | Returns a dll "handle" or use with subsequent dll functions.
Failure: | Returns -1 if error occurs.

Remarks

Up to 64 files can be open simultaneously by one AutoIt script.
When finished working with a dll, call the DllClose function to close it. Autoit normally closes all files upon termination, but explicitly calling DllClose is still a good idea.

Related

DllCall, DllClose

Example

$dll = DllOpen("user32.dll")
$result = DllCall($dll, "int", "MessageBox", "hwnd", 0, "str", "Some text", "str", "Some title", "int", 0)
DllClose($dll)


Function ProcessClose

Function Reference

ProcessClose

Terminates a named process.

ProcessClose ( "process" )

Parameters

process The title or PID of the process to terminate.

Return Value

None. (Returns 1 regardless of success/failure.)

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"
If multiple processes have the same name, the one with the highest PID is terminated--regardless of how recently the process was spawned.
PID is the unique number which identifies a Process. A PID can be obtained through the ProcessExists or Run commands.
In order to work under Windows NT 4.0, ProcessClose requires the file PSAPI.DLL (included in the AutoIt installation directory).
The process is polled approximately every 250 milliseconds.

Related

ProcessExists, ProcessWait, ProcessWaitClose, Run, WinClose

Example

ProcessClose("notepad.exe")

$PID = ProcessExists("notepad.exe") ; Will return the PID or 0 if the process isn't found.
If $PID Then ProcessClose($PID)


Function ProcessExists

Function Reference

ProcessExists

Checks to see if a specified process exists.

ProcessExists ( "process" )

Parameters

process The name or PID of the process to check.

Return Value

Success: Returns the PID of the process.
Failure: Returns 0 if process does not exist.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"
PID is the unique number which identifies a Process.
In order to work under Windows NT 4.0, ProcessExists requires the file PSAPI.DLL (included in the AutoIt installation directory).
The process is polled approximately every 250 milliseconds.

Related

ProcessClose, ProcessWait, ProcessWaitClose, WinExists

Example

If ProcessExists("notepad.exe") Then
MsgBox(0, "Example", "Notepad is running.")
EndIf


Function ProcessSetPriority

Function Reference

ProcessSetPriority

Changes the priority of a process

ProcessSetPriority ( "process", priority)

Parameters

process | The name or PID of the process to check.
priority | A flag which determines what priority to set 0 - Idle/Low 1 - Below Normal (Not supported on Windows 95/98/ME) 2 - Normal 3 - Above Normal (Not supported on Windows 95/98/ME) 4 - High 5 - Realtime (Use with caution, may make the system unstable)

Return Value

Success: Returns 1.
Failure: Returns 0 and sets @error to 1. May set @error to 2 if attempting to use an unsupported priority class.

Remarks

Above Normal and Below Normal priority classes are not supported on Windows 95/98/ME. If you try to use them on those platforms, the function will fail and @error will be set to 2.

Related

Example

Run("Notepad.exe")
ProcessSetPriority("notepad.exe", 0)
; Notepad should now have Idle/Low priority


Function ProcessList

Function Reference

ProcessList

Returns an array listing the currently running processes (names and PIDs).

ProcessList ( ["name"] )

Parameters

name [Optional] If a name is given only processes of the same name will be returned.

Return Value

Success - An array of process names and PIDs (See Remarks).
Failure - @error is set to 1.

Remarks

The array returned is two-dimensional and is made up as follows:
$array[0][0] = Number of processes
$array[1][0] = 1st Process name
$array[1][1] = 1st Process ID (PID)
$array[2][0] = 2nd Process name
$array[2][1] = 2nd Process ID (PID)
...
$array[n][0] = nth Process name
$array[n][1] = nth Process ID (PID)

Related

ProcessClose, ProcessExists, ProcessSetPriority, ProcessWait, ProcessWaitClose

Example

; List all processes
$list = ProcessList()
for $i = 1 to $list[0][0]
msgbox(0, $list[$i][0], $list[$i][1])
next

; List just notepad.exe processes
$list = ProcessList("notepad.exe")
for $i = 1 to $list[0][0]
msgbox(0, $list[$i][0], $list[$i][1])
next


Function ProcessWait

Function Reference

ProcessWait

Pauses script execution until a given process exists.

ProcessWait ( "process" [, timeout] )

Parameters

process | The name of the process to check.
timeout | [optional] Specifies how long to wait (default is to wait indefinitely).

Return Value

Success: Returns 1.
Failure: Returns 0 if the wait timed out.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"
In order to work under Windows NT 4.0, ProcessWait requires the file PSAPI.DLL (included in the AutoIt installation directory).
The process is polled approximately every 250 milliseconds.

This function is the only process function not to accept a PID. Because PIDs are allocated randomly, waiting for a particular PID to exist doesn't make sense.

Related

ProcessClose, ProcessExists, ProcessWaitClose, RunWait, WinWait, WinWaitActive

Example

ProcessWait("notepad.exe")


Function ProcessWaitClose

Function Reference

ProcessWaitClose

Pauses script execution until a given process does not exist.

ProcessWaitClose ( "process" [, timeout] )

Parameters

process | The name or PID of the process to check.
timeout | [optional] Specifies how long to wait (default is to wait indefinitely).

Return Value

Success: Returns 1.
Failure: Returns 0 if wait timed out.

Remarks

Process names are executables without the full path, e.g., "notepad.exe" or "winword.exe"
PID is the unique number which identifies a Process. A PID can be obtained through the ProcessExists or Run commands.
In order to work under Windows NT 4.0, ProcessWaitClose requires the file PSAPI.DLL (included in the AutoIt installation directory).
The process is polled approximately every 250 milliseconds.

Related

ProcessClose, ProcessExists, ProcessWaitClose, RunWait, WinWaitClose

Example

;waits until no instance of notepad.exe exists
ProcessWaitClose("notepad.exe")

; This will wait until this particular instance of notepad has exited
$PID = Run("notepad.exe")
ProcessWaitClose($PID)


Function Run

Function Reference

Run

Runs an external program.

Run ( "filename" [, "workingdir" [, flag]] )

Parameters

filename | The full name of the executable (EXE, BAT, COM, or PIF) to run.
workingdir | [optional] The working directory.
flag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window

Return Value

Success: The PID of the process that was launched.
Failure: Depends on RunErrorsFatal; see Remarks.

Remarks

To run DOS (console) commands, try RunWait(@ComSpec & " /c " & 'commandName', "", @SW_HIDE)

WorkingDir is NOT the same as the path to the executable! For example, running a file from a floppy disk:
Bad: Run("myProg.exe", "A:") ; Wrong! This will most likely fail!
Good: Run("A:\myProg.exe") ; Correct because FULL path to executable was given

After running the requested program the script continues. To pause execution of the script until the spawned program has finished use the RunWait function instead.

By default the script will terminate with a fatal error if the Run function fails. To set @error to 1 as an indication of failure, see AutoItSetOption.

Related

RunAsSet, RunErrorsFatal (Option), RunWait

Example

Run("Notepad.exe", "", @SW_MAXIMIZE)


Function RunAsSet

Function Reference

RunAsSet

Initialise a set of user credentials to use during Run and RunWait operations. 2000/XP or later ONLY.

RunAsSet ( ["user", "domain", "password" [, options]] )

Parameters

username | [optional] The user name to use.
domain | [optional] The domain name to use.
password | [optional] The password to use.
options | [optional] 0 = do not load the user profile, 1 = (default) load the user profile, 2 = use for net credentials only

Return Value

Returns 0 if the operating system does not support this function.
Otherwise returns 1--regardless of success. (If the login information was invalid, subsequent Run/RunWait commands will fail....)

Remarks

This function allows subsequent Run and RunWait functions to run as a different user (e.g. Administrator). The function only works on the 2000/XP (or later) platforms. NT4 users should install and use the SU command from the NT Resource Kit.

The "Secondary Logon service" or "RunAs service" must not be disabled if you want this function to work.

To unset the RunAs details, use the function with no parameters: RunAsSet().

Related

Run, RunErrorsFatal (Option), RunWait

Example

; Set the RunAs parameters to use local adminstrator account
RunAsSet("Administrator", @Computername, "adminpassword")

; Run registry editor as admin
RunWait("regedit.exe")

; Reset user's permissions
RunAsSet()


Function RunWait

Function Reference

RunWait

Runs an external program and pauses script execution until the program finishes.

RunWait ( "filename" [, "workingdir" [, flag]] )

Parameters

filename | The name of the executable (EXE, BAT, COM, PIF) to run.
workingdir | [optional] The working directory.
flag | [optional] The "show" flag of the executed program: @SW_HIDE = Hidden window @SW_MINIMIZE = Minimized window @SW_MAXIMIZE = Maximized window

Return Value

Success: | Returns the exit code of the program that was run.
Failure: | Depends on RunErrorsFatal; see Remarks.

Remarks

To run DOS commands, try RunWait(@ComSpec & " /c " & "commandName")

After running the requested program the script pauses until the program terminates. To run a program and then immediately continue script execution use the Run function instead.

Some programs will appear to return immediately even though they are still running; these programs spawn another process - you may be able to use the ProcessWaitClose function to handle these cases.

By default the script will terminate with a fatal error if the Run function fails. To set @error to 1 as an indication of failure, see AutoItSetOption.

Related

ProcessWait, ProcessWaitClose, RunAsSet, RunErrorsFatal (Option), RunWait

Example

$val = RunWait("Notepad.exe", "C:\WINDOWS", @SW_MAXIMIZE)
; script waits until Notepad closes
MsgBox(0, "Program returned with exit code:", $val)


Function Shutdown

Function Reference

Shutdown

Shuts down the system.

Shutdown ( code )

Parameters

code A combination of shutdown codes. See "remarks".

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

The shutdown code is a combination of the following values:
0 = Logoff
1 = Shutdown
2 = Reboot
4 = Force
8 = Power down
32= Suspend
64= Hibernate

Add the required values together. To shutdown and power down, for example, the code would be 9 (shutdown + power down = 1 + 8 = 9).

Standby or hibernate are ignored if other codes are set. They are also ignored under Win9x.

Related

ProcessClose

Example

Shutdown(6) ;Force a reboot


Function RegDelete

Function Reference

RegDelete

Deletes a key or value from the registry.

RegDelete ( "keyname" [, "valuename"] )

Parameters

keyname | The registry key to delete.
valuename | [optional] The valuename to delete.

Return Value

Success: | Returns 1.
Special: | Returns 0 if the key/value does not exist.
Failure: | Returns 2 if error deleting key/value.

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

To access the (Default) value use "" (a blank string) for the valuename.

Deleting from the registry is potentially dangerous--please exercise caution!

It is possible to access remote registries by using a keyname in the form "\\computername\keyname". To use this feature you must have the correct access rights on NT/2000/XP/2003, or if you are using a 9x based OS the remote PC must have the remote regsitry service installed first (See Microsoft Knowledge Base Article - 141460).

Related

RegRead, RegWrite

Example

RegDelete("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey")


Function RegEnumKey

Function Reference

RegEnumKey

Reads the name of a subkey according to it's instance.

RegEnumKey ( "keyname", instance )

Parameters

keyname | The registry key to read.
instance | The 1-based key instance to retrieve

Return Value

Success: | Returns the requested subkey name..
Failure: | Returns "" and sets the @error flag:
 | 1 if unable to open requested key
 | -1 if unable to retrieve requested subkey (key instance out of range)

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

Related

RegEnumVal, RegDelete, RegWrite, StringSplit

Example

$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE", 1)
MsgBox(4096, "First SubKey under HKLM\Software: ", $var)
$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE", 2)
MsgBox(4096, "Second SubKey under HKLM\Software: ", $var)


Function RegEnumVal

Function Reference

RegEnumVal

Reads the name of a value according to it's instance.

RegEnumVal ( "keyname", instance )

Parameters

keyname | The registry key to read.
instance | The 1-based value instance to retrieve

Return Value

Success: | Returns the requested value name..
Failure: | Returns "" and sets the @error flag:
 | 1 if unable to open requested key
 | -1 if unable to retrieve requested value name (value instance out of range)

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

Related

RegEnumKey, RegDelete, RegWrite, StringSplit

Example

$var = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\HiddenSoft\AutoIt3", 1)
MsgBox(4096, "First Value Name under in AutoIt3 key", $var)
$var = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\HiddenSoft\AutoIt3", 2)
MsgBox(4096, "Second Value Name under in AutoIt3 key: ", $var)


Function RegRead

Function Reference

RegRead

Reads a value from the registry.

RegRead ( "keyname", "valuename" )

Parameters

keyname | The registry key to read.
valuename | The value to read.

Return Value

Success: | Returns the requested registry value value..
Failure: | Returns "" and sets the @error flag:
 | 1 if unable to open requested key
 | -1 if unable to open requested value
 | -2 if value type not supported

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

AutoIt supports registry keys of type REG_BINARY, REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, and REG_DWORD.

To access the (Default) value use "" (a blank string) for the valuename.

When reading a REG_BINARY key the result is a string of hex characters, e.g. the REG_BINARY value of 01,a9,ff,77 will be read as the string "01A9FF77".

When reading a REG_MULTI_SZ key the multiple entries are seperated by @LF - use with StringSplit(..., @LF) to get each entry.

It is possible to access remote registries by using a keyname in the form "\\computername\keyname". To use this feature you must have the correct access rights on NT/2000/XP/2003, or if you are using a 9x based OS the remote PC must have the remote regsitry service installed first (See Microsoft Knowledge Base Article - 141460).

Related

RegDelete, RegWrite, StringSplit

Example

$var = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
MsgBox(4096, "Program files are in:", $var)


Function RegWrite

Function Reference

RegWrite

Creates a key or value in the registry.

RegWrite ( "keyname" [,"valuename", "type", value] )

Parameters

keyname | The registry key to write to. If no other parameters are specified this key will simply be created.
valuename | [optional] The valuename to write to.
type | [optional] Type of key to write: "REG_SZ", "REG_MULTI_SZ", "REG_EXPAND_SZ", "REG_DWORD", or "REG_BINARY".
value | [optional] The value to write.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if error writing registry key or value.

Remarks

A registry key must start with "HKEY_LOCAL_MACHINE" ("HKLM") or "HKEY_USERS" ("HKU") or "HKEY_CURRENT_USER" ("HKCU") or "HKEY_CLASSES_ROOT" ("HKCR") or "HKEY_CURRENT_CONFIG" ("HKCC").

AutoIt supports registry keys of type REG_BINARY, REG_SZ, REG_MULTI_SZ, REG_EXPAND_SZ, and REG_DWORD.

To access the (Default) value use "" (a blank string) for the valuename.

When writing a REG_BINARY key use a string of hex characters, e.g. the REG_BINARY value of 01,a9,ff,77 can be written by using the string "01A9FF77".

When writing a REG_MULTI_SZ key you must separate each value with @LF. The value must NOT end with @LF and no "blank" entries are allowed (see example).

It is possible to access remote registries by using a keyname in the form "\\computername\keyname". To use this feature you must have the correct access rights on NT/2000/XP/2003, or if you are using a 9x based OS the remote PC must have the remote regsitry service installed first (See Microsoft Knowledge Base Article - 141460).

Related

RegDelete, RegRead

Example

; Write a single REG_SZ value
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_SZ", "Hello this is a test")

; Write the REG_MULTI_SZ value of "line1" and "line2"
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_MULTI_SZ", "line1" & @LF & "line2")

; INCORRECT uses of REG_MULTI_SZ
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_MULTI_SZ", "line1" & @LF & "line2" & @LF)
RegWrite("HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_MULTI_SZ", "line1" & @LF & @LF & "line2" & @LF)


Function StringAddCR

Function Reference

StringAddCR

Takes a string and prefixes all linefeed characters ( Chr(10) ) with a carriage return character ( Chr(13) ).

StringAddCR ( "string" )

Parameters

string The string to convert.

Return Value

Returns the string with all instances of linefeed characters ( @LF ) prefixed with a carriage return character ( @CR ).

Remarks

None.

Related

StringStripCR, StringReplace

Example

$old = "Notepad" & @LF & "expects" & @LF & "CRLF text."
$new = StringAddCR($old)


Function StringInStr

Function Reference

StringInStr

Checks if a string contains a given substring.

StringInStr ( "string", "substring" [, casesense [, occurance]] )

Parameters

string | The string to evaluate.
substring | The substring to search for.
casesense | [optional] Flag to indicate if the operations should be case sensitive. 0 = not case sensitive (default) 1 = case sensitive
occurance | [optional] Which occurance of the substring to find in the string. Use a negative occurance to search from the right side. The default value is 1 (finds first occurance).

Return Value

Success: | Returns the position of the substring.
Failure: | Returns 0 if substring not found.
@Error | 0 - Normal operation
 | 1 - Occurance was 0. Occurance must be a positive or negative integer.

Remarks

The first character position is 1. If occurance is given, casesense must also be given.

Related

String, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$result = StringInStr("I am a String", "RING")
MsgBox(0, "Search result:", $result)

$location = StringInStr("How much wood could a woodchuch chuch is a woodchuck could chuck wood?", "wood", 0, 3) ; Find the 3rd occurance of "wood"


Function StringIsAlNum

Function Reference

StringIsAlNum

Checks if a string contains only alphanumeric characters.

StringIsAlNum ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-alphanumeric characters.

Remarks

Keep in mind that any whitespace will cause StringIsAlNum to return 0.

Related

StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringUpper, StringLower

Example

$x = "This is a sentence with whitespace."
MsgBox(0,"StringIsAlNum returns:", StringIsAlNum($x))


Function StringIsAlpha

Function Reference

StringIsAlpha

Checks if a string contains only alphabetic characters.

StringIsAlpha ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-alphabetic characters.

Remarks

Keep in mind that any whitespace will cause StringIsAlpha to return 0.

Related

StringIsAlNum, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringUpper, StringLower

Example

$x = "This is a sentence with whitespace."
MsgBox(0,"StringIsAlpha returns:", StringIsAlpha($x))


Function StringIsASCII

Function Reference

StringIsASCII

Checks if a string contains only ASCII characters in the range 0x00 - 0x7f (0 - 127).

StringIsASCII ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains extended ASCII characters.

Remarks

None.

Related

StringIsAlNum, StringIsAlpha, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit, StringUpper, StringLower

Example

$x = StringIsASCII("This is a sentence.")
MsgBox(0,"StringIsASCII returns:", $x)


Function StringIsDigit

Function Reference

StringIsDigit

Checks if a string contains only digit (0-9) characters.

StringIsDigit ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-digits.

Remarks

See examples.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsLower, StringIsSpace, StringIsUpper, StringIsXDigit

Example

StringIsDigit("12333") ;returns 1
StringIsDigit("1.5") ;returns 0 due to decimal point
StringIsDigit("1 2 3") ;returns 0 due to whitespace
StringIsDigit("") ;returns 0


Function StringIsFloat

Function Reference

StringIsFloat

Checks if a string is a floating point number.

StringIsFloat ( "string" )

Parameters

string The string or expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if not floating point format.

Remarks

A string is a float if it contains at least one decimal digit and exactly one period; the only other character allowed is an optional plus or minus at the beginning. (StringIsFloat does not accept a comma character as the decimal point even if the computer Locale settings use that symbol.) If parameter is not a string, its value is converted to a string. See examples.

Related

StringIsInt, IsFloat

Example

StringIsFloat("1.5") ;returns 1
StringIsFloat("7.") ;returns 1 since contains decimal
StringIsFloat("-.0") ;returns 1
StringIsFloat("3/4") ;returns 0 since '3' slash '4' is not a float

StringIsFloat(1.5) ;returns 1 since 1.5 converted to string contain .
StringIsFloat(1.0) ;returns 0 since 1.0 converted to string does not contain .


Function StringFormat

Function Reference

StringFormat

Returns a formatted string (similar to the C sprintf() function).

StringFormat ( "format control", var1 [, ... var32] )

Parameters

format control | The format and flags to use (see Remarks).
var1...var32 | Up to 32 variables that will be output according to the "format control".

Return Value

Return the formatted string according to "variable format" defined in the "format control" parameter.

Remarks

To prevent buffer overflow, each "variable" is limited to 65535 characters.

"variable format" is; %[flags] [width] [.precision] type

Width Specification

The second optional field of the format specification is the width specification. The width argument is a nonnegative decimal integer controlling the minimum number of characters printed. If the number of characters in the output value is less than the specified width, blanks are added to the left or the right of the values — depending on whether the – flag (for left alignment) is specified — until the minimum width is reached. If width is prefixed with 0, zeros are added until the minimum width is reached (not useful for left-aligned numbers).

The width specification never causes a value to be truncated. If the number of characters in the output value is greater than the specified width, or if width is not given, all characters of the value are printed (subject to the precision specification).

Type Specification

Type | Variable type | Output format
d, i | Integer | Signed decimal integer.
o | Integer | Unsigned octal integer.
u | Integer | Unsigned decimal integer.
x | Integer | Unsigned hexadecimal integer, using "abcdef".
X | Integer | Unsigned hexadecimal integer, using "ABCDEF".
e | Float | Signed value having the form [ - ]d.dddd e [sign]ddd where d is a single decimal digit, dddd is one or more decimal digits, ddd is exactly three decimal digits, and sign is + or -.
E | Float | Identical to the e format except that E rather than e introduces the exponent.
f | Float | Signed value having the form [ - ]dddd.dddd, where dddd is one or more decimal digits. The number of digits before the decimal point depends on the magnitude of the number, and the number of digits after the decimal point depends on the requested precision.
g | Float | Signed value printed in f or e format, whichever is more compact for the given value and precision. The e format is used only when the exponent of the value is less than -4 or greater than or equal to the precision argument. Trailing zeros are truncated, and the decimal point appears only if one or more digits follow it.
G | Float | Identical to the g format, except that E, rather than e, introduces the exponent (where appropriate).
s | String | String.

Flag Specification

Flag | Meaning | Default
- | Left align the result within the given field width. | Right align.
+ | Prefix the output value with a sign (+ or -) if the output value is of a signed type. | Sign appears only for negative signed values (-).
0 | If width is prefixed with 0, zeros are added until the minimum width is reached. If 0 and - appear, the 0 is ignored. If 0 is specified with an integer format (i, u, x, X, o, d) the 0 is ignored. | No padding.
Blank | Prefix the output value with a blank if the output value is signed and positive; the blank is ignored if both the blank and + flags appear. | No blank appears.
# | When used with the o, x, or X format, the # flag prefixes any nonzero output value with 0, 0x, or 0X, respectively. | No blank appears.
# | When used with the e, E, or f format, the # flag forces the output value to contain a decimal point in all cases. | Decimal point appears only if digits follow it.
# | When used with the g or G format, the # flag forces the output value to contain a decimal point in all cases and prevents the truncation of trailing zeros. Ignored when used with c, d, i, u, or s. | Decimal point appears only if digits follow it. Trailing zeros are truncated.

Precision Specification

The third optional field of the format specification is the precision specification. It specifies a nonnegative decimal integer, preceded by a period (.), which specifies the number of characters to be printed, the number of decimal places, or the number of significant digits (see Table below). Unlike the width specification, the precision specification can cause either truncation of the output value or rounding of a floating-point value. If precision is specified as 0 and the value to be converted is 0, the result is no characters output, as shown below:

printf( "%.0d", 0 ); /* No characters output */

How Precision Values Affect Type

Type | Meaning | Default
d, i, u, o, x, X | The precision specifies the minimum number of digits to be printed. If the number of digits in the argument is less than precision, the output value is padded on the left with zeros. The value is not truncated when the number of digits exceeds precision. | Default precision is 1.
e, E | The precision specifies the number of digits to be printed after the decimal point. The last printed digit is rounded. | Default precision is 6; if precision is 0 or the period (.) appears without a number following it, no decimal point is printed.
f | The precision value specifies the number of digits after the decimal point. If a decimal point appears, at least one digit appears before it. The value is rounded to the appropriate number of digits. | Default precision is 6; if precision is 0, or if the period (.) appears without a number following it, no decimal point is printed.
g, G | The precision specifies the maximum number of significant digits printed. | Six significant digits are printed, with any trailing zeros truncated.
s | The precision specifies the maximum number of characters to be printed. Characters in excess of precision are not printed. | Characters are printed until a null character is encountered.

Related

None.

Example

$string = "string"
$float = 12.3
$int = 345
$s =StringFormat ( "var1=%s var2=%.2f, var3=%d" ,$string, $float, $int )
$msgbox(0, "Result", $s)
; will output "var1=string var2=12.30 var3=345"
; notice the 12.30 done with the %.2f which force 2 digits after the decimal point


Function StringIsInt

Function Reference

StringIsInt

Checks if a string is an integer.

StringIsInt ( "string" )

Parameters

string The string to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string cannot be an integer.

Remarks

StringIsInt also returns 1 for non-string integer expressions; however, StringIsInt returns 0 for hexadecimal expressions such as "4ff0". The only punctuation allowed is either a plus or a minus at the beginning of the string.

Related

StringIsFloat, StringIsDigit, IsInt

Example

StringIsInt("+42") ;returns 1
StringIsInt("-00") ;returns 1
StringIsInt("1.0") ;returns 0 due to the decimal point
StringIsInt(1.0) ;returns 1 due to number-string conversion
StringIsInt("1+2") ;returns 0 due to plus sign


Function StringIsLower

Function Reference

StringIsLower

Checks if a string contains only lowercase characters.

StringIsLower ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-lowercase characters.

Remarks

Note that digits/punctuation/whitespace will cause StringIsLower to return 0.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsSpace, StringIsUpper, StringIsXDigit, StringUpper, StringLower

Example

If StringIsLower("abcfoo") Then
MsgBox(0, "Result:", "String contained only lowercase letters")
EndIf


Function StringIsSpace

Function Reference

StringIsSpace

Checks if a string contains only whitespace characters.

StringIsSpace ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-whitespace characters.

Remarks

Whitespace includes Chr(9) thru Chr(13) which are HorizontalTab, LineFeed, VerticalTab, FormFeed, and CarriageReturn.
Whitespace also includes the standard space ( Chr(32) ).

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsUpper, StringIsXDigit, StringUpper, StringLower

Example

$x = " " & @LF & Chr(11) & @TAB & " " & @CRLF
If StringIsSpace($x) Then
MsgBox(0,"", "String only contained whitespace characters.")
EndIf


Function StringIsUpper

Function Reference

StringIsUpper

Checks if a string contains only uppercase characters.

StringIsUpper ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-uppercase characters.

Remarks

Note that digits/punctuation/whitespace will cause StringIsUpper to return 0.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsXDigit, StringUpper, StringLower

Example

If StringIsInt("ABCDF") Then
MsgBox(4096,"", "String contains only UPPERCASE letters"
EndIf


Function StringIsXDigit

Function Reference

StringIsXDigit

Checks if a string contains only hexadecimal digit (0-9, A-F) characters.

StringIsXDigit ( "string" )

Parameters

string The string to check

Return Value

Success: | Returns 1.
Failure: | Returns 0 if string contains non-hexadecimal characters.

Remarks

Valid characters are 0123456789abcdefABCDEF Note that a string containing whitespace or the "0x" prefix will cause StringIsXDigit to return 0.

Related

StringIsAlNum, StringIsAlpha, StringIsASCII, StringIsDigit, StringIsLower, StringIsSpace, StringIsUpper, StringUpper, StringLower

Example

StringIsXDigit("00FC") ;returns 1
StringIsXDigit("2570") ;returns 1
StringIsXDigit("a cafe") ;returns 0 due to space
StringIsXDigit(1 + 2.0) ;returns 1 due to number-string conversion


Function StringLeft

Function Reference

StringLeft

Returns a number of characters from the left-hand side of a string.

StringLeft ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to get.

Return Value

Returns a string containing the leftmost count characters of the string.

Remarks

If count exceeds string length or if count is negative, the entire string is returned.

Related

String, StringInStr, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$result = StringLeft("I am a string", 3)
MsgBox(0, "Leftmost 3 characters are:", $result)


Function StringLen

Function Reference

StringLen

Returns the number of characters in a string.

StringLen ( "string" )

Parameters

string The string to evaluate.

Return Value

Returns the length of the string.

Remarks

A numeric expression is automatically evaluated and converted to a string.

Related

String, StringInStr, StringLeft, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$len = StringLen("How long am I?")
MsgBox(0, "String length is:", $len)


Function StringLower

Function Reference

StringLower

Converts a string to lowercase.

StringLower ( "string" )

Parameters

string The string to convert.

Return Value

Returns the string converted to lowercase.

Remarks

None.

Related

StringIsLower, StringIsUpper, String, StringInStr, StringLeft, StringLen, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$var = StringLower("I Am A String")
MsgBox(0, "String converted to lowercase is:", $var)


Function StringMid

Function Reference

StringMid

Extracts a number of characters from a string.

StringMid ( "string", start [, count] )

Parameters

string | The string to evaluate.
start | The character position to start. (1 = first character)
count | [optional] The number of characters to extract. By default the entire remainder of the string.

Return Value

Returns the extracted string.

Remarks

If start is out-of-bounds, an empty string is returned. If start is valid but count is out-of-bounds, the entire remainder of the string is returned.

Related

String, StringInStr, StringLeft, StringLen, StringLower, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$var = StringMid("I am a string", 3, 2)
MsgBox(0, "2 chars extracted from position 3 are:", $var)


Function StringReplace

Function Reference

StringReplace

Replaces substrings in a string.

StringReplace ( "string", "searchstring" or start, "replacestring" [, count [, casesense]] )

Parameters

string | The string to evaluate.
searchstring | The substring to search for or the character position to start the replacement.
replacestring | The replacement string.
count | [optional] The number of times to replace the searchstring. 0 = all searchstrings will be replaced (default) [count < 0 also replaces all instances]
casesense | [optional] Flag to indicate if the search operation should be case sensitive. 0 = not case sensitive (default) 1 = case sensitive

Return Value

Returns the new string, the number of replacements performed is stored in @extended.

Remarks

The search/replace is performed left-to-right. Thus, StringReplace("aaa", "aa", "bb") returns "bba"

If the start method is used the count and casesense parameters are ignored. If the replacestring cannot not be stored a blank string is returned and @error is set to 1.

Related

String, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$text = StringReplace("this is a line of text", " ", "-")
$numreplacements = @extended
MsgBox(0, "New string is", $text)
MsgBox(0, "The number of replacements done was", $numreplacements)


Function StringRight

Function Reference

StringRight

Returns a number of characters from the right-hand side of a string.

StringRight ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to get.

Return Value

Returns a string containing the rightmost count characters of the string.

Remarks

If count exceeds string length or if count is negative, the entire string is returned.

Related

String, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringTrimLeft, StringTrimRight, StringUpper

Example

$var = StringRight("I am a string", 3)
MsgBox(0, "Rightmost 3 characters are:", $var)


Function StringSplit

Function Reference

StringSplit

Splits up a string into substrings depending on the given delimiters.

StringSplit ( "string", "delimiters" [, flag ] )

Parameters

string | The string to evaluate.
delimiters | One or more characters to use as delimiters.
flag | [optional] If flag is 0 (the default), then each character in the string will mark where to split the string. If flag is 1, then the entire delimiter string is needed to mark the split.

Return Value

Returns an array, the first element ($array[0]) contains the number of strings returned, the remaining elements ($array[1], $array[2], etc.) contain the delimited strings.
If no delimiters were found @error is set to 1, the count is 1 ($array[0]) and the full string is returned ($array[1]).

Remarks

If you use a blank string "" for the delimiters, each character will be returned as an element.

If the delimiter you wish to use is a substring instead of individual single characters, see the second example below.

StringSplit is very useful as an alternative to StringInStr and as a means to populate an array.

Related

String, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringReplace, StringRight, StringTrimLeft, StringTrimRight, StringUpper

Example

$days = StringSplit("Sun,Mon,Tue,Wed,Thu,Fri,Sat", ",")
;$days[1] contains "Sun" ... $days[7] contains "Sat"

$text = "This\nline\ncontains\nC-style breaks."
$array = StringSplit(StringReplace($text, "\n", @LF), @LF)


Function StringStripCR

Function Reference

StringStripCR

Removes all carriage return values ( Chr(13) ) from a string.

StringStripCR ( "string" )

Parameters

string The string to convert.

Return Value

Returns the string with all instances of the @CR character (Chr(13)) removed.

Remarks

None.

Related

StringAddCR, StringStripWS, StringIsSpace

Example

$result = StringStripCR("I am a string" & Chr(13) & Chr(10))
MsgBox(0, "String stripped of all CR characters is:", $result)


Function StringStripWS

Function Reference

StringStripWS

Strips the white space in a string.

StringStripWS ( "string", flag )

Parameters

string | The string to strip.
flag | Flag to indicate the type of stripping that should be performed (add the flags together for multiple operations): 1 = strip leading white space 2 = strip trailing white space 4 = strip double (or more) spaces between words 8 = strip all spaces (over-rides all other flags)

Return Value

Returns the new string stripped of the requested white space.

Remarks

Whitespace includes Chr(9) thru Chr(13) which are HorizontalTab, LineFeed, VerticalTab, FormFeed, and CarriageReturn. Whitespace also includes the null string ( Chr(0) ) and the standard space ( Chr(32) ).

To strip single spaces between words, use the function StringReplace.

Related

StringStripCR, StringIsSpace, StringReplace

Example

$text = StringStripWS(" this is a line of text ", 3)
MsgBox(0, "Stripped from both ends", $text)


Function StringTrimLeft

Function Reference

StringTrimLeft

Trims a number of characters from the left hand side of a string.

StringTrimLeft ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to trim.

Return Value

Returns the string trimmed by count characters from the left.

Remarks

If count is out-of-bounds, an empty string is returned.
StringTrimLeft($str, $n) is functionally equivalent to StringRight($str, StringLen($str) - $n)

Related

String, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimRight, StringUpper

Example

$result = StringTrimLeft("I am a string", 3)
MsgBox(0, "String without leftmost 3 characters is:", $result)


Function StringTrimRight

Function Reference

StringTrimRight

Trims a number of characters from the right hand side of a string.

StringTrimRight ( "string", count )

Parameters

string | The string to evaluate.
count | The number of characters to trim.

Return Value

Returns the string trimmed by count characters from the right.

Remarks

If count is out-of-bounds, an empty string is returned.
StringTrimRight($str, $n) is functionally equivalent to StringLeft($str, StringLen($str) - $n)

Related

String, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringUpper

Example

$result = StringTrimRight("I am a string", 3)
MsgBox(0, "String without rightmost 3 characters is:", $result)


Function StringUpper

Function Reference

StringUpper

Converts a string to uppercase.

StringUpper ( "string" )

Parameters

string The string to convert.

Return Value

Returns the string converted to uppercase.

Remarks

None.

Related

StringIsLower, StringIsUpper, String, StringInStr, StringLeft, StringLen, StringLower, StringMid, StringRight, StringTrimLeft, StringTrimRight

Example

$result = StringUpper("I am 4-word string")
MsgBox(0, "String converted to uppercase is:", $result)


Function Sleep

Function Reference

Sleep

Pause script execution.

Sleep ( delay )

Parameters

delay Amount of time to pause (in milliseconds).

Return Value

None.

Remarks

Maximum sleep time is 2147483647 milliseconds (24 days).

Related

None.

Example

Sleep(5000) ;five seconds


Function TimerInit

Function Reference

TimerInit

Returns a timestamp (in milliseconds).

TimerInit ( )

Parameters

None.

Return Value

Returns a timestamp number (in milliseconds).

Remarks

None.

Related

TimerDiff

Example

$begin = TimerInit()
sleep(3000)
$dif = TimerDiff($begin)
MsgBox(0,"Time Difference",$dif)


Function TimerDiff

Function Reference

TimerDiff

Returns a difference in time from a previous call to TimerInit().

TimerDiff ( timestamp )

Parameters

timestamp timestamp returned from a previous call to TimerInit().

Return Value

Returns a time difference (in milliseconds) from a previous call to TimerInit().

Remarks

None.

Related

TimerInit

Example

$begin = TimerInit()
sleep(3000)
$dif = TimerDiff($begin)
MsgBox(0,"Time Difference",$dif)


Function Asc

Function Reference

Asc

Returns the ASCII code of a character.

Asc ( "char" )

Parameters

char The character to get the code for. If a string is used, the code for the first character is given.

Return Value

Returns the ASCII code of the specified char. If a number is passed instead of a char, the result is -1.

Remarks

See the Appendix for a complete ASCII table.
Asc("0") == 48, Asc("9") == 57, Asc("A") == 65, Asc("Z") == 90, Asc("a") == 97, Asc("z") == 122, etc.

Related

Chr

Example

$code = Asc("A")
MsgBox(0, "ASCII code for A:", $code)


Function Chr

Function Reference

Chr

Returns a character corresponding to an ASCII code.

Chr ( ASCIIcode )

Parameters

ASCIIcode An ASCII code (e.g., 65 returns the capital letter A).

Return Value

Returns a string containing the ASCII representation of the given code.

Remarks

The parameter is converted to a positive integer between 0 and 255 if not already one.
Chr(48) == 0, Chr(57) == 9, Chr(65) == "A", Chr(90) == "Z", Chr(97) == "a", Chr(122) = "z", etc.
A complete ASCII table is in the Appendix.

Related

Asc

Example

$text = ""
For $i = 65 to 90
$text = $text & Chr($i)
Next
MsgBox(0, "Uppercase alphabet", $text)


Function Assign

Function Reference

Assign

Assigns a variable by name with the data.

Assign ( "varname", "data" [, flag] )

Parameters

varname | The name of the variable you wish to assign.
data | The data you wish to assign to the variable.
flag | [optional] controls the way that variables are assigned (add required options together): 0 = (default) Create variable if required 1 = Force creation in local scope 2 = Force creation in global scope 4 = Fail if variable does not already exist

Return Value

Success: | Returns 1.
Failure: | Returns 0 if unable to create/assign the variable.

Remarks

None.

Related

Eval, IsDeclared

Example

Global $variable
If Assign("variable", "Hello") Then MsgBox(4096, "", $variable) ; Will print "Hello"


Function Dec

Function Reference

Dec

Returns a numeric representation of a hexadecimal string.

Dec ( "hex" )

Parameters

hex The hexadecimal string to convert.

Return Value

Success: | Returns a number.
Failure: | Returns 0 sets @error to 1 an invalid hex string was used or if an overflow occurs.

Remarks

The function only works with numbers that fit in a 32 bit signed integer (-2147483648 to 2147483647)

Related

Hex

Example

$dec = Dec("FFFF") ;returns the number 65536


Function Eval

Function Reference

Eval

Return the value of the variable whose name is given by the expression.

Eval ( expression )

Parameters

expression string representing name of the variable to be evaluated.

Return Value

Success: | Returns the value of the variable.
Failure: | Returns null string with @error set to 1.

Remarks

None.

Related

IsDeclared, Assign

Example

Dim $a_b = 12
$s = Eval("a" & "_" & "b") ; $s is set to 12

$s =Eval("c") ; $s = "" and @error = 1


Function Hex

Function Reference

Hex

Returns a string representation of an integer converted to hexadecimal.

Hex ( number, length )

Parameters

number | The integer to convert.
length | Number of characters to be returned (up to 8). Characters are truncated from the left-hand side if length is too small.

Return Value

Success: | Returns a string of length characters, zero-padded if necessary.
Special: | Returns null string if length is less than 1.
Failure: | Returns null string and sets @error to 1 if length is greater than 8.

Remarks

The function only works with numbers that fit in a 32 bit signed integer (-2147483648 to 2147483647)

The function will also set @error to 1 if not enough digits were requested - the returned string will return the least significant digits in this case.

Related

Dec

Example

$result = Hex(1033, 4) ;returns "0409"


Function Int

Function Reference

Int

Returns the integer (whole number) representation of an expression.

Int ( expression )

Parameters

expression An expression to convert into an integer.

Return Value

Returns an integer.

Remarks

Fractional portions are truncated, so Int(1.999999) returns 1
Int(0/0) returns -9.22337203685478e+018, if you were wondering.

Related

Number, String, Round

Example

$var = Int(10.793) ;$var is the integer 10


Function IsAdmin

Function Reference

IsAdmin

Checks if the current user has administrator privileges.

IsAdmin ( )

Parameters

None.

Return Value

Success: | Returns 1 if the current user has administrator privileges.
Failure: | Returns 0 if user lacks admin privileges.

Remarks

This function will always return 1 under Window 95/98/Me.

Related

RunAsSet

Example

If IsAdmin() Then MsgBox(0, "", "Admin rights detected")


Function IsArray

Function Reference

IsArray

Checks if a variable is an array type.

IsArray ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if parameter is not an array variable.

Remarks

Can be useful to validate array/non-array parameters to user-defined functions.

Related

IsFloat, IsInt, IsString

Example

$pos = WinGetPos("Untitled -")
If IsArray($pos) Then
MsgBox(0, "Window height", $pos[3])
EndIf


Function IsDeclared

Function Reference

IsDeclared

Check if a variable has been declared.

IsDeclared ( expression )

Parameters

expression string representing name of the variable to be checked.

Return Value

Success: | Returns 1 for Global variable or variable declared outside functions.
Special: | -1 for Local variable.
Failure: | Return 0 when no variable can be found.

Remarks

None.

Related

Eval

Example

If Not IsDeclared ("a") then
MsgBox(0,"", "$a is NOT declared") ; $a has never been assigned
EndIf

$a=1

If IsDeclared ("a") then
MsgBox(0,"", "$a IS declared" ) ; due to previous $a=1 assignment
EndIf


Function IsFloat

Function Reference

IsFloat

Checks if a variable or expression is a float-type.

IsFloat ( variable )

Parameters

variable The variable or expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not float type.

Remarks

See examples.

Related

IsArray, IsInt, IsString, StringIsFloat

Example

IsFloat(3.14159) ;returns 1
IsFloat(3.000) ;returns 0 since value is integer 3
IsFloat(1/2 - 5) ;returns 1
IsFloat(1.5e3) ;returns 0 since 1.5e3 = 1500
IsFloat("12.345) ;returns 0 since is a string


Function IsInt

Function Reference

IsInt

Checks if a variable or expression is an integer type.

IsInt ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not integer.

Remarks

IsInt(7.5 - 2.5) returns 1 (meaning true).

Related

IsArray, IsFloat, IsString, StringIsInt

Example

IsInt(-12345) ;returns 1
IsInt(3.0000) ;returns 1
IsInt("5432") ;returns 0 since is a string
IsInt(7.5 - 4.5) ;returns 1 since evaluates to integer 3


Function IsNumber

Function Reference

IsNumber

Checks if a variable's base type is numeric.

IsNumber ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not numeric type.

Remarks

Variants can be of two base types: Strings and Numbers. Additionally, a number can be whole (integer) or fractional/floating-point.

Related

IsArray, IsFloat, IsInt, IsString

Example

IsNumber(42)


Function IsString

Function Reference

IsString

Checks if a variable is a string type.

IsString ( variable )

Parameters

variable The variable/expression to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if expression is not string type.

Remarks

None.

Related

IsArray, IsFloat, IsInt

Example

$x = IsString("foo")


Function Number

Function Reference

Number

Returns the numeric representation of an expression.

Number ( expression )

Parameters

expression An expression to convert into a number.

Return Value

Returns a number.

Remarks

A string beginning with letters has a numeric value of zero. A string beginning with digits has non-numeric characters stripped.

Related

Int, String

Example

$w = Number(1+2+10) ;returns 13
$x = Number("3.14") ;returns 3.14
$y = Number("24/7") ;returns 24
$z = Number("tmp3") ;returns 0


Function String

Function Reference

String

Returns the string representation of an expression.

String ( expression )

Parameters

expression An expression to convert into a string.

Return Value

Returns a string.

Remarks

Maximum string length is 2147483647 characters (but keep in mind that no line in an AutoIt script can exceed 4095 characters.)

Related

Int, Number, IsString

Example

$var = String(10)
;$var is the string "10"


Function UBound

Function Reference

UBound

Returns the size of array dimensions.

UBound ( Array [, Dimension] )

Parameters

Array | The array variable which is being queried.
Dimension | [optional] Which dimension of a multi-dimensioned array to report the size of. Default is 1, which is the first dimension. If this parameter is 0, the number of subscripts in the array is returned.

Return Value

Success: | Returns the size of the array dimension.
Failure: | Returns 0 and sets @error:
 | 1 = Array given is not an array.
 | 2 = Array dimension is invalid.

Remarks

Remember that the value returned by UBound is one greater than the index of an array's last element!

Related

Dim

Example

Dim $myArray[10][20] ;element 0,0 to 9,19
$rows = UBound($myArray)
$cols = UBound($myArray, 2)
$dims = UBound($myArray, 0)

MsgBox(0, "The " & $dims & "-dimensional array has", _
$rows & " rows, " & $cols & " columns")

;Display $myArray's contents
$output = ""
For $r = 0 to UBound($myArray,1) - 1
$output = $output & @LF
For $c = 0 to UBound($myArray,2) - 1
$output = $output & $myArray[$r][$c] & " "
Next
Next
MsgBox(4096,"Array Contents", $output)


Function ControlClick

Function Reference

ControlClick

Sends a mouse click command to a given control.

ControlClick ( "title", "text", controlID [, button] [, clicks]] )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.
button | [optional] The button to click, "left", "right" or "middle". Default is the left button.
clicks | optional] The number of times to click the mouse. Default is 1.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

The control might first need to be given focus with the ControlFocus command.

Simulating a click on a control is only 100% accurate when the control's parent window is active - this is done automatically.

Related

ControlCommand, ControlFocus, MouseClick

Example

ControlClick("Untitled -", "", "MDIClient1")


Function ControlCommand

Function Reference

ControlCommand

Sends a command to a control.

ControlCommand ( "title", "text", controlID, "command", "option" )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.
command | The command to send to the control.
option | Additional parameter required by some commands; use "" if parameter is not required.

Return Value

Depends on command as table below shows. In case of an error (such as an invalid command or window/control), @error=1.
Command, Option | Return Value
"IsVisible", "" | Returns 1 if Control is visible, 0 otherwise
"IsEnabled", "" | Returns 1 if Control is enabled, 0 otherwise
"ShowDropDown", "" | Drops a ComboBox
"HideDropDown", "" | UNdrops a ComboBox
"AddString", 'string' | Adds a string to the end in a ListBox or ComboBox
"DelString", occurrence | Deletes a string according to occurrence in a ListBox or ComboBox
"FindString", 'string' | Returns occurrence ref of the exact string in a ListBox or ComboBox
"SetCurrentSelection", occurrence | Sets selection to occurrence ref in a ListBox or ComboBox
"SelectString", 'string' | Sets selection according to string in a ListBox or ComboBox
"IsChecked", "" | Returns 1 if Button is checked, 0 otherwise
"Check", "" | Checks radio or check Button
"UnCheck", "" | Unchecks radio or check Button
"GetCurrentLine", "" | Returns the line # where the caret is in an Edit
"GetCurrentCol", "" | Returns the column # where the caret is in an Edit
"GetCurrentSelection", "" | Returns name of the currently selected item in a ListBox or ComboBox
"GetLineCount", "" | Returns # of lines in an Edit
"GetLine", line# | Returns text at line # passed of an Edit
"GetSelected", "" | Returns selected text of an Edit
"EditPaste", 'string' | Pastes the 'string' at the Edit's caret position
"CurrentTab", "" | Returns the current Tab shown of a SysTabControl32
"TabRight", "" | Moves to the next tab to the right of a SysTabControl32
"TabLeft", "" | Moves to the next tab to the left of a SysTabControl32

Remarks

Certain commands that work on normal Combo and ListBoxes do not work on "ComboLBox" controls.

Related

ControlDisable, ControlEnable, ControlFocus, ControlGetPos, ControlGetText, ControlHide, ControlClick, ControlMove, ControlSetText, ControlShow, StatusbarGetText, WinMenuSelectItem, WinGetClassList

Example

ControlCommand("Untitled - Notepad", "", "Edit1", "GetLineCount", "")


Function ControlDisable

Function Reference

ControlDisable

Disables or "grays-out" a control.

ControlDisable ( "title", "text", controlID)

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

ControlEnable, ControlHide, ControlCommand

Example

ControlDisable("Untitled -", "", "MDIClient1")


Function ControlEnable

Function Reference

ControlEnable

Enables a "grayed-out" control.

ControlEnable ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

ControlDisable, ControlShow, ControlCommand

Example

ControlEnable("Untitled -", "", "MDIClient1")


Function ControlFocus

Function Reference

ControlFocus

Sets input focus to a given control on a window.

ControlFocus ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns 1.
Failure: | Returns 0.

Remarks

None.

Related

ControlCommand, WinActivate

Example

ControlFocus("Untitled - Notepad", "", "Edit1")


Function ControlGetFocus

Function Reference

ControlGetFocus

Returns the ControlRef# of the control that has keyboard focus within a specified window.

ControlGetFocus ( "title" [, "text"] )

Parameters

title | Title of window to check.
text | [optional] Text from window to check.

Return Value

Success: | Returns the ClassNameNN of the control that has keyboard focus within a specified window.
Failure: | Returns a blank string and sets @error to 1 if window is not found.

Remarks

None.

Related

ControlFocus, ControlCommand, WinActive

Example

$a = ControlGetFocus("Untitled - Notepad")


Function ControlGetHandle

Function Reference

ControlGetHandle

Retrieves the internal handle of a control.

ControlGetHandle ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns the handle (HWND) value.
Failure: | Returns "" (blank string) and sets @error to 1 if no window matches the criteria.

Remarks

This function returns a HWND/Handle value.

Related

None.

Example

$handle = ControlGetHandle("Untitled - Notepad", "", "Edit1")


Function ControlGetPos

Function Reference

ControlGetPos

Retrieves the position and size of a control relative to it's window.

ControlGetPos ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns an array containing the control's position and size relative to it's window:
 | $array[0] = X position
 | $array[1] = Y position
 | $array[2] = Width
 | $array[3] = Height
Failure: | Sets @error to 1.

Remarks

None.

Related

ControlCommand, ControlMove, WinMove

Example

$pos = ControlGetPos("Untitled - Notepad", "", "Edit1")
MsgBox(0, "Window Stats:", "POS: " & $pos[0] & "," & $pos[1] & " SIZE: " & $pos[2] & "," & $pos[3] )


Function ControlGetText

Function Reference

ControlGetText

Retrieves text from a control.

ControlGetText ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns text from a control.
Failure: | Sets @error to 1 and returns a blank string of "".

Remarks

None.

Related

WinGetText, StatusbarGetText, ControlSetText, ControlCommand

Example

$var = ControlGetText("Untitled - Notepad", "", "Edit1")


Function ControlHide

Function Reference

ControlHide

Hides a control.

ControlHide ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window/control is not found.

Remarks

None.

Related

ControlShow, ControlCommand, WinSetState

Example

ControlHide("Untitled -", "", "MDIClient1")


Function ControlListView

Function Reference

ControlListView

Sends a command to a ListView32 control.

ControlListView ( "title", "text", controlID, "command" [, option1 [, option2]] )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.
command | The command to send to the control (see below).
option1 | [optional] Additional parameter required by some commands.
option2 | [optional] Additional parameter required by some commands.

Return Value

Depends on command as table below shows. In case of an error (such as an invalid command or window/control could not be found) then @error is set to 1.
All items/subitems are 0 based. This means that the first item/subitem in a list is 0, the second is 1, and so on.
In a "Details" view of a ListView32 control, the "item" can be thought of as the "row" and the "subitem" as the "column".
Command, Option1, Option2 | Operation
"DeSelect", From [, To] | Deselects one or more items.
"FindItem", "string to find" [, SubItem] | Returns the item index of the string. Returns -1 if the string is not found.
"GetItemCount" | Returns the number of list items.
"GetSelected" [, option] | Returns a string containing the item index of selected items. If option=0 (default) only the first selected item is returned. If option=1 then all the selected items are returned delimited by |, e.g: "0|3|4|10". If no items are selected a blank "" string is returned.
"GetSelectedCount" | Returns the number of items that are selected.
"GetSubItemCount" | Returns the number of subitems.
"GetText", Item, SubItem | Returns the text of a given item/subitem.
"IsSelected", Item | Returns 1 if the item is selected, otherwise returns 0.
"Select", From [, To] | Selects one or more items.
"SelectAll" | Selects all items.
"SelectClear" | Clears the selection of all items.
"SelectInvert" | Inverts the current selection.
"ViewChange", "view" | Changes the current view. Valid views are "list", "details", "smallicons", "largeicons".

Remarks

None.

Related

ControlCommand, ControlDisable, ControlEnable, ControlFocus, ControlGetPos, ControlGetText, ControlHide, ControlClick, ControlMove, ControlSetText, ControlShow, StatusbarGetText, WinMenuSelectItem, WinGetClassList

Example

ControlListView("C:\Program Files\NSIS", "", "SysListView321", "SelectAll")
ControlListView("C:\Program Files\NSIS", "", "SysListView321", "Deselect", 2, 5)
MsgBox(0, "", ControlListView("C:\Program Files\NSIS", "", "SysListView321", "GetText", 9, 0) )
MsgBox(0, "", ControlListView("C:\Program Files\NSIS", "", "SysListView321", "FindItem", "14 KB", 1) )
MsgBox(0, "", ControlListView("C:\Program Files\NSIS", "", "SysListView321", "GetSelected", 1) )


Function ControlMove

Function Reference

ControlMove

Moves a control within a window.

ControlMove ( "title", "text", controlID, x, y [, width [, height]] )

Parameters

title | The title of the window to move.
text | The text of the window to move.
controlID | The control to interact with. See Controls.
x | X coordinate to move to.
y | Y coordinate to move to.
width | [optional] New width of the window.
height | [optional] New height of the window.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window/control is not found.

Remarks

None.

Related

ControlCommand, WinMove

Example

ControlMove("Untitled -", "", "MDIClient1", 0, 0, 200, 200)


Function ControlSend

Function Reference

ControlSend

Sends a string of characters to a control.

ControlSend ( "title", "text", controlID, "string" [, flag] )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.
string | String of characters to send to the control.
flag | [optional] Changes how "keys" is processed: flag = 0 (default), Text contains special characters like + to indicate SHIFT and {LEFT} to indicate left arrow. flag = 1, keys are sent raw.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window/control is not found.

Remarks

ControlSend works in a similar way to Send but it can send key strokes directly to a window, rather than just to the active window.

Related

ControlCommand, Send

Example

ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window")


Function ControlSetText

Function Reference

ControlSetText

Sets text of a control.

ControlSetText ( "title", "text", controlID, "new text" )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.
new text | The new text to be set into the control.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window/control is not found.

Remarks

None.

Related

ControlGetText, ControlCommand

Example

Run("notepad.exe")
WinWait("Untitled -")
ControlSetText("Untitled -", "", "Edit1", "New Text Here" )


Function ControlShow

Function Reference

ControlShow

Shows a control that was hidden.

ControlShow ( "title", "text", controlID )

Parameters

title | The title of the window to access.
text | The text of the window to access.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window/control is not found.

Remarks

None.

Related

ControlHide, ControlEnable, ControlCommand

Example

ControlShow("Untitled -", "", "MDIClient1")


Function StatusbarGetText

Function Reference

StatusbarGetText

Retrieves the text from a standard status bar control.

StatusbarGetText ( "title" [, "text" [, part]] )

Parameters

title | The title of the window to check.
text | [optional] The text of the window to check.
part | [optional] The "part" number of the status bar to read - the default is 1. 1 is the first possible part and usually the one that contains the useful messages like "Ready" "Loading...", etc.

Return Value

Success: | Returns the text read.
Failure: | Returns empty string and sets @error to 1 if no text could be read.

Remarks

This functions attempts to read the first standard status bar on a window (Microsoft common control: msctls_statusbar32). Some programs use their own status bars or special versions of the MS common control which StatusbarGetText cannot read. For example, StatusbarText does not work on the program TextPad; however, the first region of TextPad's status bar can be read using ControlGetText("TextPad", "", "HSStatusBar1")
StatusbarGetText can work on windows that are minimized or even hidden.

Related

ControlGetText, ControlCommand

Example

AutoItSetOption("WinTitleMatchMode", 2)
$x = StatusbarGetText("Internet Explorer")
MsgBox(0, "Internet Explorer's status bar says:", $x)


Function WinActivate

Function Reference

WinActivate

Activates (gives focus to) a window.

WinActivate ( "title" [, "text"] )

Parameters

title | The title of the window to activate.
text | [optional] The text of the window to activate.

Return Value

None.

Remarks

You can use the WinActive function to check if WinActivate succeeded. If multiple windows match the criteria, the window that was most recently active is the one activated. WinActivate works on minimized windows. However, a window that is "Always On Top" could still cover up a window you Activated.

Related

WinClose, WinSetState, WinTitleMatchMode (Option)

Example

WinActivate("Untitled - Notepad", "")


Function WinActive

Function Reference

WinActive

Checks to see if a specified window exists and is currently active.

WinActive ( "title" [, "text"] )

Parameters

title | The title of the window to activate.
text | [optional] The text of the window to activate.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if window is not active.

Remarks

None.

Related

WinExists, WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive, WinTitleMatchMode (Option)

Example

If WinActive("Untitled -") Then
MsgBox(0, "", "Window was active")
EndIf


Function WinClose

Function Reference

WinClose

Closes a window.

WinClose ( "title" [, "text"] )

Parameters

title | The title of the window to close.
text | [optional] The text of the window to close.

Return Value

None.

Remarks

This function sends a close message to a window, the result depends on the window (it may ask to save data, etc.). To force a window to close, use the WinKill function. If multiple windows match the criteria, the window that was most recently active is closed.

Related

WinActivate, WinExists, WinKill, WinSetState, WinTitleMatchMode (Option)

Example

WinClose("Untitled - Notepad", "")


Function WinExists

Function Reference

WinExists

Checks to see if a specified window exists.

WinExists ( "title" [, "text"] )

Parameters

title | The title of the window to check.
text | [optional] The text of the window to check.

Return Value

Returns 1 if the window exists, otherwise returns 0.

Remarks

WinExist will return 1 even if a window is hidden.

Related

WinActive, WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive, WinTitleMatchMode (Option)

Example

If WinExists("Untitled -") Then
MsgBox(0, "", "Window exists")
EndIf


Function WinGetCaretPos

Function Reference

WinGetCaretPos

Returns the coordinates of the caret in the foreground window

WinGetCaretPos ( )

Parameters

None.

Return Value

Success: | Returns a 2-element array containing the following information:
 | $array[0] = X coordinate
 | $array[1] = Y coordinate
Failure: | Sets @error to 1.

Remarks

WinGetCaretPos might not return accurate values for Multiple Document Interface (MDI) applications if absolute CaretCoordMode is used. See example for a workaround. Note: Some applications report static coordinates regardless of caret position!

Related

CaretCoordMode (Option)

Example

$a = WinGetCaretPos()
If Not @error Then ToolTip("First Method Pos", $a[0], $a[1])
sleep(2000)

$b = _CaretPos()
If Not @error Then ToolTip("Second Method Pos", $b[0], $b[1])
sleep(2000)

; More reliable method to get caret coords in MDI text editors.
Func _CaretPos()
Local $x_adjust = 5
Local $y_adjust = 40

Opt("CaretCoordMode", 0) ;relative mode
Local $c = WinGetCaretPos() ;relative caret coords
Local $w = WinGetPos("") ;window's coords
Local $f = ControlGetFocus("","") ;text region "handle"
Local $e = ControlGetPos("", "", $f) ;text region coords

Local $t[2]
If IsArray($c) and IsArray($w) and IsArray($e) Then
$t[0] = $c[0] + $w[0] + $e[0] + $x_adjust
$t[1] = $c[1] + $w[1] + $e[1] + $y_adjust
Return $t ;absolute screen coords of caret cursor
Else
SetError(1)
EndIf
EndFunc


Function WinGetClassList

Function Reference

WinGetClassList

Retrieves the classes from a window.

WinGetClassList ( "title" [, "text"] )

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a string containing the window classes read.
Failure: | Returns numeric 1 and sets @error to 1 if no window matches the criteria.

Remarks

Class names are linefeed (@LF) separated. WinGetClassList works on both minimized and hidden windows. Up to 64KB of text can be retrieved. If multiple windows match the criteria, the classes are read from the most recently active window.

Related

WinGetText, ControlCommand

Example

$text = WinGetClassList("Untitled -", "")
MsgBox(0, "Text read was:", $text)


Function WinGetClientSize

Function Reference

WinGetClientSize

Retrieves the size of a given window's client area.

WinGetClientSize ( "title" [, "text"] )

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a 2-element array containing the following information:
 | $array[0] = Width of window's client area
 | $array[1] = Height of window's client area
Failure: | Returns numeric 1 and sets @error to 1 if windows is not found.

Remarks

If the window is minimized, the returned width and height values are both zero. However, WinGetClientSize works correctly on (non-minimized) hidden windows. If the window title "Program Manager" is used, the function will return the size of the desktop. WinGetClientSize("") matches the active window. If multiple windows match the criteria, the most recently active window is used.

Related

WinGetPos, WinMove

Example

$size = WinGetClientSize("")
MsgBox(0, "Active window's client size is (width,height):", $size[0] & " " & $size[1])


Function WinGetHandle

Function Reference

WinGetHandle

Retrieves the internal handle of a window.

WinGetHandle ( "title" [, "text"] )

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a string containing the window handle value.
Failure: | Returns "" (blank string) and sets @error to 1 if no window matches the criteria.

Remarks

This function is for use with the advanced WinTitleMatchMode options that allow you to use classnames and handles to specify windows rather than "title" and "text".
Once you have obtained the handle you can access the required window even if its title changes.

Related

WinTitleMatchMode (Option)

Example

; Identify the Notepad window that contains the text "this one" and get a handle to it

; Change into the WinTitleMatchMode that supports classnames and handles
AutoItSetOption("WinTitleMatchMode", 4)

; Get the handle of a notepad window that contains "this one"
$handle = WinGetHandle("classname=Notepad", "this one")
If @error Then
MsgBox(4096, "Error", "Could not find the correct window")
Else
; Send some text directly to this window's edit control
ControlSend($handle, "", "Edit1", "AbCdE")
EndIf


Function WinGetPos

Function Reference

WinGetPos

Retrieves the position and size of a given window.

WinGetPos ( "title" [, "text"] )

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a 4-element array containing the following information:
 | $array[0] = X position
 | $array[1] = Y position
 | $array[2] = Width
 | $array[3] = Height
Failure: | Returns numeric 1 and sets @error to 1 if windows is not found.

Remarks

WinGetPos returns negative numbers such as -32000 for minimized windows, but works fine with (non-minimized) hidden windows.
If the window title "Program Manager" is used, the function will return the size of the desktop. If multiple windows match the criteria, the most recently active window is used.

Related

WinGetClientSize, WinMove

Example

$size = WinGetPos("")
MsgBox(0, "Active window stats (x,y,width,height):", $size[0] & " " & $size[1] & " " & $size[2] & " " & $size[3])


Function WinGetProcess

Function Reference

WinGetProcess

Retrieves the Process ID (PID) associated with a window.

WinGetProcess ( "title" [, "text"] )

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a numeric Process ID (PID).
Failure: | Returns -1.

Remarks

None.

Related

ProcessWait, ProcessWaitClose, ProcessList

Example

$pid = WinGetProcess("Untitled - Notepad")
MsgBox(0, "PID is", $pid)


Function WinGetState

Function Reference

WinGetState

Retrieves the state of a given window.

WinGetState ( "title" [, "text"] )

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns a value indicating the state of the window. Multiple values are added together so use BitAND() to examine the part you are interested in:
 | 1 = Window exists
 | 2 = Window is visible
 | 4 = Windows is enabled
 | 8 = Window is active
 | 16 = Window is minimized
 | 32 = Windows is maximized
Failure: | Returns 0 and sets @error to 1 if the window is not found.

Remarks

None.

Related

BitAND, WinGetPos

Example

; Check if a new notepad window is minimized
$state = WinGetState("Untitled", "")

; Is the "minimized" value set?
If BitAnd($state, 16) Then
MsgBox(0, "Example", "Window is minimized")
EndIf


Function WinGetText

Function Reference

WinGetText

Retrieves the text from a window.

WinGetText ( "title" [, "text"] )

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Returns a string containing the window text read. Returns numeric 1 if no title match.

Remarks

Up to 64KB of window text can be retrieved. WinGetText works on minimized windows, but only works on hidden windows if you've set AutoItSetOption("WinDetectHiddenText", 1)
If multiple windows match the criteria for WinGetText, the information for the most recently active match is returned.
Use WinGetText("") to get the active window's text.

Related

WinGetTitle, ControlGetText

Example

$text = WinGetText("Untitled -", "")
MsgBox(0, "Text read was:", $text)


Function WinGetTitle

Function Reference

WinGetTitle

Retrieves the full title from a window.

WinGetTitle ( "title" [, "text"] )

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Returns a string containing the complete window title. Returns numeric 1 if no title match.

Remarks

WinGetTitle("") returns the active window's title. WinGetTitle works on both minimized and hidden windows. If multiple windows match the criteria, the most recently active window is used.

Related

AutoItWinGetTitle, WinGetText, WinSetTitle, WinTitleMatchMode (Option)

Example

$title = WinGetTitle("Untitled -", "")
MsgBox(0, "Full title read was:", $title)


Function WinKill

Function Reference

WinKill

Forces a window to close.

WinKill ( "title" [, "text"] )

Parameters

title | The title of the window to close.
text | [optional] The text of the window to close.

Return Value

None. (Always returns 1 regardless of success.)

Remarks

The difference between this function and WinClose is that WinKill will forcibly terminate the window if it doesn't close quickly enough. Consequently, a user might not have time to respond to dialogs prompting the user to save data. Although WinKill can work on both minimized and hidden windows, some windows (notably explorer windows) can only be terminated using WinClose.

Related

WinActivate, WinClose, WinSetState, ProcessClose

Example

WinKill("Untitled - ", "")


Function WinList

Function Reference

WinList

Retrieves a list of windows.

WinList ( ["title" [, "text"]] )

Parameters

title | [optional] The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Returns an array of matching window titles and handles.

Remarks

If no title and text is given then all top-level windows are returned.

The array returned is two-dimensional and is made up as follows:
$array[0][0] = Number of windows returned
$array[1][0] = 1st window title
$array[1][1] = 1st window handle (HWND)
$array[2][0] = 2nd window title
$array[2][1] = 2nd window handle (HWND)
...
$array[n][0] = nth window title
$array[n][1] = nth window handle (HWND)

Related

WinGetHandle

Example

$var = WinList()

For $i = 1 to $var[0][0]
; Only display visble windows that have a title
If $var[$i][0] <> "" AND IsVisible($var[$i][1]) Then
MsgBox(0, "Details", "Title=" & $var[$i][0] & @LF & "Handle=" & $var[$i][1])
EndIf
Next

Func IsVisible($handle)
If BitAnd( WinGetState($handle), 2 ) Then
Return 1
Else
Return 0
EndIf

EndFunc


Function WinMenuSelectItem

Function Reference

WinMenuSelectItem

Invokes a menu item of a window.

WinMenuSelectItem ( "title", "text", "item" [, "item" [, "item" [, "item" [, "item" [, "item" [, "item"]]]]]] )

Parameters

title | The title of the window to read.
text | The text of the window to read.
item | Text of Menu Item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item
item | [optional] Text of SubMenu item

Return Value

Success: | Returns 1.
Failure: | Returns 0 if the menu could not be found.

Remarks

You should note that underlined menu items actually contain a & character to indicate the underlining. Thus, the menu item File would actually require the text "&File", and Convert would require "Con&vert" You can access menu items up to six levels deep; and the window can be inactive, minimized, and/or even hidden.

WinMenuSelectItem will only work on standard menus. Unfortunately, many menus in use today are actually custom written or toolbars "pretending" to be menus. This is true for most Microsoft applications.

Related

ControlCommand, Send

Example

; This will select File, Page Setup in notepad
WinMenuSelectItem("Untitled - ", "", "&File", "Page Set&up..." )


Function WinMinimizeAll

Function Reference

WinMinimizeAll

Minimizes all windows.

WinMinimizeAll ( )

Parameters

None.

Return Value

None.

Remarks

Send("#m") is a possible alternative.

Related

WinMinimizeAllUndo, WinSetState

Example

WinMinimizeAll()


Function WinMinimizeAllUndo

Function Reference

WinMinimizeAllUndo

Undoes a previous WinMinimizeAll function.

WinMinimizeAllUndo ( )

Parameters

None.

Return Value

None.

Remarks

Send("#+m") is a possible alternative.

Related

WinMinimizeAll, WinSetState

Example

WinMinimizeAllUndo()


Function WinMove

Function Reference

WinMove

Moves and/or resizes a window.

WinMove ( "title", "text", x, y [, width [, height]] )

Parameters

title | The title of the window to move/resize.
text | The text of the window to move/resize.
x | X coordinate to move to.
y | Y coordinate to move to.
width | [optional] New width of the window.
height | [optional] New height of the window.

Return Value

None.

Remarks

WinMove has no effect on minimized windows, but WinMove works on hidden windows.
If very width and height are small (or negative), the window will go no smaller than 112 x 27 pixels. If width and height are large, the window will go no larger than approximately [12+@DesktopWidth] x [12+@DesktopHeight] pixels.
Negative values are allowed for the x and y coordinates. In fact, you can move a window off screen; and if the window's program is one that remembers its last window position, the window will appear in the corner (but fully on-screen) the next time you launch the program.
If multiple windows match the criteria, the most recently active window is used.

Related

WinActivate, WinClose, WinGetClientSize, WinGetPos, WinSetState

Example

WinMove("Untitled -", "", 0, 0, 200, 200)


Function WinSetOnTop

Function Reference

WinSetOnTop

Change a window's "Always On Top" attribute.

WinSetOnTop ( "title", "text", flag )

Parameters

title | The title of the window to affect.
text | The text of the window to affect.
flag | Determines whether the window should have the "TOPMOST" flag set. 1=set on top flag, 0 = remove on top flag

Return Value

None.

Remarks

Third-party programs which add an "Always On Top" context menu entry might not update their menu entry to reflect the AutoIt-induced change in TOPMOST status.

Related

WinSetState

Example

WinSetOnTop("Untitled -", "", 1)


Function WinSetState

Function Reference

WinSetState

Shows, hides, minimizes, maximizes, or restores a window.

WinSetState ( "title", "text", flag )

Parameters

title | The title of the window to show.
text | The text of the window to show.
flag | The "show" flag of the executed program: @SW_HIDE = Hide window @SW_SHOW = Shows a previously hidden window @SW_MINIMIZE = Minimize window @SW_MAXIMIZE = Maximize window @SW_RESTORE = Undoes a window minimization or maximization @SW_DISABLE = Disables the window @SW_ENABLE = Enables the window

Return Value

None.

Remarks

WinSetState is a replacement for the badly named WinShow function. WinShow is accepted as an alias but this may be withdrawn in the future.

If multiple windows match the criteria, the most recently active window is used.
@SW_MINIMIZE and @SW_MAXIMIZE even work on modal dialog windows.

Related

WinActivate, WinClose

Example

WinSetState("Untitled -", "", @SW_HIDE)
Sleep(3000)
WinSetState("Untitled -", "", @SW_SHOW)


Function WinSetTitle

Function Reference

WinSetTitle

Changes the title of a window.

WinSetTitle ( "title", "text", "newtitle" )

Parameters

title | The title of the window to change.
text | The text of the window to change.
newtitle | The new title to give to the window.

Return Value

None.

Remarks

If multiple windows match the criteria the title of most recently active window is changed.

Related

AutoItWinSetTitle, WinGetTitle, WinTitleMatchMode (Option)

Example

WinSetTitle("Untitled - ", "", "My New Notepad")


Function WinSetTrans

Function Reference

WinSetTrans

Sets the transparency of a window. (Windows 2000/XP or later)

WinSetTrans ( "title", "text", transparency )

Parameters

title | The title of the window to change.
text | The text of the window to change.
transparency | A number in the range 0 - 255. The larger the number, the more transparent the window will become.

Return Value

Non-zero on success, zero on failure. @error will be set to 1 if the function isn't supported on an OS.

Remarks

Requires Windows 2000/XP or later.

Related

None.

Example

Opt("WinTitleMatchMode", 2) ; Match substring
WinSetTrans("Notepad", "", 170) ; Make Notepad window semi-transparent.


Function WinWait

Function Reference

WinWait

Pauses execution of the script until the requested window exists.

WinWait ( "title" [, "text" [, timeout]] )

Parameters

title | The title of the window to check.
text | [optional] The text of the window to check.
timeout | [optional] Timeout in seconds

Return Value

Success: | Returns 1.
Failure: | Returns 0 if timeout occurred.

Remarks

None.

Related

WinActive, WinExists, WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive, WinWaitDelay (Option)

Example

;Wait for the window "Untitled" to exist

Run("notepad")
WinWait("Untitled")

;Wait a maximum of 5 seconds for "Untitled" to exist
WinWait("Untitled", "", 5)


Function WinWaitActive

Function Reference

WinWaitActive

Pauses execution of the script until the requested window is active.

WinWaitActive ( "title", ["text"], [timeout] )

Parameters

title | The title of the window to check.
text | [optional] The text of the window to check.
timeout | [optional] Timeout in seconds

Return Value

Success: | Returns 1.
Failure: | Returns 0 if timeout occurred.

Remarks

None.

Related

WinActive, WinExists, WinWait, WinWaitClose, WinWaitNotActive, WinWaitDelay (Option)

Example

;Wait for the window "Untitled" to exist and be active
WinWaitActive("Untitled")

;Wait a maximum of 5 seconds for "Untitled" to exist and be active
WinWaitActive("Untitled", "", 5)


Function WinWaitClose

Function Reference

WinWaitClose

Pauses execution of the script until the requested window does not exist.

WinWaitClose ( "title" [, "text" [, timeout]] )

Parameters

title | The title of the window to check.
text | [optional] The text of the window to check.
timeout | [optional] Timeout in seconds

Return Value

Success: | Returns 1.
Failure: | Returns 0 if timeout occurred.

Remarks

If the window already doesn't exist when this function is called it will return 0 immediately. The window is polled every 250 milliseconds or so.

Related

WinActive, WinExists, WinWait, WinWaitActive, WinWaitNotActive, WinWaitDelay (Option)

Example

;Wait for the window "Untitled" to not exist
WinWaitClose("Untitled")

;Wait a maximum of 5 seconds for "Untitled" to not exist
WinWaitClose("Untitled", "", 5)


Function WinWaitNotActive

Function Reference

WinWaitNotActive

Pauses execution of the script until the requested window is not active.

WinWaitNotActive ( "title" [, "text" [, timeout]] )

Parameters

title | The title of the window to check.
text | [optional] The text of the window to check.
timeout | [optional] Timeout in seconds

Return Value

Returns 0 if the timeout occurred, otherwise returns 1.

Remarks

The script polls for a window match every 250 milliseconds or so.

Related

WinActive, WinExists, WinWait, WinWaitActive, WinWaitClose, WinWaitDelay (Option)

Example

;Wait for the window "Untitled" to not be active
WinWaitNotActive("Untitled")

;Wait a maximum of 5 seconds for "Untitled" to not be active
WinWaitNotActive("Untitled", "", 5)


User Defined Functions

User Defined Function Reference

Below is a complete list of the user defined functions available in AutoIt. Click on a user defined function name for a detailed description.

User Defined Function | Description
_ArrayAdd | Adds a specified value at the end of an array, returning the adjusted array.
_ArrayBinarySearch | Uses the binary search algorithm to search through a 1-dimensional array.
_ArrayCreate | Create a small array and quickly assign values.
_ArrayDelete | Deletes the specified element from the given array, returning the adjusted array.
_ArrayDisplay | Displays a 1-dimensional array in a message box.
_ArrayInsert | Inserts the a new string at the specified element into an array, returning the adjusted array.
_ArrayMax | Returns the highest value held in an array.
_ArrayMaxIndex | Returns the index where the highest value occurs in the array.
_ArrayMin | Returns the lowest value held in an array.
_ArrayMinIndex | Returns the index where the lowest value occurs in the array.
_ArrayPop | Returns the last element of an array, deleting that element from the array at the same time.
_ArrayReverse | Takes the given array and reverses the order in which the elements appear in the array.
_ArraySort | Sort a mutiple dimensional Array.
_ArraySwap | Swaps two elements of an array.
_ArrayToClip | Sends the contents of an array to the clipboard.
_ArrayToString | Places the elements of an array into a single string, separated by the specified delimiter.
_ArrayTrim | Trims all elements in an array a certain number of characters.
_Ceil | Returns the smallest integer greater than or equal to the specified value.
_ColorGetBlue | Returns the blue component of a given color.
_ColorGetGreen | Returns the green component of a given color.
_ColorGetRed | Returns the red component of a given color.
_DateAdd | Calculates a new date based on a given date and add an interval.
_DateDayOfWeek | Returns the name of the weekday, based on the specified day.
_DateDaysInMonth | Returns the number of days in a month, based on the specified month and year.
_DateDiff | Returns the difference between 2 dates, expressed in the type requested.
_DateIsLeapYear | Checks a given year to see if it is a leap year.
_DateIsValid | Checks the given date to determine if it is a valid date.
_DateTimeFormat | Returns the date in the PC's regional settings format.
_DateToDayValue | Split a string containing Date and Time into two separate Arrays.
_DateToDayOfWeek | Returns the weekdaynumber for a given date.
_DateToDayValue | Returns the daynumber since since noon 4713 BC January 1 for a given Gregorian date.
_DayValueToDate | Add the given days since noon 4713 BC January 1 and returns the Gregorian date.
_FileCountLines | Returns the number of lines in the specified file.
_FileCreate | Creates or zero's out the length of the file specified.
_FileReadToArray | Reads the specified file into an array.
_FileWriteLog | Writes current date,time and the specified text to a log file.
_Floor | Returns the greatest integer less than or equal to the specified value.
_GetIP | Get public IP address of a network/computer.
_HexToString | Convert a hex string to a string.
_Iif | Perform a boolean test within an expression.
_INetExplorerCapable | Converts a string to IE(Internet Explorer) capable line
_INetMail | Opens default user's mail client with given address, subject, and body.
_MathCheckDiv | Checks if NumA is divisable by NumB
_Max | Evaluates which of the two numbers is higher.
_Min | Evaluates which of the two numbers is lower.
_Now | Returns the current Date and Time in PC's format.
_NowCalc | Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS for use in date calculations.
_NowCalcDate | Returns the current Date in format YYYY/MM/DD.
_NowDate | Returns the current Date in the Pc's format.
_NowTime | Returns the current Time in format HH:MM:SS.
_RunDos | Executes a DOS command in a hidden command window.
_StringEncrypt | An RC4 based string encryption function.
_StringProper | Changes a string to proper case, same a =Proper function in Excel
_StringRepeat | Repeats a string a specified number of times.
_StringReverse | Reverses the contents of the specified string.
_StringToHex | Convert a string to a hex string.
_TempFile | Generate a name for a temporary file. The file is guaranteed not to already exist in the user's %TEMP% directory.
_TicksToTime | Converts the specified tick amount to hours, minutes, and seconds.
_TimeToTicks | Converts the specified hours, minutes, and seconds to ticks.
_viOpen | Closes a VISA connection to an Instrument/Device
_viExecCommand | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viFindGpib | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viGpibBusReset | GPIB BUS "reset": Use this function when the GPIB BUS gets stuck for some reason. You might be lucky and resolve the problem by calling this function
_viGTL | Go To Local mode: Instruments that accept this command will exit the "Remote Control mode" and go to "Local mode". If the instrument is already in "Local mode" this is simply ignored. Normally, if an instrument does not support this command it will simply stay in the "Remote Control mode"
_viOpen | Opens a VISA connection to an Instrument/Device
_viSetAttribute | Set any VISA attribute This function, which is called by _viSetTimeout, can ALSO be used to set the other VISA specific attributes. Read the VISA documentation for more information and a list of VISA attributes and their corresponding values.
_viSetTimeout | Sets the VISA timeout in MILISECONDS


Function Notes

User Defined Function Notes

We have included number of files that each contain standard AutoIt3 Functions, so called User Defined Functions.
UDF's are functions/Scriptlets, written in AutoIt3, you can #include in your own script and use them without the need to program it yourself or Copy&Paste them every time you need them.

Example:

#include <date.au3>

MsgBox(0,"Today","Today's date is " & Now())

This script will display today's date formatted in your pc's long format. e.g. "Sunday, December 18, 2004"

Many UDF's contain optional parameters that can be omitted. If you wish to specify an optional parameter, however, all parameters that precede it must be specified!
For example, consider _ArraySort ( ByRef $a_Array, [[[[$i_Descending], $i_Base=0], $i_Ubound=0, $i_Dim=1]] )
When a parameters is preceded with Byref mean that the function will update this variable with a new value. These parameters must be a variable ($xyz) and cannot be a constant.

Most UDF's indicate success/failure as a return value; others indicate it by setting the @error flag. Some do both....
@error = 0 ;is always success
Return = varies, but is typically non-zero for success to allow easy to read code...

If a function can set the @error flag, you should always check it before using a return value - if @error indicates an error then the function return value is generally undefined...


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Array Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_ArrayAdd | Adds a specified value at the end of an array, returning the adjusted array.
_ArrayBinarySearch | Uses the binary search algorithm to search through a 1-dimensional array.
_ArrayCreate | Create a small array and quickly assign values.
_ArrayDelete | Deletes the specified element from the given array, returning the adjusted array.
_ArrayDisplay | Displays a 1-dimensional array in a message box.
_ArrayInsert | Inserts the a new string at the specified element into an array, returning the adjusted array.
_ArrayMax | Returns the highest value held in an array.
_ArrayMaxIndex | Returns the index where the highest value occurs in the array.
_ArrayMin | Returns the lowest value held in an array.
_ArrayMinIndex | Returns the index where the lowest value occurs in the array.
_ArrayPop | Returns the last element of an array, deleting that element from the array at the same time.
_ArrayReverse | Takes the given array and reverses the order in which the elements appear in the array.
_ArraySort | Sort a mutiple dimensional Array.
_ArraySwap | Swaps two elements of an array.
_ArrayToClip | Sends the contents of an array to the clipboard.
_ArrayToString | Places the elements of an array into a single string, separated by the specified delimiter.
_ArrayTrim | Trims all elements in an array a certain number of characters.


Function _ArrayAdd

Function Reference

_ArrayAdd

Adds a specified value at the end of an array, returning the adjusted array.

#include <Array.au3>
_ArrayAdd ( $avArray, $sValue )

Parameters

$avArray | The array to which the element is to be added.
$sValue | The value to be added.

Return Value

Success: | Returns 1 and the modified array.
Failure: | Returns a 1-element array with the value added to it.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

This function will return an array even if both parameters are empty strings (""). In this case it will return an array with 1-element that contains an empty string value.

Related

_ArrayDelete, _ArrayInsert

Example

#include <Array.au3>
Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"
_ArrayDisplay( $avArray, "Whole array" )
_ArrayAdd( $avArray,"Brian")
_ArrayDisplay( $avArray, "Updated Array" )


Function _ArrayBinarySearch

Function Reference

_ArrayBinarySearch

Uses the binary search algorithm to search through a 1-dimensional array.

#include <Array.au3>
_ArrayBinarySearch ( $avArray, $iKey [, $i_Base=0] )

Parameters

$avArray | The 1-dimensional sorted array to search on.
$iKey | String or number to search for in the array.
$i_Base | Optional: Start Array index for sort, normally set to 0 or 1.

Return Value

Success: | Returns the key (index of where item is in the array).
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.
 | 2 = $iKey is out of bounds.
 | 3 = If the item wasn't found in the array.

Remarks

When doing a binary search on an array of items, the contents MUST be sorted before the search is done. Otherwise undefined results will be returned.

The array is passed to the function by reference and so doesn't use up any additional resources other than a few internal variables.

Related

None.

Example

#include <Array.au3>
Dim $avArray[10]

$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"

; sort the array to be able to do a binary search
_ArraySort( $avArray)

; display sorted array
_ArrayDisplay( $avArray, "sorted" )

; Lookup existing entry
$iKeyIndex = _ArrayBinarySearch ( $avArray, "Jon" )
If Not @error Then
Msgbox(0,'Entry found',' Index:' & $iKeyIndex)
Else
Msgbox(0,'Entry Not found',' Error:' & @error)
EndIf

; Lookup None existing entry
$iKeyIndex = _ArrayBinarySearch ( $avArray, "Unknown" )
If Not @error Then
Msgbox(0,'Entry found',' Index:' & $iKeyIndex)
Else
Msgbox(0,'Entry Not found',' Error:' & @error)
EndIf

;
; Example 2, using an Array returned by StringSplit
;
$avArray = StringSplit("a,b,d,c,e,f,g,h,i",",")

; sort the array to be able to do a binary search
_ArraySort( $avArray, 0, 1)

; display sorted array
_ArrayDisplay( $avArray, "sorted" )

; added 1 as second parameter to skip looking in $avArray[0]
$iKeyIndex = _ArrayBinarySearch ( $avArray, "c",1 )
If Not @error Then
Msgbox(0,'Entry found',' Index:' & $iKeyIndex)
Else
Msgbox(0,'Entry Not found',' Error:' & @error)
EndIf

Exit


Function _ArrayCreate

Function Reference

_ArrayCreate

Create a small array and quickly assign values.

#include <Array.au3>
_ArrayCreate ( $v_Val1, [$v_Val2, [..., $v_Val21]] )

Parameters

$v_Val1 | The first element of the array.
$v_Val2 | Optional: The second element of the array.
. | 0
. | 0
. | 0
$v_Val21 | Optional: The twentyfirst element of the array.

Return Value

The array with values.

Remarks

Arrays up to 21 elements are supported.

Related

Example

#include <Array.au3>

Dim $avArray
$avArray = _ArrayCreate("JPM", "Holger", "Jon", "Larry", "Jeremy", "Valik", "Cyberslug", "Nutster", "Tylo", "JdeB")

_ArrayDisplay( $avArray, "Array created with _ArrayCreate" )

Exit


Function _ArrayDelete

Function Reference

_ArrayDelete

Deletes the specified element from the given array, returning the adjusted array.

#include <Array.au3>
_ArrayDelete ( $avArray, $iElement )

Parameters

$avArray | The array from which an element is to be deleted.
$iElement | The index of the element to be deleted.

Return Value

Success: | Returns 1 and the modified array is stored in the original Array.
Failure: | Returns 0 and the original Array.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.
 | 2 = $avArray has only 1 element in it.

Remarks

If the array passed in has only 1 element, this function returns an empty string.
If the modified array equals the original array, then the original array is returned and @error is set to 2.

Related

_ArrayAdd, _ArrayInsert

Example

#include <Array.au3>

Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"
_ArrayDisplay( $avArray, "Whole array" )
_ArrayDelete( $avArray,8)
_ArrayDisplay( $avArray, "Removed entry 8" )


Function _ArrayDisplay

Function Reference

_ArrayDisplay

Displays a 1-dimensional array in a message box.

#include <Array.au3>
_ArrayDisplay ( $avArray, $sTitle )

Parameters

$avArray | The array to display.
$sTitle | The title of the message box.

Return Value

Success: | Returns 1.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayToClip

Example

; Ex. #1:

#include <Array.au3>

$asControls = StringSplit( WinGetClassList( "", "" ), @LF )
_ArrayDisplay( $asControls, "Class List of Active Window" )
Exit

; Ex. #2:

#include <Array.au3>

Dim $avArray[8]
$avArray[0] = 7
$avArray[1] = "Brian"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Christa"
$avArray[5] = "Rick"
$avArray[6] = "Jack"
$avArray[7] = "Gregory"

_ArrayDisplay( $avArray, "_ArrayDisplay() Test" )
Exit


Function _ArrayInsert

Function Reference

_ArrayInsert

Inserts the a new string at the specified element into an array, returning the adjusted array.

#include <Array.au3>
_ArrayInsert ( $avArray, $iElement[, $sValue] )

Parameters

$avArray | The array from which an element is to be inserted.
$iElement | The index where the element is to be inserted.
$sValue | Optional: Sting to insert at the specified position.

Return Value

Success: | Returns 1 and upadtes the original array.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

Related

_ArrayAdd, _ArrayDelete

Example

#include <Array.au3>

Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"
_ArrayDisplay( $avArray, "Whole array" )
_ArrayInsert( $avArray,4,"New")
_ArrayDisplay( $avArray, "Updated Array" )
Exit


Function _ArrayMax

Function Reference

_ArrayMax

Returns the highest value held in an array.

#include <Array.au3>
_ArrayMax ( $avArray[[, $iCompNumeric], $i_Base] )

Parameters

$avArray | The array to be scanned.
$iCompNumeric | 0 = Alpha numeric compare 1 = Numeric compare
$i_Base | Optional: Start Array index for sort, normally 0 or 1. default = 0

Return Value

Success: | Returns the highest value in the array.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayMaxIndex, _ArrayMin, _ArrayMinIndex

Example

#include <Array.au3>
;
$avArray = StringSplit("4,2,06,8,12,5",",")
;
MsgBox(0,'Max Index String value',_ArrayMaxIndex( $avArray, 0, 1))
MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex( $avArray, 1, 1))
;
MsgBox(0,'Max String value',_ArrayMax( $avArray, 0, 1))
MsgBox(0,'Max Numeric value',_ArrayMax( $avArray, 1, 1))
;
MsgBox(0,'Min Index String value',_ArrayMinIndex( $avArray , 0, 1))
MsgBox(0,'Min Index Numeric value',_ArrayMinIndex( $avArray, 1, 1))
;
MsgBox(0,'Min String value',_ArrayMin( $avArray, 0, 1))
MsgBox(0,'Min Numeric value',_ArrayMin( $avArray, 1, 0))

Exit


Function _ArrayMaxIndex

Function Reference

_ArrayMaxIndex

Returns the index where the highest value occurs in the array.

#include <Array.au3>
_ArrayMaxIndex ( $avArray[[, $iCompNumeric], $i_Base] )

Parameters

$avArray | The array to be scanned.
$iCompNumeric | 0 = Alpha numeric compare 1 = Numeric compare
$i_Base | Optional: Start Array index , normally 0 or 1. default = 0

Return Value

Success: | Returns the index of the highest value in the array.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayMax, _ArrayMin, _ArrayMinIndex

Example

#include <Array.au3>
;
$avArray = StringSplit("4,2,06,8,12,5",",")
;
MsgBox(0,'Max Index String value',_ArrayMaxIndex( $avArray, 0, 1))
MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex( $avArray, 1, 1))
;
MsgBox(0,'Max String value',_ArrayMax( $avArray, 0, 1))
MsgBox(0,'Max Numeric value',_ArrayMax( $avArray, 1, 1))
;
MsgBox(0,'Min Index String value',_ArrayMinIndex( $avArray , 0, 1))
MsgBox(0,'Min Index Numeric value',_ArrayMinIndex( $avArray, 1, 1))
;
MsgBox(0,'Min String value',_ArrayMin( $avArray, 0, 1))
MsgBox(0,'Min Numeric value',_ArrayMin( $avArray, 1, 0))

Exit


Function _ArrayMin

Function Reference

_ArrayMin

Returns the lowest value held in an array.

#include <Array.au3>
_ArrayMin ( $avArray[[, $iCompNumeric], $i_Base] )

Parameters

$avArray | The array to be scanned.
$iCompNumeric | 0 = Alpha numeric compare 1 = Numeric compare
$i_Base | Optional: Start Array index for sort, normally 0 or 1. default = 0

Return Value

Success: | Returns the lowest value in the array.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayMax, _ArrayMaxIndex, _ArrayMinIndex

Example

#include <Array.au3>
;
$avArray = StringSplit("4,2,06,8,12,5",",")
;
MsgBox(0,'Max Index String value',_ArrayMaxIndex( $avArray, 0, 1))
MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex( $avArray, 1, 1))
;
MsgBox(0,'Max String value',_ArrayMax( $avArray, 0, 1))
MsgBox(0,'Max Numeric value',_ArrayMax( $avArray, 1, 1))
;
MsgBox(0,'Min Index String value',_ArrayMinIndex( $avArray , 0, 1))
MsgBox(0,'Min Index Numeric value',_ArrayMinIndex( $avArray, 1, 1))
;
MsgBox(0,'Min String value',_ArrayMin( $avArray, 0, 1))
MsgBox(0,'Min Numeric value',_ArrayMin( $avArray, 1, 0))

Exit


Function _ArrayMinIndex

Function Reference

_ArrayMinIndex

Returns the index where the lowest value occurs in the array.

#include <Array.au3>
_ArrayMinIndex ( $avArray[[, $iCompNumeric], $i_Base] )

Parameters

$avArray | The array to be scanned.
$iCompNumeric | 0 = Alpha numeric compare 1 = Numeric compare
$i_Base | Optional: Start Array index, normally 0 or 1. default = 0

Return Value

Success: | Returns the index of the lowest value in the array.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

None.

Related

_ArrayMax, _ArrayMaxIndex, _ArrayMin

Example

#include <Array.au3>
;
$avArray = StringSplit("4,2,06,8,12,5",",")
;
MsgBox(0,'Max Index String value',_ArrayMaxIndex( $avArray, 0, 1))
MsgBox(0,'Max Index Numeric value',_ArrayMaxIndex( $avArray, 1, 1))
;
MsgBox(0,'Max String value',_ArrayMax( $avArray, 0, 1))
MsgBox(0,'Max Numeric value',_ArrayMax( $avArray, 1, 1))
;
MsgBox(0,'Min Index String value',_ArrayMinIndex( $avArray , 0, 1))
MsgBox(0,'Min Index Numeric value',_ArrayMinIndex( $avArray, 1, 1))
;
MsgBox(0,'Min String value',_ArrayMin( $avArray, 0, 1))
MsgBox(0,'Min Numeric value',_ArrayMin( $avArray, 1, 0))

Exit


Function _ArrayPop

Function Reference

_ArrayPop

Returns the last element of an array, deleting that element from the array at the same time.

#include <Array.au3>
_ArrayPop ( $avArray )

Parameters

$avArray The array to be decreased.

Return Value

Success: | Returns the value of the last element.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

This function changes the array in place by useing the ByRef keyword in the parameter definition of $avArray. So, not only does it return the last element of the array, but it ALSO changes the array to have 1 less element.

Related

Example

#include <Array.au3>

Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "JdeB"
$avArray[9] = "Tylo"

While UBound($avArray) > 0
MsgBox(0,'',_ArrayPop($avArray))
_ArrayDisplay( $avArray, "Entries left in the array" )
WEnd

Exit


Function _ArrayReverse

Function Reference

_ArrayReverse

Takes the given array and reverses the order in which the elements appear in the array.

#include <Array.au3>
_ArrayReverse ( $avArray )

Parameters

$avArray The array to be reversed.

Return Value

Success: | Returns 1 and the updated original array.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.

Remarks

This function returns a COPY of the array with all of the elements reversed. It does NOT overwrite the original array.

Related

_ArraySwap

Example

#include <Array.au3>
Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "Tylo"
$avArray[9] = "JdeB"

_ArrayDisplay( $avArray, "Nomal" )
_ArrayReverse( $avArray)
_ArrayDisplay( $avArray, "Reversed" )

; Example Reverse Array created with StringSplit.
$avArray = StringSplit("0,1,2,3,4,5,6,7,8,9,10,11,12",",")
_ArrayDisplay( $avArray, "Nomal" )
_ArrayReverse( $avArray, 1) ; added the 1 as second parameter
_ArrayDisplay( $avArray, "Reversed" )

Exit


Function _ArraySort

Function Reference

_ArraySort

Sort a mutiple dimensional Array.

#include <Array.au3>
_ArraySort ( ByRef $a_Array, [[[[[$i_Descending], $i_Base=0], $i_Ubound=0], $i_Dim=1], $i_SortIndex=0] )

Parameters

$a_Array | Input Array to be sorted.
$i_Descending | Optional: 1=Sort Descending else Ascending.
$i_Base | Optional: Start Array index for sort, normally set to 0 or 1.
$i_Ubound | Optional: Set the UBound for sorting which will only sort the defined number of entries in stead of the whole array.
$i_Dim | Optional: Number of occurences in the second dimension eg $A[100] = 0, $A[100][2] = 2, $A[100][5] = 5
$i_SortIndex | Optional: The index to Sort on.

Return Value

None.

Remarks

This sort functions can handle 1 or 2 dimention arrays.

Related

Example

#include <Array.au3>

Dim $avArray[10]
$avArray[0] = "JPM"
$avArray[1] = "Holger"
$avArray[2] = "Jon"
$avArray[3] = "Larry"
$avArray[4] = "Jeremy"
$avArray[5] = "Valik"
$avArray[6] = "Cyberslug"
$avArray[7] = "Nutster"
$avArray[8] = "Tylo"
$avArray[9] = "JdeB"

_ArrayDisplay( $avArray, "Unsorted" )
_ArraySort( $avArray)
_ArrayDisplay( $avArray, "Sort Ascending" )
_ArraySort( $avArray,1)
_ArrayDisplay( $avArray, "Sort Decending" )

; Example sort Array created with StringSplit.
$avArray = StringSplit("b,d,c,w,a,e,s,r,x,q",",")
_ArrayDisplay( $avArray, "UnSorted" )
_ArraySort( $avArray,0,1,5) ; sort first 5 entries
_ArrayDisplay( $avArray, "Sort first 5 entries" )
_ArraySort( $avArray,0,1) ; sort and start at 1.. skip array[0]
_ArrayDisplay( $avArray, "Sorted starting at 1" )
_ArraySort( $avArray,1,1) ; sort and start at 1.. skip array[0]
_ArrayDisplay( $avArray, "Sorted Desc starting at 1" )

Exit


Function _ArraySwap

Function Reference

_ArraySwap

Swaps two elements of an array.

#include <Array.au3>
_ArraySwap ( $sVector1, $sVector2 )

Parameters

$sVector1 | First element in the array to be swapped.
$sVector2 | Second element in the array to be swapped.

Return Value

None.

Remarks

This function swaps the 2 elements in place (they're passed by reference) and so don't do any error checking or returning of values.

Related

_ArrayReverse

Example

#include <Array.au3>

Dim $asArray[2]

$asArray[0] = "World!"
$asArray[1] = "Hello"

_ArrayDisplay( $asArray, "_ArraySwap() - BEFORE" )
_ArraySwap( $asArray[0], $asArray[1] )
_ArrayDisplay( $asArray, "_ArraySwap() - AFTER" )
Exit


Function _ArrayToClip

Function Reference

_ArrayToClip

Sends the contents of an array to the clipboard.

#include <Array.au3>
_ArrayToClip ( $avArray, $i_Base = 0)

Parameters

$avArray | The array to be sent to the clipboard.
$i_Base | Optional: Start Array index for sort, normally set to 0 or 1.

Return Value

Success: | Returns 1.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = The clipboard was cleared.

Remarks

None.

Related

_ArrayDisplay, _ArrayToString, StringSplit

Example

#include <Array.au3>
$asArray = StringSplit("a,b,c,d,e,f,g,h,i",",")
$iRetCode = _ArrayToClip( $asArray, 1 )
MsgBox( 4096, "_ArrayToClip() Test", ClipGet() )
Exit


Function _ArrayToString

Function Reference

_ArrayToString

Places the elements of an array into a single string, separated by the specified delimiter.

#include <Array.au3>
_ArrayToString ( $avArray, $sDelim [[, $iStart], $iEnd] )

Parameters

$avArray | The array to be converted into a string.
$iStart | Optional (default to 0): An integer that specifies the element to start at in the array.
$iEnd | Optional (Default to Ubound): An integer that specifies the element to end at in the array.
$sDelim | The delimiter to separate each element with.

Return Value

Success: | Returns a delimited string containing all elements in the array.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = $avArray isn't an array.
 | 2 = $avArray has less than 2 elements or it has more than 1 dimension.
 | 3 = $iStart isn't an integer.
 | 4 = $iStart is < 0.
 | 5 = $iEnd isn't an integer.
 | 6 = $iEnd is < 0.
 | 7 = $sDelim isn't a string
 | 8 = $sDelim is an empty string.
 | 9 = $sDelim has more than one delimiter.

Remarks

This function is the opposite of the StringSplit function with the extension of being able to take a subset of all of the elements and placing just that subset into the string.
Since this function is the inverse of the StringSplit function, the delimiter can't be larger than 1 character in length.

This function only accepts a 1 dimensional array.

If both $iStart and $iEnd = -1, then the entire array will be converted to a string.

Related

_ArrayToClip, _FileReadToArray, StringSplit

Example

#include <Array.au3>

Dim $avArray[11], $I = 0

; Populate test array.
For $I = 0 To UBound($avArray) - 1
$avArray[$I] = Int( Random(-20000, 20000))
Next

_ArrayDisplay($avArray, "_ArrayToString() Test")

Dim $sArrayString = _ArrayToString($avArray, @TAB, 1, 7)
MsgBox(4096, "_ArrayToString() Test", $sArrayString)
Exit


Function _ArrayTrim

Function Reference

_ArrayTrim

Trims all elements in an array a certain number of characters.

#include <Array.au3>
_ArrayTrim( $aArray, $iTrimNum [[[, $iTrimDirection], $iBase], $iUbound] )

Parameters

$aArray | The array to trim the items of.
$iTrimNum | The amount of characters to trim.
$iTrimDirection | Optional: Default=0. 0 to trim left, 1 to trim right
$i_Base | Optional: Start Array index for sort, normally set to 0 or 1.
$i_Ubound | Optional: Set the UBound for sorting which will only sort the defined number of entries in stead of the whole array.

Return Value

0 | If invalid array
1 | Invalid base boundry parameter
2 | Invalid end boundry parameter
3 | If $iTrimDirection is not a zero or a one
 | Otherwise it returns the new trimmed array

Remarks

Related

Example

#include <Array.au3>

Dim $avArray[5]
$avArray[0] = "ab"
$avArray[1] = "bc"
$avArray[2] = "cd"
$avArray[3] = "de"
$avArray[4] = "ef"

$aNewArray = _ArrayTrim( $avArray, 1, 1,1,3)
_ArrayDisplay($aNewArray,"demo _ArrayTrim")
Exit

;The new array in order should now be "a", "b" , "c" , "d", "e".


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Color Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_ColorGetBlue | Returns the blue component of a given color.
_ColorGetGreen | Returns the green component of a given color.
_ColorGetRed | Returns the red component of a given color.


Function _ColorGetBlue

Function Reference

_ColorGetBlue

Returns the blue component of a given color.

#include <Color.au3>
_ColorGetBlue ( $nColor )

Parameters

$nColor The RGB color to work with (hexadecimal code).

Return Value

Success: | Returns the component color in the range 0-255.
Failure: | Returns -1.
@Error: | 0 = No error.
 | 1 = $nColor isn't a number.

Remarks

None.

Related

_ColorGetRed, _ColorGetGreen

Example

#include

$iBlueColor = _ColorGetBlue( 0x8080ff )
MsgBox( 4096, "AutoIt", $iBlueColor )


Function _ColorGetGreen

Function Reference

_ColorGetGreen

Returns the green component of a given color.

#include <Color.au3>
_ColorGetGreen ( $nColor )

Parameters

$nColor The RGB color to work with (hexadecimal code).

Return Value

Success: | Returns the component color in the range 0-255.
Failure: | Returns -1.
@Error: | 0 = No error.
 | 1 = $nColor isn't a number.

Remarks

None.

Related

_ColorGetRed, _ColorGetBlue

Example

#include

$iGreenColor = _ColorGetGreen( 0x8080ff )
MsgBox( 4096, "AutoIt", $iGreenColor )


Function _ColorGetRed

Function Reference

_ColorGetRed

Returns the red component of a given color.

#include <Color.au3>
_ColorGetRed ( $nColor )

Parameters

$nColor The RGB color to work with (hexadecimal code).

Return Value

Success: | Returns the component color in the range 0-255.
Failure: | Returns -1.
@Error: | 0 = No error.
 | 1 = $nColor isn't a number.

Remarks

None.

Related

_ColorGetRed, _ColorGetBlue

Example

#include

$iRedColor = _ColorGetRed( 0x8080ff )
MsgBox( 4096, "AutoIt", $iRedColor )


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Date Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_DateAdd | Calculates a new date based on a given date and add an interval.
_DateDayOfWeek | Returns the name of the weekday, based on the specified day.
_DateDaysInMonth | Returns the number of days in a month, based on the specified month and year.
_DateDiff | Returns the difference between 2 dates, expressed in the type requested.
_DateIsLeapYear | Checks a given year to see if it is a leap year.
_DateIsValid | Checks the given date to determine if it is a valid date.
_DateTimeFormat | Returns the date in the PC's regional settings format.
_DateTimeSplit | Split a string containing Date and Time into two separate Arrays.
_DateToDayOfWeek | Returns the weekdaynumber for a given date.
_DateToDayValue | Returns the daynumber since since noon 4713 BC January 1 for a given Gregorian date.
_DayValueToDate | Add the given days since noon 4713 BC January 1 and returns the Gregorian date.
_Now | Returns the current Date and Time in PC's format.
_NowCalc | Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS for use in date calculations.
_NowCalcDate | Returns the current Date in format YYYY/MM/DD.
_NowDate | Returns the current Date in the Pc's format.
_NowTime | Returns the current Time in format HH:MM:SS.
_TicksToTime | Converts the specified tick amount to hours, minutes, and seconds.
_TimeToTicks | Converts the specified hours, minutes, and seconds to ticks.


Function _DateAdd

Function Reference

_DateAdd

Calculates a new date based on a given date and add an interval.

#include <Date.au3>
_DateAdd ( $sType, $iValToAdd, $sDate )

Parameters

$sType | D = Add number of days to the given date M = Add number of months to the given date Y = Add number of years to the given date w = Add number of Weeks to the given date h = Add number of hours to the given date n = Add number of minutes to the given date s = Add number of seconds to the given date
$iValToAdd | number to be added
$sDate | Input date in the format "YYYY/MM/DD[ HH:MM:SS]"

Return Value

Success: | Newly calculated date.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid $sType
 | 2 = Invalid $iValToAdd
 | 3 = Invalid $sDate

Remarks

The function will not return an invalid date.
e.g When 3 months arte added to '2004/1/31' then the result will be 2004/04/30

Related

_DateDiff

Example

#include <Date.au3>

; Add 5 days to today
$sNewDate = _DateAdd( 'd',5, _NowCalcDate())
MsgBox( 4096, "", "Today + 5 days:" & $sNewDate )

; Subtract 2 weeks from today
$sNewDate = _DateAdd( 'w',-2, _NowCalcDate())
MsgBox( 4096, "", "Today minus 2 weeks: " & $sNewDate )

; Add 15 minutes to current time
$sNewDate = _DateAdd( 'n',15, _NowCalc())
MsgBox( 4096, "", "Current time +15 minutes: " & $sNewDate )

; Calculated eventlogdate which returns second since 1970/01/01 00:00:00
$sNewDate = _DateAdd( 's',1087497645, "1970/01/01 00:00:00")
MsgBox( 4096, "", "Date: " & $sNewDate )


Function _DateDayOfWeek

Function Reference

_DateDayOfWeek

Returns the name of the weekday, based on the specified day.

#include <Date.au3>
_DateDayOfWeek ( $iDayNum [, $iFormat] )

Parameters

$iDayNum | Day number (1 = Sunday, 7 = Saturday).
$iFormat | Optional - Format: 0 = Long name of the weekday. 1 = Abbreviated name of the weekday.

Return Value

Success: | Returns the name of the given weekday.
Failure: | Returns an empty string.
@Error: | 0 = No error.
 | 1 = Invalid day number or format.

Remarks

This function returns English day names only.

Related

_DateDaysInMonth

Example

#include <Date.au3>

; Retrieve the long name
$sLongDayName = _DateDayOfWeek( @WDAY )

; Retrieve the abbreviated name
$sShortDayName = _DateDayOfWeek( @WDAY, 1 )

MsgBox( 4096, "Day of Week", "Today is: " & $sLongDayName & " (" & $sShortDayName & ")" )


Function _DateDaysInMonth

Function Reference

_DateDaysInMonth

Returns the number of days in a month, based on the specified month and year.

#include <Date.au3>
_DateDaysInMonth ( $iYear, $iMonthNum )

Parameters

$iYear | 4-digit year.
$iMonthNum | Month number (1 = January, 12 = December).

Return Value

Success: | Returns the number of days in the month.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = Invalid month number or year.

Remarks

None.

Related

None.

Example

#include <Date.au3>

$iDays = _DateDaysInMonth( @MON, @YEAR )
MsgBox( 4096, "Days in Month", "This month has " & String( $iDays ) & " days in it." )


Function _DateDiff

Function Reference

_DateDiff

Returns the difference between 2 dates, expressed in the type requested.

#include <Date.au3>
_DateDiff($sType, $sStartDate, $sEndDate)

Parameters

$sType | D = Difference in days between the given dates M = Difference in months between the given dates Y = Difference in years between the given dates w = Difference in Weeks between the given dates h = Difference in hours between the given dates n = Difference in minutes between the given dates s = Difference in seconds between the given dates
$sStartDate | Input date in the format "YYYY/MM/DD[ HH:MM:SS]"
$sEndDate | Input End date in the format "YYYY/MM/DD[ HH:MM:SS]"

Return Value

Success: | Difference between the 2 dates.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid $sType
 | 2 = Invalid $sStartDate
 | 3 = Invalid $sEndDate

Remarks

Related

_DateAdd

Example

#include <Date.au3>

; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00)
$iDateCalc = _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of seconds since EPOCH: " & $iDateCalc )

; Calculated the number of Hours this year
$iDateCalc = _DateDiff( 'h',@YEAR & "/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of Hours this year: " & $iDateCalc )


Function _DateIsLeapYear

Function Reference

_DateIsLeapYear

Checks a given year to see if it is a leap year.

#include <Date.au3>
_DateIsLeapYear ( $iYear )

Parameters

$iYear The 4-digit year to check.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if the year is not a leap year.
@Error: | 0 = No error.
 | 1 = Invalid year.

Remarks

None.

Related

None.

Example

#include <Date.au3>

If _DateIsLeapYear( @YEAR ) Then
MsgBox( 4096, "Leap Year", "This year is a leap year." )
Else
MsgBox( 4096, "Leap Year", "This year is not a leap year." )
EndIf


Function _DateIsValid

Function Reference

_DateIsValid

Checks the given date to determine if it is a valid date.

#include <Date.au3>
_DateIsValid ( $sDate )

Parameters

$sDate The date to be checked.

Return Value

Success: | Returns 1.
Failure: | Returns 0 if the specified date is not valid.
@Error: | 0 = No error.
 | 1 = Invalid date format.
 | 2 = Badly formed month.
 | 3 = Badly formed day.
 | 4 = Badly formed year.
 | 5 = Month is out of range.
 | 6 = Day is out of range.
 | 7 = Year is out of range.
 | 8 = Not a leap year.

Remarks

This function takes a date input in one of the following formats:

m/d/yy, m/d/yyyy, mm/dd/yy, mm/dd/yyyy
d.m.yy, d.m.yyyy, dd.mm.yy, dd.mm.yyyy
m_d_yy, m_d_yyyy, mm_dd_yy, mm_dd_yyyy
yy-m-d, yyyy-m-d, yy-mm-dd, yyyy-mm-dd

The function recognizes the date format used automatically from the delimiter character used in the given date string.
If the given date is invalid, the function will return a -1 and set @error to a positive number depending on how the specified date was invalid.
If the given year is only 2-digits long, the function assumes that it will be in the 2000-2099 range. For all other date ranges, a 4-digit year must be specified.

The function works for all dates between 1753 and 2999 (before this there was another calender - Gregorian vs. Julian).

Related

None.

Example

#include <Date.au3>

$sDate = @MON & "/" & @MDAY & "/" & @YEAR

If _DateIsValid( $sDate ) Then
MsgBox( 4096, "Valid Date", "The specified date is valid." )
Else
MsgBox( 4096, "Valid Date", "The specified date is invalid." )
EndIf


Function _DateTimeFormat

Function Reference

_DateTimeFormat

Returns the date in the PC's regional settings format.

#Include <date.au3>
_DateTimeFormat ( $sDate, $sType)

Parameters

$sDate | Input date in the format "YYYY/MM/DD[ HH:MM:SS]"
$sType | 0 = Display a date and/or time. If there is a date part, display it as a short date. If there is a time part, display it as a long time. If present, both parts are displayed. 1 = Display a date using the long date format specified in your computer's regional settings. 2 = Display a date using the short date format specified in your computer's regional settings. 3 = Display a time using the time format specified in your computer's regional settings. 4 = Display a time using the 24-hour format (hh:mm).
$iValToAdd | number to be added

Return Value

Success: | Returns date in proper format.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid $sDate
 | 2 = Invalid $sType

Remarks

Related

Example

#include <Date.au3>

; Show current date/time in the pc's format
MsgBox( 4096, "Pc Long format", _DateTimeFormat( _NowCalc(),1))
MsgBox( 4096, "Pc Short format", _DateTimeFormat( _NowCalc(),2))


Function _DateToDayValue

Function Reference

_DateToDayValue

Split a string containing Date and Time into two separate Arrays.

#include <date.au3>
_DateTimeSplit($sDate, ByRef $asDatePart, ByRef $iTimePart)

Parameters

$sDate | Any of these formats: "yyyy/mm/dd[ hh:mm[:ss]]" "yyyy/mm/dd[Thh:mm[:ss]]" "yyyy-mm-dd[ hh:mm[:ss]]" "yyyy-mm-dd[Thh:mm[:ss]]" "yyyy.mm.dd[ hh:mm[:ss]]" "yyyy.mm.dd[Thh:mm[:ss]]"
$asDatePart | array that contains the Date. $asDatePart[0] number of values returned
$asTimePart | array that contains the Time. $asTimePart[0] number of values returned

Return Value

Success: | Date and Time into two separate Arrays.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid Input Date

Remarks

Related

_DayValueToDate, _DateAdd, _DateDiff

Example

#include <Date.au3>

Dim $MyDate
Dim $MyTime
_DateTimeSplit("2005/01/01 14:30",$MyDate,$MyTime)

For $x = 1 to $MyDate[0]
MsgBox(0,$x,$MyDate[$x])
Next
For $x = 1 to $MyTime[0]
MsgBox(0,$x,$MyTime[$x])
Next


Function _DateToDayOfWeek

Function Reference

_DateToDayOfWeek

Returns the weekdaynumber for a given date.

#include <date.au3>
_DateToDayOfWeek ( $iYear, $iMonth, $iDay )

Parameters

$iYear | A valid year in format YYYY
$iMonth | A valid month in format MM
$iDay | A valid day in format DD

Return Value

Success: | Returns Day of the Week Range is 1 to 7 where 1=Sunday.
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid Input Date

Remarks

Related

_DateDayOfWeek, _DayValueToDate, _DateAdd, _DateDiff

Example

#include <Date.au3>

; Week day number for a given date
$iWeekday = _DateToDayOfWeek (@YEAR, @MON, @MDAY)
: Should be equal to @Wday
MsgBox(4096, "", "Todays WeekdayNumber is: " & $iWeekDay)
MsgBox(4096, "", "Today is a : " & _DateDayOfWeek(iWeekDay))


Function _DateToDayValue

Function Reference

_DateToDayValue

Returns the daynumber since since noon 4713 BC January 1 for a given Gregorian date.

#include <date.au3>
_DateToDayValue ( $iYear, $iMonth, $iDay )

Parameters

$iYear | A valid year in format YYYY
$iMonth | A valid month in format MM
$iDay | A valid day in format DD

Return Value

Success: | Returns the Juliandate (days since noon 4713 BC January 1)
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid Input Date

Remarks

Related

_DayValueToDate, _DateAdd, _DateDiff

Example

#include <Date.au3>

; Julian date of today.
$sJulDate = _DateToDayValue (@YEAR, @MON, @MDAY)
MsgBox(4096, "", "Todays Julian date is: " & $sJulDate)

; 14 days ago calculation.
Dim $Y, $M, $D
$sJulDate = _DayValueToDate ($sJulDate-14, $Y, $M, $D)
MsgBox(4096, "", "14 days ago:" & $M & "/" & $D & "/" & $Y)


Function _DayValueToDate

Function Reference

_DayValueToDate

Add the given days since noon 4713 BC January 1 and returns the Gregorian date.

#include <Date.au3>
_DateToDayValue ($iJulianDate, ByRef $iYear, ByRef $iMonth, ByRef $iDay)

Parameters

$iJulianDate | A valid number of days.
$iYear | will return the year in format YYYY
$iMonth | will return the month in format MM
$iDay | will return the day in format DD

Return Value

Success: | Returns the date calculate
Failure: | 0
@Error: | 0 = No error.
 | 1 = Invalid Input number of days

Remarks

Related

_DateToDayValue, _DateAdd, _DateDiff

Example

#include <Date.au3>

; Julian date of today.
$sJulDate = _DateToDayValue (@YEAR, @MON, @MDAY)
MsgBox(4096, "", "Todays Julian date is: " & $sJulDate)

; 14 days ago calculation.
Dim $Y, $M, $D
$sJulDate = _DayValueToDate ($sJulDate-14, $Y, $M, $D)
MsgBox(4096, "", "14 days ago:" & $M & "/" & $D & "/" & $Y & " (" & $sJulDate & ")")


Function _Now

Function Reference

_Now

Returns the current Date and Time in PC's format.

#Include <date.au3>
_Now()

Parameters

None.

Return Value

Remarks

Related

Example

#include <Date.au3>

MsgBox( 4096, "", "Todays date/Time: " & _Now() )


Function _NowCalc

Function Reference

_NowCalc

Returns the current Date and Time in format YYYY/MM/DD HH:MM:SS for use in date calculations.

#Include <date.au3>
_NowCalc()

Parameters

None.

Return Value

Remarks

Related

Example

#include <Date.au3>

; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00)
$iDateCalc = _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of seconds since EPOCH: " & $iDateCalc )

; Calculated the number of Hours this year
$iDateCalc = _DateDiff( 'h',@YEAR & "/01/01 00:00:00",_NowCalc())
MsgBox( 4096, "", "Number of Hours this year: " & $iDateCalc )


Function _NowCalcDate

Function Reference

_NowCalcDate

Returns the current Date in format YYYY/MM/DD.

#Include <date.au3>
_NowCalcDate()

Parameters

None.

Return Value

Remarks

Related

Example

#include <Date.au3>
$Msg = "Test record"
FileWriteLine("Pgm.log",_NowCalcDate() & " :" & $Msg )


Function _NowDate

Function Reference

_NowDate

Returns the current Date in the Pc's format.

#Include <date.au3>
_NowDate()

Parameters

None.

Return Value

Remarks

Related

Example

#include <Date.au3>
MsgBox(0,'',"The Date is:" & _NowDate())


Function _NowTime

Function Reference

_NowTime

Returns the current Time in format HH:MM:SS.

#Include <date.au3>
_NowTime()

Parameters

None.

Return Value

Remarks

Related

Example

#include <Date.au3>
MsgBox(0,'',"The time is:" & _NowTime())


Function _TicksToTime

Function Reference

_TicksToTime

Converts the specified tick amount to hours, minutes, and seconds.

#Include <date.au3>
_TicksToTime ( $iTicks, $iHours, $iMins, $iSecs )

Parameters

$iTicks | Tick amount.
$iHours | Variable to store the hours.
$iMins | Variable to store the minutes.
$iSecs | Variable to store the seconds.

Return Value

Success: | Returns 1.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $iTicks isn't an integer.

Remarks

None.

Related

_TimeToTicks

Example


Function _TimeToTicks

Function Reference

_TimeToTicks

Converts the specified hours, minutes, and seconds to ticks.

#include <Date.au3>
_TimeToTicks ( $iHours, $iMins, $iSecs )

Parameters

$iHours | The hours.
$iMins | The minutes.
$iSecs | The seconds.

Return Value

Success: | Returns 1.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = The specified hours, minutes, or seconds are not valid.

Remarks

None.

Related

_TicksToTime

Example

#include <Date.au3>
Global $Sec, $Min, $Hour, $Time
; calculate with time
$StartTicks = _TimeToTicks(@HOUR,@MIN,@SEC)
; calculate 45 minutes later
$EndTicks = $StartTicks + 45 * 60 * 1000
_TicksToTime($EndTicks,$Hour,$Min,$Sec)
MsgBox(262144,'' , 'New Time:' & $Hour & ":" & $Min & ":" & $Sec)


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: File Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_FileCountLines | Returns the number of lines in the specified file.
_FileCreate | Creates or zero's out the length of the file specified.
_FileReadToArray | Reads the specified file into an array.
_FileWriteLog | Writes current date,time and the specified text to a log file.
_TempFile | Generate a name for a temporary file. The file is guaranteed not to already exist in the user's %TEMP% directory.


Function _FileCountLines

Function Reference

_FileCountLines

Returns the number of lines in the specified file.

#include <file.au3>
_FileCountLines( $sFilePath )

Parameters

$sFilePath Path and filename of the file to be read

Return Value

Success: | Returns number of lines in the file.
Failure: | Returns a 0
@Error: | 0 = No error.
 | 1 = File cannot be opened or found.

Remarks

It does not count a final @LF as a line.

Related

Example

#include
$CountLines = _FileCountLines("error.log")
MsgBox(64, "Error log recordcount", "There are " & $CountLines & " in the error.log.")
Exit


Function _FileCreate

Function Reference

_FileCreate

Creates or zero's out the length of the file specified.

#include <file.au3>
_FileCreate ( $sFilePath )

Parameters

$sFilePath Path and filename of the file to be created.

Return Value

Success: | Returns a 1
Failure: | Returns a 0
@Error: | 0 = No error.
 | 1 = Error opening specified file
 | 2 = File could not be written to

Remarks

Related

..\Functions\FileOpen

Example

#include
If Not _FileCreate("error.log") Then
MsgBox(4096,"Error", " Error Creating/Resetting log. error:" & @error)
EndIf


Function _FileReadToArray

Function Reference

_FileReadToArray

Reads the specified file into an array.

#include <file.au3>
_FileReadToArray($sFilePath, ByRef $aArray)

Parameters

$sFilePath | Path and filename of the file to be read.
$aArray | The array to store the contents of the file.

Return Value

Success: | Returns a 1
Failure: | Returns a 0
@Error: | 0 = No error.
 | 1 = Error opening specified file
 | 2 = File could not be written to

Remarks

Related

Example

#include <file.au3>
Dim $aRecords
If Not _FileReadToArray("error.log",$aRecords) Then
MsgBox(4096,"Error", " Error reading log to Array error:" & @error)
Exit
EndIf
For $x = 1 to $aRecords[0]
Msgbox(0,'Record:' & $x, $aRecords[$x])
Next


Function _FileWriteLog

Function Reference

_FileWriteLog

Writes current date,time and the specified text to a log file.

#include <file.au3>
_FileWriteLog( $sLogPath, $sLogMsg )

Parameters

$sFilePath | Path and filename of the file to be written to
$sLogMsg | Message to be written to the log file

Return Value

Success: | Returns a 1
Failure: | Returns a 0
@Error: | 0 = No error.
 | 1 = Error opening specified file
 | 2 = File could not be written to

Remarks

Related

FileOpen

Example

#include <file.au3>
;
_FileWriteLog(@ScriptDir & "\my.log","Text 1")
;
_FileWriteLog(@ScriptDir & "\my.log","Text 2")


Function _TempFile

Function Reference

_TempFile

Generate a name for a temporary file. The file is guaranteed not to already exist in the user's %TEMP% directory.

#include <File.au3>
_TempFile()

Parameters

No parameters.

Return Value

Filename of a temporary file which does not exist.

Remarks

None.

Related

Example

#include <File.au3>

Dim $s_TempFile
$s_TempFile = _TempFile()

MsgBox(4096, "Name suitable for new temporary file", $s_TempFile)

Exit


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Inet Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_GetIP | Get public IP address of a network/computer.
_INetExplorerCapable | Converts a string to IE(Internet Explorer) capable line
_INetMail | Opens default user's mail client with given address, subject, and body.


Function _GetIP

Function Reference

_GetIP

Get public IP address of a network/computer.

#include <inet.au3>
_GetIP()

Parameters

None.

Return Value

None.

Remarks

This only returns the Public IP address of a computer or network. Do not forget to set a the return value to a variable.

Related

Example

#include <Inet.au3>
$PublicIP = _GetIP()
MsgBox(0, "IP Address", "Your IP Address is: " & $PublicIP)


Function _INetExplorerCapable

Function Reference

_INetExplorerCapable

Converts a string to IE(Internet Explorer) capable line

#include <INet.au3>
_INetExplorerCapable ( $s_IEString )

Parameters

$s_IEString String to be converted

Return Value

Success: Converted string
Failure: Blank string and @error = 1

Remarks

This converts IE uncapable characters to '%' and their hex value

Related

Example

#include <INet.au3>

MsgBox(0, "", _INetExplorerCapable(InputBox("", "Enter a string to convert into browser readable text")))


Function _INetMail

Function Reference

_INetMail

Opens default user's mail client with given address, subject, and body.

#include <INet.au3>
_INetMail ( $s_MailTo, $s_MailSubject, $s_MailBody )

Parameters

$s_MailTo | Address for the E-Mail
$s_MailSubject | Subject for the E-Mail
$s_MailBody | Body for the E-Mail

Return Value

Success: Process identifier for the E-Mail client
Failure: See remarks.

Remarks

If this fails to find the correct mail client the script will depend on the status of Opt('RunErrorsFatal', *)
Failure and Opt('RunErrorsFatal',1) will crash script
Failure and Opt('RunErrorsFatal',0) will return blank string and @error = 1

It is recomended before using this function to set Opt('RunErrorsFatal', 0)!

Related

Example

#include <INet.au3>

$Address = InputBox('Address', 'Enter the E-Mail address to send message to')
$Subject = InputBox('Subject', 'Enter a subject for the E-Mail')
$Body = InputBox('Body', 'Enter the body (message) of the E-Mail')
MsgBox(0,'E-Mail has been opened','The E-Mail has been opened and process identifier for the E-Mail client is ' & _INetMail($address, $subject, $body))


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Math Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_Ceil | Returns the smallest integer greater than or equal to the specified value.
_Floor | Returns the greatest integer less than or equal to the specified value.
_MathCheckDiv | Checks if NumA is divisable by NumB
_Max | Evaluates which of the two numbers is higher.
_Min | Evaluates which of the two numbers is lower.


Function _Ceil

Function Reference

_Ceil

Returns the smallest integer greater than or equal to the specified value.

#include <math.au3>
_Ceil ( $nValue )

Parameters

$nValue Any valid numeric expression.

Return Value

Success: | Returns the smallest integer greater than or equal to the specified value.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $nValue isn't a number.

Remarks

None.

Related

_Floor

Example

#include <Math.au3>

$x = _Ceil(5.25) ; returns 6


Function _Floor

Function Reference

_Floor

Returns the greatest integer less than or equal to the specified value.

#include <math.au3>
_Floor ( $nValue )

Parameters

$nValue Any valid numeric expression.

Return Value

Success: | Returns the greatest integer less than or equal to the specified value.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $nValue isn't a number.

Remarks

None.

Related

_Ceil

Example

#include <Math.au3>

$x = _Floor(5.25) ; returns 5


Function _MathCheckDiv

Function Reference

_MathCheckDiv

Checks if NumA is divisable by NumB

#include <math.au3>
_MathCheckDiv ( $i_NumA, $i_NumB )

Parameters

$i_NumA | Number to check
$i_NumB | Number to divide by

Return Value

1 for not divisable
2 for divisable
-1 and @error = 1 if not valid numbers

Remarks

This function will also enable checking if a number is even/odd by making the second parameter = 2

Related

Example

#include <math.au3>
$I_Var = InputBox('Odd or Even', 'Enter a number:')
$I_Result = _MathCheckDiv($I_Var, 2)
If $I_Result = -1 Or @error = 1 Then
MsgBox(0,'','You did not enter a valid number')
ElseIf $I_Result = 1 Then
MsgBox(0,'','Number is odd')
ElseIf $I_Result = 2 Then
MsgBox(0,'','Number is even')
Else
MsgBox(0,'','Could not parse $I_Result')
EndIf


Function _Max

Function Reference

_Max

Evaluates which of the two numbers is higher.

#include <math.au3>
_Max ( $nNum1, $nNum2 )

Parameters

$nNum1 | First number.
$nNum2 | Second number.

Return Value

Success: | Returns the higher of the two numbers.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $nNum1 isn't a number.
 | 2 = $nNum2 isn't a number.

Remarks

This function works with floats as well as integers.

Related

_Min

Example

#include <Math.au3>

$x = _Max(25, 10) ; returns 25


Function _Min

Function Reference

_Min

Evaluates which of the two numbers is lower.

#include <math.au3>
_Min ( $nNum1, $nNum2 )

Parameters

$nNum1 | First number.
$nNum2 | Second number.

Return Value

Success: | Returns the lower of the two numbers.
Failure: | Returns 0.
@Error: | 0 = No error.
 | 1 = $nNum1 isn't a number.
 | 2 = $nNum2 isn't a number.

Remarks

This function works with floats as well as integers.

Related

_Max

Example

#include <Math.au3>

$x = _Min(25, 10) ; returns 10


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Misc Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_Iif | Perform a boolean test within an expression.


Function _Iif

Function Reference

_Iif

Perform a boolean test within an expression.

#include <Misc.au3>
_Iif ( $f_Test, $v_TrueVal, $v_FalseVal )

Parameters

$f_Test | Boolean test.
$v_TrueVal | Value to return if $f_Test is true.
$v_FalseVal | Value to return if $f_Test is false.

Return Value

One of $v_TrueVal or $v_FalseVal.

Remarks

Note that all parameters are evaluated, even though only one is returned.

Related

Example

#include <Misc.au3>

Dim $i_Count, $i_Index

For $i_Index = 1 To 2
MsgBox(4096, "Count", "This dialog has displayed " & String($i_Index) & _
" time" & _Iif($i_Index > 1, "s", "") & " so far")
Next

Exit


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Process Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_RunDOS | Executes a DOS command in a hidden command window.


Function _RunDos

Function Reference

_RunDos

Executes a DOS command in a hidden command window.

#Include <process.au3>
_RunDOS( $sCommand )

Parameters

$sCommand Command to execute

Return Value

Remarks

Related

Example

#include <Process.au3>
$rc = _RunDos("start Http://www.autoitscript.com")


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: String Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_HexToString | Convert a hex string to a string.
_StringEncrypt | An RC4 based string encryption function.
_StringProper | Changes a string to proper case, same a =Proper function in Excel
_StringRepeat | Repeats a string a specified number of times.
_StringReverse | Reverses the contents of the specified string.
_StringToHex | Convert a string to a hex string.


Function _HexToString

Function Reference

_HexToString

Convert a hex string to a string.

#include <string.au3>
_HexToString("hex")

Parameters

$strHex

Return Value

Returns string upon success. Returns -1 and sets @error to 1 upon failure.

Remarks

Related

_StringToHex

Example

#include <string.au3>
$String = "I like AutoIt3"
$Hex = _StringToHex($String)
MsgBox(0, "Hex", "Original String: " & $String & @LF & " Hex: " & $Hex)

$Hex = "49206C696B65204175746F497433"
$String = _HexToString($Hex)
MsgBox(0, "Hex", "Original Hex: " & $Hex & @LF & " String: " & $String)


Function _StringEncrypt

Function Reference

_StringEncrypt

An RC4 based string encryption function.

#include <string.au3>
_StringEncrypt ( $i_Encrypt, $s_EncryptText, $s_EncryptPassword [, $i_EncryptLevel ] )

Parameters

$i_Encrypt | 1 to encrypt, 0 to decrypt.
$s_EncryptText | Text to encrypt/decrypt.
$s_EncryptPassword | Password to encrypt/decrypt with.
$i_EncryptLevel | Optional: Level to encrypt/decrypt. Default = 1

Return Value

Success: The Encrypted/Decrypted string.
Failure: Blank string and @error = 1

Remarks

WARNING: This function has an extreme timespan if the encryption level or encrypted string are too large!

Related

Example

#include <guiconstants.au3>
#include <string.au3>
; GUI and String stuff
$WinMain = GuiCreate('Encryption tool', 400, 400)
; Creates window
$EditText = GuiCtrlCreateEdit('',5,5,380,350)
; Creates main edit
$InputPass = GuiCtrlCreateInput('',5,360,100,20, 0x21)
; Creates the password box with blured/centered input
$InputLevel = GuiCtrlCreateInput(1, 110, 360, 50, 20, 0x2001)
$UpDownLevel = GUICtrlSetLimit(GuiCtrlCreateUpDown($inputlevel),10,1)
; These two make the level input with the Up|Down ability
$EncryptButton = GuiCtrlCreateButton('Encrypt', 170, 360, 105, 35)
; Encryption button
$DecryptButton = GuiCtrlCreateButton('Decrypt', 285, 360, 105, 35)
; Decryption button
GUICtrlCreateLabel('Password', 5, 385)
GuiCtrlCreateLabel('Level',110,385)
; Simple text labels so you know what is what
GuiSetState()
; Shows window

Do
$Msg = GuiGetMsg()
If $msg = $EncryptButton Then
GuiSetState(@SW_DISABLE,$WinMain) ; Stops you from changing anything
$string = GuiCtrlRead($EditText) ; Saves the editbox for later
GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.') ; Friendly message
GuiCtrlSetData($EditText,_StringEncrypt(1,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel)))
; Calls the encryption. Sets the data of editbox with the encrypted string
; The encryption starts with 1/0 to tell it to encrypt/decrypt
; The encryption then has the string that we saved for later from edit box
; It then reads the password box & Reads the level box
GuiSetState(@SW_ENABLE,$WinMain) ; This turns the window back on
EndIf
If $msg = $DecryptButton Then
GuiSetState(@SW_DISABLE,$WinMain) ; Stops you from changing anything
$string = GuiCtrlRead($EditText) ; Saves the editbox for later
GUICtrlSetData($EditText,'Please wait while the text is Encrypted/Decrypted.') ; Friendly message
GuiCtrlSetData($EditText,_StringEncrypt(0,$string,GuiCtrlRead($InputPass),GuiCtrlRead($InputLevel)))
; Calls the encryption. Sets the data of editbox with the encrypted string
; The encryption starts with 1/0 to tell it to encrypt/decrypt
; The encryption then has the string that we saved for later from edit box
; It then reads the password box & Reads the level box
GuiSetState(@SW_ENABLE,$WinMain) ; This turns the window back on
EndIf
Until $msg = $GUI_EVENT_CLOSE ; Continue loop untill window is closed


Function _StringProper

Function Reference

_StringProper

Changes a string to proper case, same a =Proper function in Excel

#Include <string.au3>
_StringProper ( $sString )

Parameters

$sString Input string

Return Value

Success: | Returns proper string.
Failure: | Returns "".
@Error: | NA

Remarks

This function will capitalize every character following a None Apha character.

Related

Example

#include <String.au3>
;Will return : Somebody Lastnames
Msgbox(0,'',_StringProper("somebody lastnames"))
;Will return : Some.Body Last(Name)
Msgbox(0,'',_StringProper("SOME.BODY LAST(NAME)"))
Exit


Function _StringRepeat

Function Reference

_StringRepeat

Repeats a string a specified number of times.

#Include <string.au3>
_StringRepeat( $sString, $iRepeatCount )

Parameters

$sString | String to repeat
$iRepeatCount | Number of times to repeat the string

Return Value

Success: | Returns string with specified number of repeats
Failure: | Returns an empty string and sets @error = 1
@Error: | 0 = No error.
 | 1 = One of the parameters is invalid

Remarks

Related

Example

#include <String.au3>

Msgbox(0,'',_StringRepeat("+-",40))
Exit


Function _StringReverse

Function Reference

_StringReverse

Reverses the contents of the specified string.

#Include <string.au3>
_StringReverse( $sString )

Parameters

$sString String to reverse

Return Value

@Error: | 0 = No error.
 | 1 = One of the parameters is invalid

Remarks

Related

Example

#include <String.au3>
Msgbox(0,'',_StringReverse("esreveR"))
Exit


Function _StringToHex

Function Reference

_StringToHex

Convert a string to a hex string.

#include <string.au3>
_StringToHex("string")

Parameters

$strChar

Return Value

Returns hex string upon success. Returns -1 and sets @error to 1 upon failure.

Remarks

Related

_HexToString

Example

#include <string.au3>
$String = "I like AutoIt3"
$Hex = _StringToHex($String)
MsgBox(0, "Hex", "Original String: " & $String & @LF & " Hex: " & $Hex)

$Hex = "49206C696B65204175746F497433"
$String = _HexToString($Hex)
MsgBox(0, "Hex", "Original Hex: " & $Hex & @LF & " String: " & $String)


User Defined Functions

User Defined Function Reference

Below is a list of the user defined functions for catagory: Visa Management.
Click on a user defined function name for a detailed description.

User Defined Function | Description
_viClose | Closes a VISA connection to an Instrument/Device
_viExecCommand | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viFindGpib | Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)
_viGpibBusReset | GPIB BUS "reset": Use this function when the GPIB BUS gets stuck for some reason. You might be lucky and resolve the problem by calling this function
_viGTL | Go To Local mode: Instruments that accept this command will exit the "Remote Control mode" and go to "Local mode". If the instrument is already in "Local mode" this is simply ignored. Normally, if an instrument does not support this command it will simply stay in the "Remote Control mode"
_viOpen | Opens a VISA connection to an Instrument/Device
_viSetAttribute | Set any VISA attribute This function, which is called by _viSetTimeout, can ALSO be used to set the other VISA specific attributes. Read the VISA documentation for more information and a list of VISA attributes and their corresponding values.
_viSetTimeout | Sets the VISA timeout in MILISECONDS


Function _viOpen

Function Reference

_viOpen

Closes a VISA connection to an Instrument/Device

#include <Visa.au3>
_viClose($h_session)

Parameters

$h_session A VISA session handle (as returned by _viOpen)

Return Value

On Success - Returns 0
On Failure - Returns -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide)
This function always sets @error to 1 in case of error

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

Related

_viClose, _viExecCommand

Example

;- This assumes that you have instrument set to GPIB address 1
; It shows how to use the _viExecCommand function in stand alone mode and combined
; with _viOpen and _viClose.
; It also shows the _viGTL function

#include <Visa.au3>

Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Open the instrument connection with _viOpen")
Dim $h_instr = _viOpen("GPIB::3::0")
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument

MsgBox(0,"Step 2","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox(0,"Step 3","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 4","Close the instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


Function _viExecCommand

Function Reference

_viExecCommand

Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)

#include <Visa.au3>
_viExecCommand($h_session, $s_command, $i_timeout_ms = -1)

Parameters

$h_session A VISA descriptor (STRING) OR a VISA session handle (INTEGER)
This it can be a string or an integer (a handle):
* STRING -> A VISA DESCRIPTOR is a string which specifies the resource with
which to establish a communication session.
An example descriptor is "GPIB::20::0".
This function supports all valid VISA descriptors, including GPIB, TCP, VXI
and Serial Interface instruments (ASRL).
A detailed explanation of VISA descriptors is shown in the Remarks section
of this function.
As a SHORTCUT you can also use a STRING containing the address number
(e.g. "20") of a GPIB instrument instead of typing the full descriptor
(in that case, "GPIB::20::0")
* INTEGER -> A VISA session handle is an integer value returned by _viOpen.
It is recommended that instead you use _viOpen and VISA session handles
instead of descriptors if you plan to communicate repeteadly with an
Instrument or Device, as otherwise each time that you contact the instrument
you would incur the overhead of opening and closing the communication link.
Once you are done using the instrument you must remember to close the link
with _viClose.
$s_command Command/Query to execute (e.g. "*IDN?" or "SOURCE:POWER -20 dBM")
A query MUST contain a QUESTION MARK (?)
When the command is a QUERY the function will automatically wait for the
instrument's answer (or until the operation times out)
$i_timeout_ms Optional: The operation timeout in MILISECONDS.
This is mostly important for QUERIES only.
This is an OPTIONAL PARAMETER.
If it is not specified the last set timeout will be used. If it was never set
before the default timeout (which depends on the VISA implementation) will be used.
Timeouts can also be set separatelly with the _viSetTimeout function.
Depending on the bus type (GPIB, TCP, etc) the timeout might not be set to the
exact value that you request. Instead the closest valid timeout bigger than
the one that you requested will be used.

Return Value

The return value depends on whether the command is a QUERY
or not and in whether the operation was successful or not.
* Command, NON QUERY:
On Success - Returns ZERO
On Failure - Returns -1 if the VISA DLL could not be open
or a NON ZERO value representing the VISA
error code (see the VISA programmer's guide)
* QUERY:
On Success - Returns the answer of the instrument to the QUERY
On Failure - Returns -1 if the VISA DLL could not be open
Returns -3 if the VISA DLL returned an unexpected
number of results
or returns a NON ZERO value representing the VISA
error code (see the VISA programmer's guide)
This function always sets @error to 1 in case of error

Remarks

* The VISA queries only return the 1st line of the device answer
This is not a problem in most cases, as most devices will always
answer with a single line.

* The following is a description of the MOST COMMON VISA DESCRIPTORS
Note that there are some more types. For more info please
refer to a VISA programmer's guide (available at www.ni.com)
Optional segments are shown in square brackets ([]).
Required segments that must be filled in are denoted by angle
brackets (<>).

Interface Syntax
------------------------------------------------------------
GPIB INSTR GPIB[board]::primary address
[::secondary address] [::INSTR]
GPIB INTFC GPIB[board]::INTFC
TCPIP SOCKET TCPIP[board]::host address::port::SOCKET
Serial INSTR ASRL[board][::INSTR]
PXI INSTR PXI[board]::device[::function][::INSTR]
VXI INSTR VXI[board]::VXI logical address[::INSTR]
GPIB-VXI INSTR GPIB-VXI[board]::VXI logical address[::INSTR]
TCPIP INSTR TCPIP[board]::host address[::LAN device name]
[::INSTR]

The GPIB keyword is used for GPIB instruments.
The TCPIP keyword is used for TCP/IP communication.
The ASRL keyword is used for serial instruments.
The PXI keyword is used for PXI instruments.
The VXI keyword is used for VXI instruments via either embedded
or MXIbus controllers.
The GPIB-VXI keyword is used for VXI instruments via a GPIB-VXI
controller.

The default values for optional parameters are shown below.

Optional Segment Default Value
---------------------------------------
board 0
secondary address none
LAN device name inst0

Example Resource Strings:
--------------------------------------------------------------
GPIB::1::0::INSTR A GPIB device at primary address 1 and
secondary address 0 in GPIB interface 0.

GPIB2::INTFC Interface or raw resource for GPIB
interface 2.

TCPIP0::1.2.3.4::999::SOCKET Raw TCP/IP access to port 999
at the specified IP address.

ASRL1::INSTR A serial device attached to interface
ASRL1. VXI::MEMACC Board-level register
access to the VXI interface.

PXI::15::INSTR PXI device number 15 on bus 0.

VXI0::1::INSTR A VXI device at logical address 1 in VXI
interface VXI0.

GPIB-VXI::9::INSTR A VXI device at logical address 9 in a
GPIB-VXI controlled system.

Related

_viFindGpib, _viOpen, _viClose, _viSetTimeout, _viGTL, _viGpibBusReset

Example

;- This assumes that you have instrument set to GPIB address 3
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viExecCommand function in stand alone mode and combined
; with _viOpen and _viClose.
; It also shows the _viGTL function

#include <Visa.au3>

Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Simple GPIB query using a VISA Descriptor")
Dim $s_answer = _viExecCommand("GPIB::3::0","*IDN?",10000) ; 10 secs timeout
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 2","Go to LOCAL using VISA Descriptor")
_viGTL("GPIB::1::0") ; Go to local (exit remote control mode)

MsgBox(0,"Step 3","Simple GPIB query using a VISA address shortcut")
$s_answer = _viExecCommand("1","*IDN?") ; The address MUST BE A STRING
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
MsgBox(0,"Info","Now let's use _viOpen and _viClose")

MsgBox(0,"Step 4","Open the instrument connection with _viOpen")
Dim $h_instr = _viOpen(3)
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument

MsgBox(0,"Step 5","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox(0,"Step 6","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 7","Go to LOCAL using VISA instrument handle")
_viGTL($h_instr); Go to local (this is optional)

MsgBox(0,"Step 8","Close the Instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


Function _viFindGpib

Function Reference

_viFindGpib

Send a Command/Query to an Instrument/Device through the VISA interface (GPIB / TCP)

#include <Visa.au3>
_viFindGpib(ByRef $a_descriptor_list, ByRef $a_idn_list, $f_show_search_results = 0)

Parameters

$a_descriptor_list (ByRef) | RETURNS an array of the VISA resource descriptors of the instruments that were found in the GPIB bus (see the Remarks of the _viExecCommand for more info)
$a_idn_list (ByRef) | RETURNS an array of the IDNs (i.e names) of the instruments that were found in the GPIB bus
$f_show_search_results | Optional: If 1 a message box showing the results of the search will be shown. The default is 0, which means that the results are not shown

Return Value

On Success - The number of instruments found (0 or more)
On Failure - Returns a NEGATIVE value and SETS @error to 1

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand function

Related

_viExecCommand, _viOpen, _viClose, _viGTL, _viGpibControlREN

Example

; This example performs a search on the GPIB bus and shows the results in a MsgBox

#include <Visa.au3>

Dim $a_descriptor_list[1], $a_idn_list[1]
_viFindGpib($a_descriptor_list, $a_idn_list, 1)


Function _viGpibBusReset

Function Reference

_viGpibBusReset

GPIB BUS "reset": Use this function when the GPIB BUS gets stuck for some reason. You might be lucky and resolve the problem by calling this function

#include <Visa.au3>
_viGpibBusReset()

Parameters

None

Return Value

On Success - Returns 0
On Failure - Returns -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide)
This function always sets @error to 1 in case of error

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

Related

_viGTL, _viExecCommand, _viFindGpib, _viOpen, _viClose

Example

; This example tries to "reset" the GPIB bus after a BUS "lock". This is rare,
; but it might happen if one of the instruments connected to the BUS has crashed

#include <Visa.au3>

_viGpibBusReset()


Function _viGTL

Function Reference

_viGTL

Go To Local mode: Instruments that accept this command will exit the "Remote Control mode" and go to "Local mode". If the instrument is already in "Local mode" this is simply ignored. Normally, if an instrument does not support this command it will simply stay in the "Remote Control mode"

#include <Visa.au3>
_viGTL($h_session)

Parameters

$h_session A VISA descriptor (STRING) OR a VISA session handle (INTEGER).
See the Remarks of the _viExecCommand for more info.

Return Value

On Success - Returns 0
On Failure - Returns -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide)
This function always sets @error to 1 in case of error

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand function

Related

_viExecCommand, _viGpibBusReset, _viFindGpib, _viOpen, _viClose

Example

;- This assumes that you have instrument set to GPIB address 3
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viGTL function with a VISA descriptor and with a
; VISA device handler. We use _viExecCommand first to force the instrument to go
; into "Remote mode"

#include <Visa.au3>

Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Simple GPIB query using a VISA Descriptor")
Dim $s_answer = _viExecCommand("GPIB::3::0","*IDN?",10)
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 2","Go to LOCAL using VISA Descriptor")
_viGTL("GPIB::1::0") ; Go to local (exit remote control mode)

MsgBox(0,"Step 4","Open the instrument connection with _viOpen")
Dim $h_instr = _viOpen(3)
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument

MsgBox(0,"Step 5","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox(0,"Step 6","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 7","Go to LOCAL using VISA instrument handle")
_viGTL($h_instr); Go to local (this is optional)

MsgBox(0,"Step 8","Close the Instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


Function _viOpen

Function Reference

_viOpen

Opens a VISA connection to an Instrument/Device

#include <Visa.au3>
_viOpen($s_visa_address, $s_visa_secondary_address = 0)

Parameters

$s_visa_address | A VISA resource descriptor STRING (see the NOTES of _viExecCommand above for more info) As as shortcut you can also directly pass a GPIB address as an integer
$s_visa_secondary_address | Optional: The "secondary GPIB address". Only used if the primary address is passed as an integer. Only some GPIB instruments have secondary addresses. In those cases this optional parameter can be used to specify it. This parameter is ZERO by default, which means NO SECONDARY ADDRESS

Return Value

On Success - Returns a (POSITIVE) VISA Instrument Handle
On Failure - Returns -1 and SETS @error to 1

Remarks

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand function

Related

_viClose, _viExecCommand

Example

;- This assumes that you have instrument set to GPIB address 1
; It shows how to use the _viExecCommand function in stand alone mode and combined
; with _viOpen and _viClose.
; It also shows the _viGTL function
#include <Visa.au3>
Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Open the instrument connection with _viOpen")
Dim $h_instr = _viOpen("GPIB::3::0")
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument

MsgBox(0,"Step 2","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox(0,"Step 3","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 4","Close the instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection

MsgBox(0,"Step 5","Open the Instrument connection using only the address number")
Dim $h_instr = _viOpen(3)
MsgBox(0,"Instrument Handle obtained", "$h_instr = " & $h_instr) ; Show the Session Handle
; Query the instrument

MsgBox(0,"Step 6","Query the instrument using the VISA instrument handle")
$s_answer = _viExecCommand($h_instr,"*IDN?") ; $h_instr is NOT A STRING now!
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer
; Query again. There is no need to OPEN the link again

MsgBox(0,"Step 7","Query again. There is no need to OPEN the link again")
$s_answer = _viExecCommand($h_instr,"*IDN?")
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 8","Close the instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


Function _viSetAttribute

Function Reference

_viSetAttribute

Set any VISA attribute This function, which is called by _viSetTimeout, can ALSO be used to set the other VISA specific attributes. Read the VISA documentation for more information and a list of VISA attributes and their corresponding values.

#include <Visa.au3>
_viSetAttribute($h_session, $i_attribute, $i_value)

Parameters

$h_session | A VISA descriptor (STRING) OR a VISA session handle (INTEGER). See the Remarks of the _viExecCommand for more info.
$i_attribute | The index of the attribute that must be changed. Attributes are defined in the VISA library. This AutoIt library only defines a CONSTANT for the TIMEOUT attribute ($VI_ATTR_TMO_VALUE) and for the Serial Interface attributes and values (see the remarks) but you can pass any other valid index (as an integer) if you want to.
$i_value | The value of the attribute. It must be an integer and the possible values depend on the attribute type and are defined in the VISA documentation.

Return Value

On Success - Returns 0
On Failure - Returns -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide)
This function always sets @error to 1 in case of error

Remarks

This is a list of the currently pre-defined attributes and values. Remember that you can use any other valid attribute/value by passing the corresponding integer index (as defined in the VISA programmer's guide) to this function.

* Attribute: $VI_ATTR_TMO_VALUE -> Set Timeout
* Values:
A timeout in MILLISECONDS or
$VI_TMO_IMMEDIATE (or 0) for "Return immediatly"
VI_TMO_INFINITE (or "INF") for "No timeout"

* Attribute: $VI_ATTR_ASRL_BAUD
* Values:
Any valid baudrate (9600, 115200, etc)

* Attribute: $VI_ATTR_ASRL_DATA_BITS
* Values:
From 5 to 8

* Attribute: $VI_ATTR_ASRL_PARITY
* Values:
$VI_ASRL_PAR_NONE
$VI_ASRL_PAR_ODD
$VI_ASRL_PAR_EVEN
$VI_ASRL_PAR_MARK
$VI_ASRL_PAR_SPACE

* Attribute: $VI_ATTR_ASRL_STOP_BITS
* Values:
$VI_ASRL_STOP_ONE
$VI_ASRL_STOP_ONE5
$VI_ASRL_STOP_TWO

* Attribute: $VI_ATTR_ASRL_FLOW_CNTRL
* Values:
$VI_ASRL_FLOW_NONE
$VI_ASRL_FLOW_XON_XOFF
$VI_ASRL_FLOW_RTS_CTS
$VI_ASRL_FLOW_DTR_DSR

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32).
You onlly need a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) if you use the GPIB related functions.

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand function

Related

_viSetTimeout, _viExecCommand, _viOpen, _viClose

Example

;- This assumes that you have instrument set to GPIB address 3.
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viSetAttribute. In this example we use _viSetAttribute
; instead of _viSetTimeout to set the GPIB timeout of a _viExecCommand operation.

#include <Visa.au3>

Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Simple GPIB query with explicit TIMEOUT set")
Dim $s_answer = _viExecCommand("GPIB::3::0","*IDN?",10000) ; 10 secs timeout
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

; This is the same as using the _viSetAttribute function first:
MsgBox(0,"Step 2","_vOpen + timeout using _viSetAttribute + GPIB query")
Dim $h_instr = _viOpen(3)
; NOTE - This is the same as: _viSetTimeout($h_instr, 10000)
_viSetAttribute($h_instr, $VI_ATTR_TMO_VALUE, 10000) ; 10000 ms = 10 secs

$s_answer = _viExecCommand($h_instr,"*IDN?") ; No need to set the timeout now
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 3","Close the Instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


Function _viSetTimeout

Function Reference

_viSetTimeout

Sets the VISA timeout in MILISECONDS

#include <Visa.au3>
_viSetTimeout($h_session, $i_timeout_ms)

Parameters

$h_session | A VISA descriptor (STRING) OR a VISA session handle (INTEGER). See the Remarks of the _viExecCommand for more info.
$i_timeout_ms | The timeout IN MILISECONDS for VISA operations (mainly for GPIB queries) If you set it to 0 the tiemouts are DISABLED. If you set it to "INF" the VISA operations will NEVER timeout. Be careful with this as it could easly hung your program ifv your instrument does not respond to one of your queries. Depending on the bus type (GPIB, TCP, etc) the timeout might not be set to the exact value that you request. Instead the closest valid timeout bigger than the one that you requested will be used.

Return Value

On Success - Returns 0
On Failure - Returns -1 if the VISA DLL could not be open or a NON ZERO value representing the VISA error code (see the VISA programmer's guide)
This function always sets @error to 1 in case of error

Remarks

Most of the time it is not necessary to call this function, as _viExecCommand has a third OPTIONAL parameter $i_timeout_ms which can also be used to set the VISA timeout.

As for all the VISA functions the VISA libraries must be installed (you can check whether visa32.dll is in {WINDOWS}\system32) and a GPIB card (such as a National Instruments NI PCI-GPIB card or an Agilent 82350B PCI High-Performance GPIB card) must be installed

* For a detailed description of the most common VISA DESCRIPTORS look at the Remarks of the help on the _viExecCommand function

Related

_viSetAttribute, _viExecCommand, _viOpen, _viClose

Example

;- This assumes that you have instrument set to GPIB address 3.
; If you have an instrument in a different address change "GPIB::3::0" to the
; corresponding descriptor. Do the same for the call to _viOpen
; It shows how to use the _viExecCommand function with a timeout or how to
; call _viSetTimeout instead.

#include <Visa.au3>

Dim $h_session = 0

; Query the ID of the instrument in GPIB address 3
MsgBox(0,"Step 1","Simple GPIB query with explicit TIMEOUT set")
Dim $s_answer = _viExecCommand("GPIB::3::0","*IDN?",10000) ; 10 secs timeout
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

; This is the same as using the _viSetTimeout function first:
MsgBox(0,"Step 2","_vOpen + timeout using _viSetTimeout + GPIB query")
Dim $h_instr = _viOpen(3)
_viSetTimeout($h_instr, 10000) ; 10000 ms = 10 secs
$s_answer = _viExecCommand($h_instr,"*IDN?") ; No need to set the timeout now
MsgBox(0,"GPIB QUERY result",$s_answer) ; Show the answer

MsgBox(0,"Step 3","Close the Instrument connection using _viClose")
_viClose($h_instr) ; Close the instrument connection


1.0.04 (19 February, 2005)
    - Fixed _ArrayMaxIndex() and _ArrayMinIndex() to set to proper initial value.
    - Fixed _ArraySort() issue with only 2 entries not being sorted.
    - Fixed documentation and example for _ArrayToString()
    - Fixed VISA.au3 from Peppe.

1.0.03 (6 February. 2005)
    *** Updated all documentation to follow the standard used in the helpfile.

    Array.au3:
    - Updated many Array Function with optional parameters like $iBase.(See helpfile for detail)
    - Updated a couple of Function to make use of the new Redim function.
    - Added: _ArraySort()
    - Added: _ArrayTrim()
    - Added: _ArrayCreate()

    Date.au3:
    - Added: _DateAdd, _DateDiff, _DateToDayValue, _DayValueToDate,
             _DateTimeFormat, _DayOfWeek, _DateIsValid,
             _Now(), Nowcalc(), Nowcalcdate(), _NowTime(),
             _NowDate(),_DaysInMonth()_DaysOfWeek()

    File.au3:
    - Removed: _DirRemoveContents , obsolete, replaced by FileDelete() internal command.
    - Removed: _FileAppend , obsolete, replaced by FileWriteLine("Filename",) internal command.
    - Updated: _FileCountLines with a faster version created by Tylo.
    - Added:   _TempFile()

    Inet.au3
    - Added: _INetExplorerCapable, _INetMail, _GetIp

    Math.au3:
    - Added:   _Ceil, _Floor, _MathCheckDiv, _MathCheckDiv

    Misc.au3:
    - Added:  _Iif()

    Process.au3:
    - Updated: _RunDos because the default quotes gave problems in Win9x.

    String.au3:
    - Added:  _StringProper(), _StringEncrypt(), _StringToHex(), HexToString()

   Visa.au3:
    - Added:  _viExecCommand,_viOpen, _viClose, _viFindGpib, _viSetTimeout,
              _viSetAttribute, _viGTL, _viGpibBusReset

1.0.02 (27th Feb. 2004)
    - Added: _FileCountLines(), _DirRemoveContents()
    - Added: _DateDaysInMonth()
    - Added: _DateIsValidMonthNum(), _DateIsValidWeekdayNum(), _DateIsValidYear()
    - Added: _TimeIsValidHour(), _TimeIsValidMinute(), _TimeIsValidSecond()
    - Added: Usage syntax now included for documentation
    - Added: Documentation updates
    - Changed: _FileReadToArray() so it executes faster
    - Changed: (Internal) Enhanced the way the date/time functions operate
    - Changed: (Internal) File functions now use new file read/write syntax
    - Fixed: _RunDOS() to support executing DOS commands with spaces in the command

1.0.01 (5th Feb. 2004)
    - Added: _ColorGetRed(), _ColorGetGreen(), _ColorGetBlue()
    - Added: _RunDOS()
    - Fixed: _TicksToTime() and _TimeToTicks()

1.0.00 (21st Jan. 2004)
    - Initial release


Language Reference

Appendix Reference

  • Ascii Characters
  • CLSIDs of Special Folders
  • GUI Control Styles
  • Splash... Fonts
  • OsLang Values
  • Send Key List


ASCII Characters

ASCII Character Codes

This list is helpful with the Asc and Chr functions. Taken from ASCII Character Set

Control Characters (mostly non-printing; most useful of these are highlighted in yellow.)

Char... | Dec | Hex | Description
NUL | 0 | 00 | Null character
SOH | 1 | 01 | Start of heading, = console interrupt
STX | 2 | 02 | Start of text, maintenance mode on HP console
ETX | 3 | 03 | End of text
EOT | 4 | 04 | End of transmission, not the same as ETB
ENQ | 5 | 05 | Enquiry, goes with ACK; old HP flow control
ACK | 6 | 06 | Acknowledge, clears ENQ logon hand
BEL | 7 | 07 | Bell, rings the bell... (Plays Windows' default beep)
BS | 8 | 08 | Backspace, works on HP terminals/computers
HT | 9 | 09 | Horizontal tab, move to next tab stop
LF | 10 | 0a | Line Feed
VT | 11 | 0b | Vertical tab
FF | 12 | 0c | Form Feed, page eject
CR | 13 | 0d | Carriage Return
SO | 14 | 0e | Shift Out, alternate character set
SI | 15 | 0f | Shift In, resume default character set
DLE | 16 | 10 | Data link escape
DC1 | 17 | 11 | XON, with XOFF to pause listings; ":okay to send".
DC2 | 18 | 12 | Device control 2, block-mode flow control
DC3 | 19 | 13 | XOFF, with XON is TERM=18 flow control
DC4 | 20 | 14 | Device control 4
NAK | 21 | 15 | Negative acknowledge
SYN | 22 | 16 | Synchronous idle
ETB | 23 | 17 | End transmission block, not the same as EOT
CAN | 24 | 17 | Cancel line, MPE echoes !!!
EM | 25 | 19 | End of medium, Control-Y interrupt
SUB | 26 | 1a | Substitute
ESC | 27 | 1b | Escape, next character is not echoed
FS | 28 | 1c | File separator
GS | 29 | 1d | Group separator
RS | 30 | 1e | Record separator, block-mode terminator
US | 31 | 1f | Unit separator

Printing Characters (standard characters)

Char | Dec | Hex | Description
 | 32 | 20 | Space
! | 33 | 21 | Exclamation mark
" | 34 | 22 | Quotation mark (&quot; in HTML)
# | 35 | 23 | Cross hatch (number sign)
$ | 36 | 24 | Dollar sign
% | 37 | 25 | Percent sign
& | 38 | 26 | Ampersand
` | 39 | 27 | Closing single quote (apostrophe)
( | 40 | 28 | Opening parentheses
) | 41 | 29 | Closing parentheses
* | 42 | 2a | Asterisk (star, multiply)
+ | 43 | 2b | Plus
, | 44 | 2c | Comma
- | 45 | 2d | Hyphen, dash, minus
. | 46 | 2e | Period
/ | 47 | 2f | Slant (forward slash, divide)
0 | 48 | 30 | Zero
1 | 49 | 31 | One
2 | 50 | 32 | Two
3 | 51 | 33 | Three
4 | 52 | 34 | Four
5 | 53 | 35 | Five
6 | 54 | 36 | Six
7 | 55 | 37 | Seven
8 | 56 | 38 | Eight
9 | 57 | 39 | Nine
: | 58 | 3a | Colon
; | 59 | 3b | Semicolon
< | 60 | 3c | Less than sign
= | 61 | 3d | Equals sign
> | 62 | 3e | Greater than sign
? | 63 | 3f | Question mark
@ | 64 | 40 | At-sign
A | 65 | 41 | Uppercase A
B | 66 | 42 | Uppercase B
C | 67 | 43 | Uppercase C
D | 68 | 44 | Uppercase D
E | 69 | 45 | Uppercase E
F | 70 | 46 | Uppercase F
G | 71 | 47 | Uppercase G
H | 72 | 48 | Uppercase H
I | 73 | 49 | Uppercase I
J | 74 | 4a | Uppercase J
K | 75 | 4b | Uppercase K
L | 76 | 4c | Uppercase L
M | 77 | 4d | Uppercase M
N | 78 | 4e | Uppercase N
O | 79 | 4f | Uppercase O
P | 80 | 50 | Uppercase P
Q | 81 | 51 | Uppercase Q
R | 82 | 52 | Uppercase R
S | 83 | 53 | Uppercase S
T | 84 | 54 | Uppercase T
U | 85 | 55 | Uppercase U
V | 86 | 56 | Uppercase V
W | 87 | 57 | Uppercase W
X | 88 | 58 | Uppercase X
Y | 89 | 59 | Uppercase Y
Z | 90 | 5a | Uppercase Z
[ | 91 | 5b | Opening square bracket
\ | 92 | 5c | Reverse slant (Backslash)
] | 93 | 5d | Closing square bracket
^ | 94 | 5e | Caret (Circumflex)
_ | 95 | 5f | Underscore
` | 96 | 60 | Opening single quote
a | 97 | 61 | Lowercase a
b | 98 | 62 | Lowercase b
c | 99 | 63 | Lowercase c
d | 100 | 64 | Lowercase d
e | 101 | 65 | Lowercase e
f | 102 | 66 | Lowercase f
g | 103 | 67 | Lowercase g
h | 104 | 68 | Lowercase h
i | 105 | 69 | Lowercase i
j | 106 | 6a | Lowercase j
k | 107 | 6b | Lowercase k
l | 108 | 6c | Lowercase l
m | 109 | 6d | Lowercase m
n | 110 | 6e | Lowercase n
o | 111 | 6f | Lowercase o
p | 112 | 70 | Lowercase p
q | 113 | 71 | Lowercase q
r | 114 | 72 | Lowercase r
s | 115 | 73 | Lowercase s
t | 116 | 74 | Lowercase t
u | 117 | 75 | Lowercase u
v | 118 | 76 | Lowercase v
w | 119 | 77 | Lowercase w
x | 120 | 78 | Lowercase x
y | 121 | 79 | Lowercase y
z | 122 | 7a | Lowercase z
{ | 123 | 7b | Opening curly brace
| | 124 | 7c | Vertical line
} | 125 | 7d | Closing curly brace
~ | 126 | 7e | Tilde (approximate)
 | 127 | 7f | Delete (rubout), cross-hatch box

Extended Character Set (ANSI)

Char | Dec | Hex | Description
€ | 128 | 80 |
 | 129 | 81 | Note: does not display in this compiled html help file
‚ | 130 | 82 |
ƒ | 131 | 83 |
„ | 132 | 84 |
… | 133 | 85 |
† | 134 | 86 |
‡ | 135 | 87 |
ˆ | 136 | 88 |
‰ | 137 | 89 |
Š | 138 | 8A |
‹ | 139 | 8B |
Œ | 140 | 8C |
 | 141 | 8D | Note: does not display in this compiled html help file
Ž | 142 | 8E |
 | 143 | 8F | Note: does not display in this compiled html help file
� | 144 | 90 | Note: does not display in this compiled html help file
‘ | 145 | 91 |
’ | 146 | 92 |
“ | 147 | 93 |
” | 148 | 94 |
• | 149 | 95 |
– | 150 | 96 |
— | 151 | 97 |
˜ | 152 | 98 |
™ | 153 | 99 |
š | 154 | 9A |
› | 155 | 9B |
œ | 156 | 9C |
 | 157 | 9D | Note: does not display in this compiled html help file
ž | 158 | 9E |
Ÿ | 159 | 9F |
 | 160 | A0 |
¡ | 161 | A1 |
¢ | 162 | A2 |
£ | 163 | A3 |
¤ | 164 | A4 |
¥ | 165 | A5 |
¦ | 166 | A6 |
§ | 167 | A7 |
¨ | 168 | A8 |
© | 169 | A9 |
ª | 170 | AA |
« | 171 | AB |
¬ | 172 | AC |
 | 173 | AD | Note: may not display in this compiled html help file
® | 174 | AE |
¯ | 175 | AF |
° | 176 | B0 |
± | 177 | B1 |
² | 178 | B2 |
³ | 179 | B3 |
´ | 180 | B4 |
µ | 181 | B5 |
¶ | 182 | B6 |
· | 183 | B7 |
¸ | 184 | B8 |
¹ | 185 | B9 |
º | 186 | BA |
» | 187 | BB |
¼ | 188 | BC |
½ | 189 | BD |
¾ | 190 | BE |
¿ | 191 | BF |
À | 192 | C0 |
Á | 193 | C1 |
Â | 194 | C2 |
Ã | 195 | C3 |
Ä | 196 | C4 |
Å | 197 | C5 |
Æ | 198 | C6 |
Ç | 199 | C7 |
È | 200 | C8 |
É | 201 | C9 |
Ê | 202 | CA |
Ë | 203 | CB |
Ì | 204 | CC |
Í | 205 | CD |
Î | 206 | CE |
Ï | 207 | CF |
Ð | 208 | D0 |
Ñ | 209 | D1 |
Ò | 210 | D2 |
Ó | 211 | D3 |
Ô | 212 | D4 |
Õ | 213 | D5 |
Ö | 214 | D6 |
× | 215 | D7 |
Ø | 216 | D8 |
Ù | 217 | D9 |
Ú | 218 | DA |
Û | 219 | DB |
Ü | 220 | DC |
Ý | 221 | DD |
Þ | 222 | DE |
ß | 223 | DF |
à | 224 | E0 |
á | 225 | E1 |
â | 226 | E2 |
ã | 227 | E3 |
ä | 228 | E4 |
å | 229 | E5 |
æ | 230 | E6 |
ç | 231 | E7 |
è | 232 | E8 |
é | 233 | E9 |
ê | 234 | EA |
ë | 235 | EB |
ì | 236 | EC |
í | 237 | ED |
î | 238 | EE |
ï | 239 | EF |
ð | 240 | F0 |
ñ | 241 | F1 |
ò | 242 | F2 |
ó | 243 | F3 |
ô | 244 | F4 |
õ | 245 | F5 |
ö | 246 | F6 |
÷ | 247 | F7 |
ø | 248 | F8 |
ù | 249 | F9 |
ú | 250 | FA |
û | 251 | FB |
ü | 252 | FC |
ý | 253 | FD |
þ | 254 | FE |
ÿ | 255 | FF |


CLSID List

For use with FileOpenDialog, FileSaveDialog, or FileSelectFolder

List taken from Online Security > Windows Tips & Tricks

Note: Not all values may work as parameters to the AutoIt functions listed above.

Example: FileSelectFolder ("Choose a folder.", "::{00000000-1080-F9E5-6311-4162E05A6BEE}", 1)

Folder | Value for the File___'s directory parameter
Administrative Tools | "::{D20EA4E1-3957-11d2-A40B-0C5020524153}"
Briefcase | "::{85BBD92O-42A0-1O69-A2E4-08002B30309D}"
Control Panel | "::{21EC2O2O-3AEA-1O69-A2DD-08002b30309d}"
Fonts | "::{D20EA4E1-3957-11d2-A40B-0C5020524152}"
History | "::{FF393560-C2A7-11CF-BFF4-444553540000}"
Inbox | "::{00020D75-0000-0000-C000-000000000046}"
Microsoft Network | "::{00028B00-0000-0000-C000-000000000046}"
My Computer | "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
My Documents | "::{450D8FBA-AD25-11D0-98A8-0800361B1103}"
My Network Places | "::{208D2C60-3AEA-1069-A2D7-08002B30309D}"
Network Computers | "::{1f4de370-d627-11d1-ba4f-00a0c91eedba}"
Network Connections | "::{7007ACC7-3202-11D1-AAD2-00805FC1270E}"
Printers and Faxes | "::{2227A280-3AEA-1069-A2DE-08002B30309D}"
Programs Folder | "::{7be9d83c-a729-4d97-b5a7-1b7313c39e0a}"
Recycle Bin | "::{645FF040-5081-101B-9F08-00AA002F954E}"
Scanners and Cameras | "::{E211B736-43FD-11D1-9EFB-0000F8757FCD}"
Scheduled Tasks | "::{D6277990-4C6A-11CF-8D87-00AA0060F5BF}"
Start Menu Folder | "::{48e7caab-b918-4e58-a94d-505519c795dc}"
Temporary Internet Files | "::{7BD29E00-76C1-11CF-9DD0-00A0C9034933}"
Web Folders | "::{BDEADF00-C265-11d0-BCED-00A0C90AB50F}"


Standard Windows Fonts

GUI Control Styles

This page contains a list of the common and extended styles that can be used with windows, and also specific styles that can be used with controls. These styles are used in the "style" and/or "exStyle" parameters of many of the GUI functions. To use these values you must #include <GUIConstants.au3> into your script.

Note: The "Value" is given just for reference, you should always use the "name" of the style in order to keep your scripts readable.

Common Styles | Value | Description
Default/forced for GUI creation |  | see GUICreate function.
$WS_BORDER | 0x00800000 | Creates a window that has a thin-line border.
$WS_POPUP | 0x80000000 | Creates a pop-up window. This style cannot be used with the WS_CHILD style.
$WS_CAPTION | 0x00C00000 | Creates a window that has a title bar (includes the WS_BORDER style)
$WS_CLIPCHILDREN | 0x02000000 | Excludes the area occupied by child windows when drawing occurs within the parent window. This style is used when creating the parent window.
$WS_CLIPSIBLINGS | 0x04000000 | Clips child windows relative to each other; that is, when a particular child window receives a WM_PAINT message, the WS_CLIPSIBLINGS style clips all other overlapping child windows out of the region of the child window to be updated. If WS_CLIPSIBLINGS is not specified and child windows overlap, it is possible, when drawing within the client area of a child window, to draw within the client area of a neighboring child window.
$WS_DISABLED | 0x08000000 | Creates a window that is initially disabled.
$WS_DLGFRAME | 0x00400000 | Creates a window that has a border of a style typically used with dialog boxes.
$WS_HSCROLL | 0x00100000 | Creates a window that has a horizontal scroll bar.
$WS_MAXIMIZE | 0x01000000 | Creates a window that is initially maximized.
$WS_MAXIMIZEBOX | 0x00010000 | Creates a window that has a maximize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified.
$WS_MINIMIZE | 0x20000000 | Creates a window that is initially minimized.
$WS_MINIMIZEBOX | 0x00020000 | Creates a window that has a minimize button. Cannot be combined with the WS_EX_CONTEXTHELP style. The WS_SYSMENU style must also be specified.
$WS_OVERLAPPED | 0x00000000 | Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_TILED style
$WS_OVERLAPPEDWINDOW | 0x00CF0000 | Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_TILEDWINDOW style.
$WS_POPUPWINDOW | 0x80880000 | Creates a pop-up window with WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION and WS_POPUPWINDOW styles must be combined to make the window menu visible.
$WS_SIZEBOX | 0x00040000 | Creates a window that has a sizing border. Same as the WS_THICKFRAME style.
$WS_SYSMENU | 0x00080000 | Creates a window that has a window menu on its title bar. The WS_CAPTION style must also be specified.
$WS_THICKFRAME | 0x00040000 | Creates a window that has a sizing border. Same as the WS_SIZEBOX style
$WS_VSCROLL | 0x00200000 | Creates a window that has a vertical scroll bar.
$WS_VISIBLE | 0x10000000 | Creates a window that is initially visible.
$WS_CHILD | 0x40000000 | Creates a child window. A window with this style cannot have a menu bar. This style cannot be used with the WS_POPUP style.
$WS_GROUP | 0x00020000 | Specifies the first control of a group of controls. The group consists of this first control and all controls defined after it, up to the next control with the WS_GROUP style.
$WS_TABSTOP | 0x00010000 | Turns the control into a tab stop, which enables the user to select the control by tabbing through the controls in a dialog box.
$DS_MODALFRAME | 0x00000080 | Creates a dialog box with a modal dialog-box frame that can be combined with a title bar and window menu by specifying the WS_CAPTION and WS_SYSMENU styles.
$DS_SETFOREGROUND | 0x00000200 | This style is useful for modal dialog boxes that require immediate attention from the user regardless of whether the owner window is the foreground window.
$DS_CONTEXTHELP | 0x00002000 | Includes a question mark in the title bar of the dialog box. Cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX styles. Same as WS_EX_CONTEXTHELP extended style.

Common Extended Styles | Value | Description
$WS_EX_ACCEPTFILES | 0x00000010 | Allow an edit or input control within the created GUI window to receive filenames via drag and drop. The control must have also the $GUI_ACCEPTFILES state set by GUICtrlSetState.
$WS_EX_APPWINDOW | 0x00040000 | Forces a top-level window onto the taskbar when the window is visible.
$WS_EX_CLIENTEDGE | 0x00000200 | Specifies that a window has a border with a sunken edge.
$WS_EX_CONTEXTHELP | 0x00000400 | Includes a question mark in the title bar of the window. Cannot be used with the WS_MAXIMIZEBOX or WS_MINIMIZEBOX
$WS_EX_DLGMODALFRAME | 0x00000001 | Creates a window that has a double border; the window can, optionally, be created with a title bar by specifying the WS_CAPTION style in the dwStyle parameter.
$WS_EX_OVERLAPPEDWINDOW | 0x00000300 | Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles.
$WS_EX_STATICEDGE | 0x00020000 | Creates a window with a three-dimensional border style intended to be used for items that do not accept user input.
$WS_EX_TOPMOST | 0x00000008 | Specifies that a window created with this style should be placed above all non-topmost windows and should stay above them, even when the window is deactivated.
$WS_EX_TRANSPARENT | 0x00000020 | The window appears transparent because the bits of underlying sibling windows have already been painted.
$WS_EX_TOOLWINDOW | 0x00000080 | Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog box that appears when the user presses ALT+TAB. If a tool window has a system menu, its icon is not displayed on the title bar. However, you can display the system menu by typing ALT+SPACE.
$WS_EX_WINDOWEDGE | 0x00000100 | Specifies that a window has a border with a raised edge.
$WS_EX_LAYERED | 0x00080000 | Creates a layered window. Note that this cannot be used for child windows.
$LVS_EX_FULLROWSELECT | 0x00000020 | When an item is selected, the item and all its subitems are highlighted.

Checkbox Styles | Value | Description
Default/forced |  | See GUICtrlCreateCheckbox function.
$BS_3STATE | 0x0005 | Creates a check box in which the box can be unavailable as well as selected or cleared. Use the unavailable state to show that the state of the check box is not determined.
$BS_AUTO3STATE | 0x0006 | Creates a three-state check box in which the state cycles through selected, unavailable, and cleared each time the user selects the check box.
$BS_AUTOCHECKBOX | 0x0003 | Creates a check box in which the check state switches between selected and cleared each time the user selects the check box.
$BS_CHECKBOX | 0x0002 | Creates a small, empty check box with a label displayed to the right of it. To display the text to the left of the check box, combine this flag with the BS_RIGHTBUTTON style.
$BS_LEFT | 0x0100 | Left-aligns the text in the button rectangle on the right side of the check box.
$BS_PUSHLIKE | 0x1000 | Makes a button (such as a check box, three-state check box, or radio button) look and act like a push button. The button looks raised when it isn't pushed or checked, and sunken when it is pushed or checked.
$BS_RIGHT | 0x0200 | Right-aligns text in the button rectangle on the right side of the check box.
$BS_RIGHTBUTTON | 0x0020 | Positions a check box square on the right side of the button rectangle.

Push Button Styles | Value | Description
Default/forced |  | See GUICtrlCreateButton, GUICtrlCreateCheckbox, GUICtrlCreateRadio functions.
$BS_BOTTOM | 0x0800 | Places the text at the bottom of the button rectangle.
$BS_CENTER | 0x0300 | Centers the text horizontally in the button rectangle.
$BS_DEFPUSHBUTTON | 0x0001 | Creates a push button with a heavy black border. If the button is in a dialog box, the user can select the button by pressing the ENTER key, even when the button does not have the input focus. This style is useful for enabling the user to quickly select the most likely option, or default.
$BS_MULTILINE | 0x2000 | Wraps the button text to multiple lines if the text string is too long to fit on a single line in the button rectangle.
$BS_TOP | 0x0400 | Places text at the top of the button rectangle.
$BS_VCENTER | 0x0C00 | Vertically centers text in the button rectangle.
$BS_ICON | 0x0040 | Specifies that the button displays an icon.
$BS_BITMAP | 0x0080 | Specifies that the button displays an bitmap.
$BS_FLAT | 0x8000 | Specifies that the button is two-dimensional; it does not use the default shading to create a 3-D image.

Combo Styles | Value | Description
Default/forced |  | see GUICtrlCreateCombo function.
$CBS_AUTOHSCROLL | 0x0040 | Automatically scrolls the text in an edit control to the right when the user types a character at the end of the line. If this style is not set, only text that fits within the rectangular boundary is enabled.
$CBS_DISABLENOSCROLL | 0x0800 | Shows a disabled vertical scroll bar in the list box when the box does not contain enough items to scroll. Without this style, the scroll bar is hidden when the list box does not contain enough items.
$CBS_DROPDOWN | 0x0002 | Displays only the edit control by default. The user can display the list box by selecting an icon next to the edit control.
$CBS_DROPDOWNLIST | 0x0003 | Displays a static text field that displays the current selection in the list box.
$CBS_LOWERCASE | 0x4000 | Converts to lowercase any uppercase characters that are typed into the edit control of a combo box.
$CBS_NOINTEGRALHEIGHT | 0x0400 | Specifies that the combo box will be exactly the size specified by the application when it created the combo box. Usually, Windows CE sizes a combo box so that it does not display partial items.
$CBS_OEMCONVERT | 0x0080 | Converts text typed in the combo box edit control from the Windows CE character set to the OEM character set and then back to the Windows CE set. This style is most useful for combo boxes that contain file names. It applies only to combo boxes created with the CBS_DROPDOWN style.
$CBS_SIMPLE | 0x0001 | Displays the list box at all times. The current selection in the list box is displayed in the edit control.
$CBS_SORT | 0x0100 | Sorts strings that are typed into the list box.
$CBS_UPPERCASE | 0x2000 | Converts to uppercase any lowercase characters that are typed into the edit control of a combo box.

List Styles | Value | Description
Default/forced |  | see GUICtrlCreateList function.
$LBS_DISABLENOSCROLL | 0x1000 | Shows a disabled vertical scroll bar for the list box when the box does not contain enough items to scroll. If you do not specify this style, the scroll bar is hidden when the list box does not contain enough items.
$LBS_NOINTEGRALHEIGHT | 0x0100 | Specifies that the list box will be exactly the size specified by the application when it created the list box.
$LBS_NOSEL | 0x4000 | Specifies that the user can view list box strings but cannot select them.
$LBS_NOTIFY | 0x0001 | Notifies the parent window when the user taps or double-taps a string in the list box.
$LBS_SORT | 0x0002 | Sorts strings in the list box alphabetically.
$LBS_STANDARD | 0xA00003 | Sorts strings in the list box alphabetically. The parent window receives an input message when the user taps or double-taps a string. The list box has borders on all sides. (LBS_NOTIFY | LBS_SORT | WS_VSCROLL | WS_BORDER)
$LBS_USETABSTOPS | 0x0080 | Enables a list box to recognize and expand tab characters when drawing its strings. The default tab positions are 32 dialog box units. A dialog box unit is equal to one-fourth of the current dialog box base-width unit.

Edit Styles | Value | Description
Default/forced |  | see GUICtrlCreateEdit function.
$ES_AUTOHSCROLL | 0x0080 | Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line. When the user presses the ENTER key, the control scrolls all text back to the zero position.
$ES_AUTOVSCROLL | 0x0040 | Scrolls text up one page when the user presses the ENTER key on the last line.
$ES_CENTER | 0x0001 | Centers text in a multiline edit control.
$ES_LOWERCASE | 0x0010 | Converts all characters to lowercase as they are typed into the edit control.
$ES_NOHIDESEL | 0x0100 | Negates the default behavior for an edit control. The default behavior hides the selection when the control loses the input focus and inverts the selection when the control receives the input focus. If you specify ES_NOHIDESEL, the selected text is inverted, even if the control does not have the focus.
$ES_NUMBER | 0x2000 | Accepts into the edit control only digits to be typed.
$ES_OEMCONVERT | 0x0400 | This style is most useful for edit controls that contain file names.
$ES_MULTILINE | 0x0004 | Designates a multiline edit control. The default is a single-line edit control.
$ES_PASSWORD | 0x0020 | Displays an asterisk (*) for each character that is typed into the edit control.
$ES_READONLY | 0x0800 | Prevents the user from typing or editing text in the edit control.
$ES_RIGHT | 0x0002 | Right-aligns text in a multiline edit control.
$ES_UPPERCASE | 0x0008 | Converts all characters to uppercase as they are typed into the edit control.
$ES_WANTRETURN | 0x1000 | Specifies that a carriage return be inserted when the user presses the ENTER key while typing text into a multiline edit control in a dialog box. If you do not specify this style, pressing the ENTER key has the same effect as pressing the dialog box’s default push button. This style has no effect on a single-line edit control.

Progress Bar Styles | Value | Description
PBS_SMOOTH | 0x01 | Displays progress status in a smooth scrolling bar instead of the default segmented bar.
PBS_VERTICAL | 0x04 | Displays progress status vertically, from bottom to top.

Up-down Styles | Value | Description
Default/forced |  | see GUICtrlCreateUpdown function.
$UDS_ALIGNLEFT | 0x08 | Positions the up-down control next to the left edge of the buddy window. The buddy window is moved to the right and its width is decreased to accommodate the width of the up-down control.
$UDS_ALIGNRIGHT | 0x04 | Positions the up-down control next to the right edge of the buddy window. The width of the buddy window is decreased to accommodate the width of the up-down control.
$UDS_ARROWKEYS | 0x20 | Causes the up-down control to process the UP ARROW and DOWN ARROW keys on the keyboard.
$UDS_HORZ | 0x40 | Causes the up-down control’s arrows to point left and right instead of up and down.
$UDS_NOTHOUSANDS | 0x80 | Prevents insertion of a thousands separator between every three decimal positions.
$UDS_WRAP | 0x01 | Causes the position to wrap if it is incremented or decremented beyond the end or beginning of the range.

Label/Static Styles | Value | Description
Default/forced |  | see GUICtrlCreateLabel, GUICtrlCreateIcon, GUICtrlCreatePic functions.
$SS_BLACKFRAME | 0x07 | Specifies a box with a frame drawn in the same color as the window frames. This color is black in the default color scheme.
$SS_BLACKRECT | 0x04 | Specifies a rectangle filled with the current window frame color. This color is black in the default color scheme.
$SS_CENTER | 0x01 | Specifies a simple rectangle and centers the error value text in the rectangle. The control automatically wraps words that extend past the end of a line to the beginning of the next centered line.
$SS_CENTERIMAGE | 0x0200 | Specifies that the midpoint of a static control with the SS_BITMAP style will remain fixed when you resize the control. The four sides are adjusted to accommodate a new bitmap. If the bitmap is smaller than the control’s client area, the rest of the client area is filled with the color of the pixel in the upper-left corner of the bitmap. It can be used with static control having only one line of text.
$SS_ETCHEDFRAME | 0x12 | Draws the frame of the static control using the EDGE_ETCHED edge style.
$SS_ETCHEDHORZ | 0x10 | Draws the top and bottom edges of the static control using the EDGE_ETCHED edge style.
$SS_ETCHEDVERT | 0x11 | Draws the left and right edges of the static control using the EDGE_ETCHED edge style.
$SS_GRAYFRAME | 0x08 | Specifies a box with a frame drawn with the same color as the screen background (desktop). This color is gray in the default color scheme
$SS_GRAYRECT | 0x05 | Specifies a rectangle filled with the current screen background color. This color is gray in the default color scheme.
$SS_LEFT | 0x0000 | Specifies a simple rectangle and left-aligns the text in the rectangle. The text is formatted before it is displayed. Words that extend past the end of a line are automatically wrapped to the beginning of the next left-aligned line. Words that are longer than the width of the control are truncated.
$SS_LEFTNOWORDWRAP | 0x0C | Specifies a rectangle and left-aligns the text in the rectangle. Tabs are expanded, but words are not wrapped. Text that extends past the end of a line is clipped.
$SS_NOPREFIX | 0x80 | Prevents interpretation of any ampersand (&) characters in the control’s text as accelerator prefix characters. An application can combine SS_NOPREFIX with other styles by using the bitwise OR (|) operator. This can be useful when file names or other strings that might contain an ampersand (&) must be displayed within a static control in a dialog box.
$SS_NOTIFY | 0x0100 | Sends the parent window the STN_CLICKED notification when the user clicks the control.
$SS_RIGHT | 0x0002 | Specifies a rectangle and right-aligns the specified text in the rectangle.
$SS_RIGHTJUST | 0x0400 | Specifies that the lower right corner of a static control with the SS_BITMAP or SS_ICON style is to remain fixed when the control is resized. Only the top and left sides are adjusted to accommodate a new bitmap or icon.
$SS_SIMPLE | 0x0B | Specifies a simple rectangle and displays a single line of left-aligned text in the rectangle. The text line cannot be shortened or altered in any way. Also, if the control is disabled, the control does not gray its text.
$SS_SUNKEN | 0x1000 | Draws a half-sunken border around a static control.
$SS_WHITEFRAME | 0x09 | Specifies a box with a frame drawn with the same color as the window background. This color is white in the default color scheme.
$SS_WHITERECT | 0x06 | Specifies a rectangle filled with the current window background color. This color is white in the default color scheme.

Tab Styles | Value | Description
Default/forced |  | see GUICtrlCreateTab function.
$TCS_SCROLLOPPOSITE | 0x0001 | Unneeded tabs scroll to the opposite side of the control when a tab is selected.
$TCS_BOTTOM | 0x0002 | Tabs appear at the bottom of the control.
$TCS_RIGHT | 0x0002 | Tabs appear vertically on the right side of controls that use the TCS_VERTICAL style. This value equals TCS_BOTTOM.
$TCS_MULTISELECT | 0x0004 | Multiple tabs can be selected by holding down CTRL when clicking. This style must be used with the TCS_BUTTONS style.
$TCS_FLATBUTTONS | 0x0008 | Selected tabs appear as being indented into the background while other tabs appear as being on the same plane as the background. This style only affects tab controls with the TCS_BUTTONS style.
$TCS_FORCEICONLEFT | 0x0010 | Icons are aligned with the left edge of each fixed-width tab. This style can only be used with the TCS_FIXEDWIDTH style.
$TCS_FORCELABELLEFT | 0x0020 | Labels are aligned with the left edge of each fixed-width tab; that is, the label is displayed immediately to the right of the icon instead of being centered. This style can only be used with the TCS_FIXEDWIDTH style, and it implies the TCS_FORCEICONLEFT style.
$TCS_HOTTRACK | 0x0040 | Items under the pointer are automatically highlighted
$TCS_VERTICAL | 0x0080 | Tabs appear at the left side of the control, with tab text displayed vertically. This style is valid only when used with the TCS_MULTILINE style. To make tabs appear on the right side of the control, also use the TCS_RIGHT style.
$TCS_TABS | 0x0000 | Tabs appear as tabs, and a border is drawn around the display area. This style is the default.
$TCS_BUTTONS | 0x0100 | Tabs appear as buttons, and no border is drawn around the display area.
$TCS_SINGLELINE | 0x0000 | Only one row of tabs is displayed. The user can scroll to see more tabs, if necessary. This style is the default.
$TCS_MULTILINE | 0x0200 | Multiple rows of tabs are displayed, if necessary, so all tabs are visible at once.
$TCS_RIGHTJUSTIFY | 0x0000 | The width of each tab is increased, if necessary, so that each row of tabs fills the entire width of the tab control. This window style is ignored unless the TCS_MULTILINE style is also specified.
$TCS_FIXEDWIDTH | 0x0400 | All tabs are the same width. This style cannot be combined with the TCS_RIGHTJUSTIFY style.
$TCS_RAGGEDRIGHT | 0x0800 | Rows of tabs will not be stretched to fill the entire width of the control. This style is the default.
$TCS_FOCUSONBUTTONDOWN | 0x1000 | The tab control receives the input focus when clicked.
$TCS_OWNERDRAWFIXED | 0x2000 | The parent window is responsible for drawing tabs.
$TCS_TOOLTIPS | 0x4000 | The tab control has a tooltip control associated with it.
$TCS_FOCUSNEVER | 0x8000 | The tab control does not receive the input focus when clicked.

Avi Clip Styles | Value | Description
Default/forced |  | see GUICtrlCreateAvi function.
$ACS_AUTOPLAY | 0x04 | Starts playing the animation as soon as the AVI clip is opened.
$ACS_CENTER | 0x01 | Centers the animation in the animation control's window.
$ACS_TRANSPARENT | 0x02 | Allows you to match an animation's background color to that of the underlying window, creating a "transparent" background. (Default value)
$ACS_NONTRANSPARENT | 0x10 | To override default ACS_TRANSPARENT

Date Styles | Value | Description
Default/forced |  | see GUICtrlCreateDate function.
$DTS_UPDOWN | 0x01 | Places an up-down control to the right of a DTP control to modify time values. This style can be used instead of the drop-down month calendar, which is the default style.
$DTS_SHOWNONE | 0x02 | Enables the control to accept “no date” as a valid selection state.
$DTS_LONGDATEFORMAT | 0x04 | Displays the date in long format. The default format string for this style is defined by LOCALE_SLONGDATEFORMAT, which produces output like “Friday, April 19, 1998.”
$DTS_TIMEFORMAT | 0x09 | Displays the time. The default format string for this style is defined by LOCALE_STIMEFORMAT, which produces output like “5:31:42 PM.”
$DTS_RIGHTALIGN | 0x20 | The drop-down month calendar will be right-aligned with the control instead of left-aligned, which is the default.
$DTS_SHORTDATEFORMAT | 0x00 | Displays the date in short format. The default format string for this style is defined by LOCALE_SSHORTDATE, which produces output like "4/19/96".

TreeView Styles | Value | Description
Default/forced |  | see GUICtrlCreateTreeView function.
$TVS_HASBUTTONS | 0x0001 | Displays plus (+) and minus (-) buttons next to parent items. The user clicks the buttons to expand or collapse a parent item's list of child items. To include buttons with items at the root of the tree view, TVS_LINESATROOT must also be specified.
$TVS_HASLINES | 0x0002 | Uses lines to show the hierarchy of items.
$TVS_LINESATROOT | 0x0004 | Uses lines to link items at the root of the tree view control. This value is ignored if TVS_HASLINES is not also specified.
$TVS_DISABLEDRAGDROP | 0x0010 | Prevents the tree view control from sending TVN_BEGINDRAG notification messages.
$TVS_SHOWSELALWAYS | 0x0020 | Causes a selected item to remain selected when the tree view control loses focus.
$TVS_RTLREADING | 0x0040 | Normal windows display text left-to-right (LTR). Windows can be mirrored to display languages such as Hebrew or Arabic that read right-to-left (RTL). Normally, tree view text will be displayed in same direction as the the text in its parent window. If TVS_RTLREADING is set, tree view text will read in the opposite direction from the text in the parent window.
$TVS_NOTOOLTIPS | 0x0080 | The tree view control does not support tooltips.
$TVS_CHECKBOXES | 0x0100 |
$TVS_TRACKSELECT | 0x0200 | Enables hot tracking in a tree view control.
$TVS_SINGLEEXPAND | 0x0400 | When this style is enabled, changing the selection in the tree view will automatically cause the item being selected to expand and the item being unselected to collapse. If the mouse is used to single-click the selected item and that item is closed, it will be expanded. If the user holds the CTRL key down while selecting an item, the item being unselected will not be collapsed.
$TVS_FULLROWSELECT | 0x1000 | Enables full-row selection in the tree view. The entire row of the selected item is highlighted, and clicking anywhere on an item's row will cause it to be selected. This style cannot be used in conjunction with the TVS_HASLINES style.
$TVS_NOSCROLL | 0x2000 | Disables horizontal scrolling in the control. The control will not display any horizontal scroll bars.
$TVS_NONEVENHEIGHT | 0x4000 | The height of the items can be set to an odd height with the TVM_SETITEMHEIGHT message. By default, the height of items must be an even value.

Slider Styles | Value | Description
Default/forced |  | see GUICtrlCreateSlider function.
$TBS_AUTOTICKS | 0x0001 | Adds tick marks when you set the range on the trackbar by using the TBM_SETRANGE message.
$TBS_BOTH | 0x0008 | Places ticks on both sides of the trackbar.
$TBS_BOTTOM | 0x0000 | Places ticks on the bottom of a horizontal trackbar.
$TBS_HORZ | 0x0000 | Specifies a horizontal trackbar. This is the default.
$TBS_VERT | 0x0002 | Places ticks on the left side of a vertical trackbar.
$TBS_NOTHUMB | 0x0080 | Specifies that the trackbar has no slider.
$TBS_NOTICKS | 0x0010 | Specifies that no ticks are placed on the trackbar.
$TBS_LEFT | 0x0004 | Places ticks on the left side of a vertical trackbar.
$TBS_RIGHT | 0x0000 | Places ticks on the right side of a vertical trackbar.
$TBS_TOP | 0x0004 | Places ticks on the top of a horizontal trackbar.

ListView Styles | Value | Description
Default/forced |  | see GUICtrlCreateListView function.
$LVS_REPORT | 0x0001 | This style specifies report view.
$LVS_EDITLABELS | 0x0200 | Item text can be edited in place.
$LVS_NOCOLUMNHEADER | 0x4000 | Column headers are not displayed in report view. By default, columns have headers in report view.
$LVS_NOSORTHEADER | 0x8000 | Column headers do not work like buttons. This style can be used if clicking a column header in report view does not carry out an action, such as sorting.
$LVS_SINGLESEL | 0x0004 | Only one item at a time can be selected.
$LVS_SHOWSELALWAYS | 0x0008 | The selection, if any, is always shown, even if the control does not have the focus.


Standard Windows Fonts

List based upon Standard Windows fonts.

Recommend Fonts are highlighted in yellow.

FONT NAME | Win95 | WinNT | Win98 | Win2000 | WinMe | WinXP
Abadi MT Condensed Light |  |  | x |  |  |
Arial | x | x | x | x | x | x
Arial Alternative Regular |  |  |  |  | x |
Arial Alternative Symbol |  |  |  |  | x |
Arial Black |  |  | x | x | x | x
Arial Bold | x | x | x | x | x | x
Arial Bold Italic | x | x | x | x | x | x
Arial Italic | x | x | x | x | x | x
Book Antiqua |  |  | x |  |  |
Calisto MT |  |  | x |  |  |
Century Gothic |  |  | x |  |  |
Century Gothic Bold |  |  | x |  |  |
Century Gothic Bold Italic |  |  | x |  |  |
Century Gothic Italic |  |  | x |  |  |
Comic Sans MS |  |  | x | x | x |
Comic Sans MS Bold |  |  | x | x | x | x
Copperplate Gothic Bold |  |  | x |  |  |
Copperplate Gothic Light |  |  | x |  |  |
Courier | x | x | x | x | x | x
Courier New | x | x | x | x | x | x
Courier New Bold | x | x | x | x | x | x
Courier New Bold Italic | x | x | x | x | x | x
Courier New Italic | x | x | x | x | x | x
Estrangelo Edessa |  |  |  |  |  | x
Franklin Gothic Medium |  |  |  |  |  | x
Franklin Gothic Medium Italic |  |  |  |  | x |
Gautami |  |  |  |  |  | x
Georgia |  |  |  | x |  | x
Georgia Bold |  |  |  | x |  | x
Georgia Bold Italic |  |  |  | x |  | x
Georgia Italic |  |  |  | x |  | x
Georgia Italic Impact |  |  |  |  |  | x
Impact |  |  | x | x | x |
Latha |  |  |  |  |  | x
Lucida Console |  | x | x | x | x | x
Lucida Handwriting Italic |  |  | x |  |  |
Lucida Sans Italic |  |  | x |  |  |
Lucida Sans Unicode |  |  | x | x |  | x
Marlett |  |  | x |  | x |
Matisse ITC |  |  | x |  |  |
Modern | x | x | x | x |  |
Modern MS Sans Serif |  |  |  |  |  | x
MS Sans Serif | x | x | x | x | x | x
MS Serif | x | x | x | x | x |
Mv Boli |  |  |  |  |  | x
News Gothic MT |  |  | x |  |  |
News Gothic MT Bold |  |  | x |  |  |
News Gothic MT Italic |  |  | x |  |  |
OCR A Extended |  |  | x |  |  |
Palatino Linotype |  |  |  | x |  | x
Palatino Linotype Bold |  |  |  | x |  | x
Palatino Linotype Bold Italic |  |  | x |  | x |
Palatino Linotype Italic |  |  |  | x |  | x
Roman |  | x |  | x |  | x
Script |  | x |  | x |  | x
Small Fonts |  | x |  | x |  | x
Smallfonts | x |  | x |  | x |
Symbol | x | x | x | x | x | x
Tahoma |  |  | x | x | x | x
Tahoma Bold |  |  | x | x | x | x
Tempus Sans ITC |  |  | x | x |  |
Times New Roman | x | x | x | x | x | x
Times New Roman Bold | x | x | x | x | x | x
Times New Roman Bold Italic | x | x | x | x | x | x
Times New Roman Italic | x | x | x | x | x | x
Trebuchet |  |  |  |  | x |
Trebuchet Bold |  |  |  |  | x |
Trebuchet Bold Italic |  |  |  |  | x |
Trebuchet Italic |  |  |  |  | x |
Trebuchet MS |  |  |  | x |  | x
Trebuchet MS Bold |  |  |  | x |  | x
Trebuchet MS Bold Italic |  |  |  | x |  | x
Trebuchet MS Italic |  |  |  | x |  | x
Tunga |  |  |  |  |  | x
Verdana |  |  | x | x | x | x
Verdana Bold |  |  | x | x | x | x
Verdana Bold Italic |  |  | x | x | x | x
Verdana Italic |  |  | x | x | x | x
Webdings |  |  | x | x | x | x
Westminster |  |  | x |  | x | x
Wingdings | x | x |  | x |  | x
WST_Czech |  |  |  |  |  | x
WST_Engl |  |  |  |  |  | x
WST_Fren |  |  |  |  |  | x
WST_Germ |  |  |  |  |  | x
WST_Ital |  |  |  |  |  | x
WST_Span |  |  |  |  |  | x
WST_Swed |  |  |  |  |  | x


Language Codes

@OSLang codes

Possible return values (strings) of @OSLang

List was generated from Windows 2000 - List of Locale IDs and Language Groups

Note: Codes that contain letters could possible have the letters in uppercase.

Code | Meaning
0436 | Afrikaans
041c | Albanian
0401 | Arabic_Saudi_Arabia
0801 | Arabic_Iraq
0c01 | Arabic_Egypt
1001 | Arabic_Libya
1401 | Arabic_Algeria
1801 | Arabic_Morocco
1c01 | Arabic_Tunisia
2001 | Arabic_Oman
2401 | Arabic_Yemen
2801 | Arabic_Syria
2c01 | Arabic_Jordan
3001 | Arabic_Lebanon
3401 | Arabic_Kuwait
3801 | Arabic_UAE
3c01 | Arabic_Bahrain
4001 | Arabic_Qatar
042b | Armenian
042c | Azeri_Latin
082c | Azeri_Cyrillic
042d | Basque
0423 | Belarusian
0402 | Bulgarian
0403 | Catalan
0404 | Chinese_Taiwan
0804 | Chinese_PRC
0c04 | Chinese_Hong_Kong
1004 | Chinese_Singapore
1404 | Chinese_Macau
041a | Croatian
0405 | Czech
0406 | Danish
0413 | Dutch_Standard
0813 | Dutch_Belgian
0409 | English_United_States
0809 | English_United_Kingdom
0c09 | English_Australian
1009 | English_Canadian
1409 | English_New_Zealand
1809 | English_Irish
1c09 | English_South_Africa
2009 | English_Jamaica
2409 | English_Caribbean
2809 | English_Belize
2c09 | English_Trinidad
3009 | English_Zimbabwe
3409 | English_Philippines
0425 | Estonian
0438 | Faeroese
0429 | Farsi
040b | Finnish
040c | French_Standard
080c | French_Belgian
0c0c | French_Canadian
100c | French_Swiss
140c | French_Luxembourg
180c | French_Monaco
0437 | Georgian
0407 | German_Standard
0807 | German_Swiss
0c07 | German_Austrian
1007 | German_Luxembourg
1407 | German_Liechtenstei
408 | Greek
040d | Hebrew
0439 | Hindi
040e | Hungarian
040f | Icelandic
0421 | Indonesian
0410 | Italian_Standard
0810 | Italian_Swiss
0411 | Japanese
043f | Kazakh
0457 | Konkani
0412 | Korean
0426 | Latvian
0427 | Lithuanian
042f | Macedonian
043e | Malay_Malaysia
083e | Malay_Brunei_Darussalam
044e | Marathi
0414 | Norwegian_Bokmal
0814 | Norwegian_Nynorsk
0415 | Polish
0416 | Portuguese_Brazilian
0816 | Portuguese_Standard
0418 | Romanian
0419 | Russian
044f | Sanskrit
081a | Serbian_Latin
0c1a | Serbian_Cyrillic
041b | Slovak
0424 | Slovenian
040a | Spanish_Traditional_Sort
080a | Spanish_Mexican
0c0a | Spanish_Modern_Sort
100a | Spanish_Guatemala
140a | Spanish_Costa_Rica
180a | Spanish_Panama
1c0a | Spanish_Dominican_Republic
200a | Spanish_Venezuela
240a | Spanish_Colombia
280a | Spanish_Peru
2c0a | Spanish_Argentina
300a | Spanish_Ecuador
340a | Spanish_Chile
380a | Spanish_Uruguay
3c0a | Spanish_Paraguay
400a | Spanish_Bolivia
440a | Spanish_El_Salvador
480a | Spanish_Honduras
4c0a | Spanish_Nicaragua
500a | Spanish_Puerto_Rico
0441 | Swahili
041d | Swedish
081d | Swedish_Finland
0449 | Tamil
0444 | Tatar
041e | Thai
041f | Turkish
0422 | Ukrainian
0420 | Urdu
0443 | Uzbek_Latin
0843 | Uzbek_Cyrillic
042a | Vietnamese

Example

MsgBox(0, "Your OS Language:", _Language())

Func _Language()
Select
Case StringInStr("0413,0813", @OSLang)
Return "Dutch"

Case StringInStr("0409,0809,0c09,1009,1409,1809,1c09,2009,_
2409,2809,2c09,3009,3409", @OSLang)
Return "English"

Case StringInStr("040c,080c,0c0c,100c,140c,180c", @OSLang)
Return "French"

Case StringInStr("0407,0807,0c07,1007,1407", @OSLang)
Return "German"

Case StringInStr("0410,0810", @OSLang)
Return "Italian"

Case StringInStr("0414,0814", @OSLang)
Return "Norwegian"

Case StringInStr("0415", @OSLang)
Return "Polish"

Case StringInStr("0416,0816", @OSLang)
Return "Portuguese"

Case StringInStr("040a,080a,0c0a,100a,140a,180a,1c0a,200a,_
240a,280a,2c0a,300a,340a,380a,3c0a,400a,_
440a,480a,4c0a,500a", @OSLang)
Return "Spanish"

Case StringInStr("041d,081d", @OSLang)
Return "Swedish"

Case Else
Return "Other (can determine with @OSLang directly"

EndSelect
EndFunc


Send Key list

Quick reference for the Send ( "keys" [, flag] ) Command. ^ Ctrl ! Alt + Shift # Win

AutoIt can send all ASCII and Extended ASCII characters (0-255), to send UNICODE characters you must use the "ASC" option and the code of the character you wish to send (see {ASC} below).

To send the ASCII value A (same as pressing ALT+065 on the numeric keypad)

Send("{ASC 065}")

(When using 2 digit ASCII codes you must use a leading 0, otherwise an obselete 437 code page is used).

To send UNICODE characters enter the character code, for example this sends a Chinese character

Send("{ASC 2709}")

Single keys can also be repeated, e.g.

Send("{DEL 4}") ;Presses the DEL key 4 times
Send("{S 30}") ;Sends 30 'S' characters
Send("+{TAB 4}) ;Presses SHIFT+TAB 4 times

To hold a key down (generally only useful for games)

Send("{a down}") ;Holds the A key down Send("{a up}") ;Releases the A key

If you with to use a variable for the count, try

$n = 4
Send("+{TAB " & $n & "}")

If you wish to send the ASCII value A four times, then try

$x = Chr(65)
Send("{" & $x & " 4}")

Most laptop computer keyboards have a special Fn key. This key cannot be simulated.

Note, by setting the flag parameter to 1 the "keys" parameter is sent RAW. This is useful when you want to send some text copied from a variable and you want the text sent exactly as written.

Send is quite useful because windows can be navigated without needing a mouse.

For example, open Folder Options (in the control panel) and try the following:

Send("{TAB}") | Navigate to next control (button, checkbox, etc)
Send("+{TAB}") | Navigate to previous control.
Send("^{TAB}") | Navigate to next WindowTab (on a Tabbed dialog window)
Send("^+{TAB}") | Navigate to previous WindowTab.
Send("{SPACE}") | Can be used to toggle a checkbox or click a button.
Send("{+}") | Usually checks a checkbox (if it's a "real" checkbox.)
Send("{-}") | Usually unchecks a checkbox.
Send("{NumPadMult}") | Recursively expands folders in a SysTreeView32.

Use Alt-key combos to access menu items. Also, open Notepad and try the following:

Send("!f") | Send Alt+f, the access key for Notepad's file menu. Try other letters!
Send("{DOWN}") | Move down a menu.
Send("{UP}") | Move up a menu.
Send("{LEFT}") | Move leftward to new menu or expand a submenu.
Send("{RIGHT}") | Move rightward to new menu or collapse a submenu.

See Windows' Help--press Win+F1--for a complete list of keyboard shortcuts if you don't know the importance of Alt+F4, PrintScreen, Ctrl+C, and so on.

Send Command (if zero flag) | Resulting Keypress
{!} | !
{#} | #
{+} | +
{^} | ^
{{} | {
{}} | }
{SPACE} | SPACE
{ENTER} | ENTER key on the main keyboard
{ALT} | ALT
{BACKSPACE} or {BS} | BACKSPACE
{DELETE} or {DEL} | DELETE
{UP} | Cursor up
{DOWN} | Cursor down
{LEFT} | Cursor left
{RIGHT} | Cursor right
{HOME} | HOME
{END} | END
{ESCAPE} or {ESC} | ESCAPE
{INSERT} or {INS} | INS
{PGUP} | PGUP
{PGDN} | PGDN
{F1} - {F12} | Function keys
{TAB} | TAB
{PRINTSCREEN} | PRINTSCR
{LWIN} | Left Windows key
{RWIN} | Right Windows key
{NUMLOCK} | NUMLOCK
{CTRLBREAK} | Ctrl+Break
{PAUSE} | PAUSE
{CAPSLOCK} | CAPSLOCK
{NUMPAD0} - {NUMPAD9} | Numpad digits
{NUMPADMULT} | Numpad Multiply
{NUMPADADD} | Numpad Add
{NUMPADSUB} | Numpad Subtract
{NUMPADDIV} | Numpad Divide
{NUMPADDOT} | Numpad period
{NUMPADENTER} | Enter key on the numpad
{APPSKEY} | Windows App key
{LALT} | Left ALT key
{RALT} | Right ALT key
{LCTRL} | Left CTRL key
{RCTRL} | Right CTRL key
{LSHIFT} | Left Shift key
{RSHIFT} | Right Shift key
{SLEEP} | Computer SLEEP key
{ALTDOWN} | Holds the ALT key down until {ALTUP} is sent
{SHIFTDOWN} | Holds the SHIFT key down until {SHIFTUP} is sent
{CTRLDOWN} | Holds the CTRL key down until {CTRLUP} is sent
{LWINDOWN} | Holds the left Windows key down until {LWINUP} is sent
{RWINDOWN} | Holds the right Windows key down until {RWINUP} is sent
{ASC nnnn} | Send the ALT+nnnn key combination
{BROWSER_BACK} | 2000/XP Only: Select the browser "back" button
{BROWSER_FORWARD} | 2000/XP Only: Select the browser "forward" button
{BROWSER_REFRESH} | 2000/XP Only: Select the browser "refresh" button
{BROWSER_STOP} | 2000/XP Only: Select the browser "stop" button
{BROWSER_SEARCH} | 2000/XP Only: Select the browser "search" button
{BROWSER_FAVORITES} | 2000/XP Only: Select the browser "favorites" button
{BROWSER_HOME} | 2000/XP Only: Launch the browser and go to the home page
{VOLUME_MUTE} | 2000/XP Only: Mute the volume
{VOLUME_DOWN} | 2000/XP Only: Reduce the volume
{VOLUME_UP} | 2000/XP Only: Increase the volume
{MEDIA_NEXT} | 2000/XP Only: Select next track in media player
{MEDIA_PREV} | 2000/XP Only: Select previous track in media player
{MEDIA_STOP} | 2000/XP Only: Stop media player
{MEDIA_PLAY_PAUSE} | 2000/XP Only: Play/pause media player
{LAUNCH_MAIL} | 2000/XP Only: Launch the email application
{LAUNCH_MEDIA} | 2000/XP Only: Launch media player
{LAUNCH_APP1} | 2000/XP Only: Launch user app1
{LAUNCH_APP2} | 2000/XP Only: Launch user app2


AutoIt

Credits

In no particular order, but thank you all! (-Jon)

Please see here for details of the coding contributions. (Email me if you have been left out).

AutoIt v3 Coding

- Jonathan Bennett <jon at hiddensoft com>

- Larry Keys <larrydalooza at yahoo com>

- David Nuttall <nutster at autoit3 com>

- J-Paul Mesnage <jpaul-mesnage at ifrance com>

- Jason Boggs <vampirevalik at hotmail com>

- Tylo <tylo at start no>

- Jeremy Landes <jlandes at landeserve com>

- Philip "CyberSlug" Gump <cyberslug at autoitscript com>

- Jos van der Zande <jdeb at autoitscript.com >

- Holger <Holger.Kotsch at GMX de>

- Garrett "The HardlyDeservesCreditFor20LinesOfCode" R. Mueller ;) <garrett at mailsnare net>

AutoIt v3 Help Files

- Most of the above ;p

- Philip "CyberSlug" Gump <cyberslug at autoitscript com> (and helper scripts)

- Jos van der Zande <jdeb at autoitscript com> (and helper scripts)

- ScriptKitty <scriptkitty at autoitscript com>

AutoIt v3 Standard Includes

- The authors as documented in the include files themselves.

- Jos van der Zande <jdeb at autoitscript com>

- Jeremy Landes <jlandes at landeserve com>

- Brian Keene <brian_keene at juno com>

Many thanks to the above for compiling/modifying them all.

AutoIt v3 Extras and Third Party Tools

- JdeB <jdeb at autoitscript com> (AutoIt version of the Scite editor)

Special Thanks

- Everyone who continues to use and support AutoIt

- Jeremy Landes for providing extra download capacity at http://www.landeserve.com

- The authors of UPX which is used for creating compressed executables produced by AutoIt.


History

Here is the public history for AutoIt v3. For the full technical log including beta versions click here.

7th Apr, 2005 - v3.1.1

Minor bugfix release.

  • Fixed: @OSVersion did not work for Windows Server 2003
  • Fixed: $LVS_EX_FULLROWSELECT in GUIConstants.au3 was incorrectly defined as $LBS...
  • Fixed: @YDAY was incorrect (one day out)

7th Feb, 2005 - v3.1.0

  • Added: GUI creation capabilties
  • Added: DllCall(), DllOpen(), DllClose()
  • Added: ControlListView()
  • Added: WinList()
  • Added: DirGetSize()
  • Added: IniReadSectionNames(), IniReadSection()
  • Added: InetGet(), InetGetSize()
  • Added: HttpSetProxy(), FtpSetProxy()
  • Added: FtpBinaryMode (Option)
  • Added: Ping()
  • Added: ControlGetHandle()
  • Added: WinGetProcess() and ProcessList()
  • Added: SetExtended()
  • Added: WinSetTrans()
  • Added: Assign()
  • Added: ConsoleWrite()
  • Added: @AutoItExe macro
  • Added: Const keyword
  • Added: Optional parameter support for user functions
  • Added: "main", "primary", "menu", "secondary" added as valid mouse button types
  • Added: ExpandVarStrings (Option)
  • Added: The user functions OnAutoItStart() and OnAutoItExit() are called during startup/exit
  • Added: OnExitFunc (Option)
  • Removed: URLDownloadToFile() (Replaced by InetGet())
  • Changed: For loops automatically declare the counter variable as a Local variable
  • Changed: IniDelete() can also delete entire sections
  • Changed: StringReplace() also returns the number of replacements in the @extended macro
  • Changed: StringMid() the "count" parameter is now optional (assumes remainder of the string)
  • Changed: PixelChecksum() now has optional step parameter
  • Changed: Control...() functions now accept the Control ID as an extra way to identify a control
  • Changed: InetGet() function can download in the background
  • Changed: Reg...() functions no longer give a hard error when an unknown key is used.
  • Changed: The mouse and pixel functions now have an additional "client area" mode
  • Changed: Added WIN_2003 to the possible values for @OS_VERSION
  • Changed: AU3Spy.exe renamed to AU3Info.exe
  • Changed: Major upgrades to the AutoIt Window Info Tool (control highlighting, magnify, cursor IDs)
  • Changed: FileSelectFolder() supports an initial directory as well as a root directory
  • Changed: File functions no longer give fatal errors when -1 is used as a handle
  • Fixed: Memory leak in SplashImageOn()
  • Fixed: Expressions like "$var = $var" will now give an error if the variable wasn't previously defined
  • Fixed: StringFormat() with \\ characters
  • Fixed: Under rare situations after closing a script AutoIt3.exe would still appear in task manager for a while
  • Fixed: Certain paths like @WindowsDir were incorrect under Windows Terminal Server
  • Fixed: FileSetTime() systems in non-GMT timezones had incorrect results
  • Fixed: FileMove() with UNC paths (does a real move when in the same dir rather than a copy).
  • Fixed: ^ operator
  • Fixed: Chr()
  • Fixed: StatusBarGetText() failed when used with no "Text" parameter
  • Fixed: InputBox() didn't return focus to the previously active window

4th Aug, 2004 - v3.0.102

Major Change: Colors now default to the standard RGB format rather than the previous BGR format. This affects PixelSearch() and PixelGetColor().

The "ColorMode" option has been added to allow old scripts to run with the old BGR mode, just
place this line at the top of your script to use the old method, e.g.:

Opt("ColorMode", 1)

If you use color functions in your code you MUST take notice of the above change and either change the colors in your code OR add the Opt ColorMode option as shown above. This especially affects BOTs and code that interacts with games.

  • Added: DriveMapAdd(), DriveMapDel() and DriveMapGet()
  • Added: @SW_SHOWDEFAULT, @SW_SHOWMAXIMIZED, @SW_SHOWMINIMIZED, @SW_SHOWMINNOACTIVE,
    @SW_SHOWNA, @SW_SHOWNOACTIVATE, @SW_SHOWNORMAL
  • Added: FileGetShortcut()
  • Added: Predefined $CmdLineRaw variable now holds the original command line in full
  • Added: @DesktopDepth
  • Added: ReDim
  • Added: More command line params for Aut2Exe.exe: /nodecompile and /comp 0-4 (compression level, 4=best)
  • Added: Process ID (PID) support for Process...() and Run() functions
  • Added: ProcessSetPriority()
  • Added: Decompiler (Exe2Aut) added
  • Added: PixelChecksum()
  • Added: Strings starting with "0x" are converted from hex when used numerically
  • Added: MouseWheel()
  • Added: RegEnumKey() and RegEnumVal()
  • Added: FileRecycleEmpty()
  • Changed: TimerStart() renamed to TimerInit(). TimerStop() renamed to TimerDiff()
  • Changed: FileSelectFolder() flag parameter changed
  • Changed: REG_MULTI_SZ values in Reg...() functions allow double NULL values
  • Changed: BirOr(), BitAnd() and BitXOR() take up to 255 parameters
  • Changed: Icon and windowstate options added to FileCreateShortcut()
  • Changed: RunAsSet() supports extra profile handling options
  • Changed: RegWrite() now accepts just the keyname in order to create a keyname with no value
  • Changed: "Allow Decompilation" option added to Aut2Exe
  • Changed: Aut2Exe gives feedback during compilation and gives the option to abort
  • Changed: Compiled scripts run/extract much faster when using FileInstall and medium/large files
  • Changed: Max number of user function limits removed
  • Changed: Max number of variable limits removed
  • Changed: -1 does no sleep at all for Send/Mouse delays (SendKeyDelay, etc...)
  • Changed: Optional occurance parameter added to StringInStr()
  • Changed: Optional default filename added to FileOpenDialog() and FileSaveDialog()
  • Changed: Registry functions accept 4 letters keys (HKLM instead of HKEY_LOCAL_MACHINE, etc.)
  • Changed: Remote registry keys are accepted in the form "\\computername\key\subkey"
  • Changed: AutoItSetOption returns the previous setting
  • Fixed: FileGetSize() works on >2GB files and in-use files
  • Fixed: The expression: If "non-blank" And 1 - now evaluates as true
  • Fixed: ToolTip() when the mouse is near the bottom of the screen
  • Fixed: StringIsDigit()
  • Fixed: Process...() functions under NT4 unable to see certain processes
  • Fixed: Some keywords incorrectly allowed after a THEN keyword

11th Mar, 2004 - v3.0.101

  • Added: MemGetStats()
  • Fixed: Windows 95a compatibility
  • Fixed: Minor help file typos

29th Feb, 2004 - v3.0.100

  • Initial release


CREDITS
=======

AutoIt v3 is based on the original AutoIt program by Jonathan Bennett.

Programming
===========

Core Programming and framework (and style police)
-------------------------------------------------
- Jonathan Bennett <jon at hiddensoft com>

Contributions
-------------
Names are listed in NO PARTICULAR ORDER.  The script commands that were influenced/created by the contributors
are also given where possible - if you are not mentioned and think you should be then drop me a mail.

- Larry Keys <larrydalooza at yahoo com>

    AutoIt Window Spy, AU3GUI and

    ControlFocus, ControlLeftClick, @IPAddressNN, FileGetSize, FileGetTime, FileOpenDialog,
    FileSaveDialog, FileSelectFolder, DiskSpaceTotal, DiskSpaceFree, PixelSearch, PixelGetColor,
    FileCreateShortcut, WinSetOnTop, FileExists, DriveGetDrive, CDTray, ControlSetText,
    ControlGetText, ControlCommand, ControlMove, ControlEnable, ControlDisable, ControlShow,
    ControlHide, WinGetClassList, IsAdmin, SplashImageOn, SplashTestOn, SplashOff
    ProgressOn, ProgressOff, ProgressSet, DriveGetLabel, DriveGetSerial, DriveGetFileSystem,
    DriveSetLabel, DriveGetType, MouseGetCursor, FileFindFirstFile, FileFindNextFile,
    ControlGetFocus

- David Nuttall <danuttall at autoit3 com>

    General C++ advice,
    StringIsAlpha, StringIsLower, StringIsUpper, StringIsDigit, StringIsAlNum, StringIsXDigit, StringIsSpace,
    StringIsASCII, RegDelete, Asc, DirRemove, DirCreate, Random, UBound, FileRecycle, IsArray, IsInt, IsFloat,
    IsString, StringStripWS, Mod, InputBox, variabletable.cpp rewrite and binary tree prototypes, new function
    lookup design/ideas, Redim, unified Structure stack, ContinueLoop, Util_MouseDown, Util_MouseUp (primary/secondary),
    Binary Search code for function lookup, StringRegEx... functions.

- J-Paul Mesnage <jpaul-mesnage at ifrance com>

    v2 to v3 Converter, AU3GUI and

    Lots of bug reports, regression testing and ideas/prototypes,
    @OSServicePack, @OSBuild, @AutoItVersion, AutoItWinShow, AutoItWinWrite, SoundPlay, StringFormat
    @OSLang, Hex, AutoItWinGetText, _ Continuation, Single-line IFs, Dim/Global/Local same line initialisation,
    TrayTipDebug, better non-English keyboard support for Send functions, optional UDF parameters

    Prototypes for: Error/include tracking code, Local/Global

- Jason Boggs <vampirevalik at hotmail com>

    #include <> multiple directories, TrayTip, ToolTip, MemGetStats, new function lookup design/ideas,
    PID support in process functions and Run(), ProcessSetPriority, Assign, ConsoleWrite, ProcessList,
    WinSetTrans, IniReadSectionNames, IniReadSection

- Tylo <tylo at start.no>

    Float lexing and double to string conversions.  Some math functions (tan, atan, etc.)
    vector_datatype.h, stack_datatype.h, variable_table.cpp rewrite (discontinued), new function lookup
    design/ideas

- Jeremy Landes <jlandes at landeserve com>

    Standard include files compilation and

    XP Visual Styles manifest files.  Some math functions (Abs, Pow, Sqrt, etc.)
    @UserName, @TempDir, @UserProfileDir, @HomeDrive, @HomePath, @HomeShare, @LogonServer,
    @LogonDomain, @LogonDNSDomain

- Philip "CyberSlug" Gump <cyberslug at autoitscript com>

    ControlCommand(GetCurrentCol)

- Jos van der Zande <jvdzande at yahoo com>

    Misc bug fixes, Scite lexer, Standard include files.

- Holger <Holger.Kotsch at GMX de>

    AU3GUI (especially Menus, Treeviews and ContextMenus) and

    FileGetShortcut, FileCreateShortcut, FileSelectFolder, @DesktopRefresh, Ping

- Garrett "The HardlyDeservesCreditFor20LinesOfCode" R. Mueller ;) <garrett at mailsnare.net>

    TimerInit, TimerDiff

External contributions and other sources used
---------------------------------------------

- Amir Szekely <kichik at netvision net il>

    ResourceEditor.cpp - Resource editing functions (works on 9x too)
    Thanks to Amir who coded the resource functions for the NSIS Installer and helped me
    get the code working with AutoIt.  Check out the NSIS installer at:
    http://nsis.sourceforge.net/site/index.php

- Gabriele Scibilia <http://www.geocities.com/gabriele_scibilia/>

    qmath.h - used with permission.


3.1.1 (7th Apr, 2005) (Release)
- Fixed: @OSVersion did not work for Windows Server 2003
- Fixed: $LVS_EX_FULLROWSELECT in GuiConstants.au3 was defined $LBS...
- Fixed: @YDAY was incorrect (one day out)

3.1.0 (7th Feb, 2005) (Release)

- Added: GUI creation capabilties
- Added: DllCall(), DllOpen(), DllClose()
- Added: ControlListView()
- Added: WinList()
- Added: DirGetSize()
- Added: IniReadSectionNames(), IniReadSection()
- Added: InetGet(), InetGetSize()
- Added: HttpSetProxy(), FtpSetProxy()
- Added: FtpBinaryMode (Option)
- Added: Ping()
- Added: ControlGetHandle()
- Added: WinGetProcess() and ProcessList()
- Added: SetExtended()
- Added: WinSetTrans()
- Added: Assign()
- Added: ConsoleWrite()
- Added: @AutoItExe macro
- Added: Const keyword
- Added: Optional parameter support for user functions
- Added: "main", "primary", "menu", "secondary" added as valid mouse button types
- Added: ExpandVarStrings (Option)
- Added: The user functions OnAutoItStart() and OnAutoItExit() are called during startup/exit
- Added: OnExitFunc (Option)
- Added: (Internal) Native HWND datatype added to variants

- Removed: URLDownloadToFile() (Replaced by InetGet())

- Changed: For loops automatically declare the counter variable as a Local variable
- Changed: IniDelete() can also delete entire sections
- Changed: StringReplace() also returns the number of replacements in the @extended macro
- Changed: StringMid() the "count" parameter is now optional (assumes remainder of the string)
- Changed: PixelChecksum() now has optional step parameter
- Changed: Control...() functions now accept the Control ID as an extra way to identify a control
- Changed: InetGet() function can download in the background
- Changed: Reg...() functions no longer give a hard error when an unknown key is used.
- Changed: The mouse and pixel functions now have an additional "client area" mode
- Changed: Added WIN_2003 to the possible values for @OS_VERSION
- Changed: AU3Spy.exe renamed to AU3Info.exe
- Changed: Major upgrades to the AutoIt Window Spy (control highlighting, magnify)
- Changed: FileSelectFolder supports an initial directory as well as a root directory
- Changed: File functions no longer give fatal errors when -1 is used as a handle
- Changed: (Internal) new quicker variable lookup using a binary tree
- Changed: (Internal) new shared process memory class used for StatusBarGetText()
- Changed: (Internal) Unified structure stacks (If, Func, Select, While, Do, For)
- Changed: (Internal) Variant rewrite (now handles int32, int64, double, string, HWND data)

- Fixed: Memory leak in SplashImageOn()
- Fixed: Expressions like "$var = $var" will now give an error if the variable wasn't previously defined
- Fixed: StringFormat() with \\ characters
- Fixed: Under rare situations after closing a script AutoIt3.exe would still appear in task manager for a while
- Fixed: Certain paths like @WindowsDir were incorrect under Windows Terminal Server
- Fixed: FileSetTime() systems in non-GMT timezones had incorrect results
- Fixed: FileMove() with UNC paths (does a real move when in the same dir rather than a copy).
- Fixed: ^ operator
- Fixed: Chr()
- Fixed: StatusBarGetText() failed when used with no "Text" parameter
- Fixed: InputBox() didn't return focus to the previously active window

3.0.102 (4th August, 2004) (Release)

- Major Change: Colors now default to the standard RGB format rather than the previous BGR format.

    This affects PixelSearch, PixelGetColor.

    The "ColorMode" option has been added to allow old scripts to run with the old BGR mode, just
    place this line at the top of your script to use the old method:

    Opt("ColorMode", 1)

- Added: DriveMapAdd(), DriveMapDel() and DriveMapGet()
- Added: @SW_SHOWDEFAULT, @SW_SHOWMAXIMIZED, @SW_SHOWMINIMIZED, @SW_SHOWMINNOACTIVE,
        @SW_SHOWNA, @SW_SHOWNOACTIVATE, @SW_SHOWNORMAL
- Added: FileGetShortcut()
- Added: Predefined $CmdLineRaw variable now holds the original command line in full
- Added: @DesktopDepth
- Added: ReDim
- Added: Command line option /ErrorStdOut
- Added: More command line params for Aut2Exe.exe: /nodecompile and /comp 0-4  (compression level, 4=best)
- Added: Process ID (PID) support for Process...() and Run() functions
- Added: ProcessSetPriority()
- Added: Decompiler (Exe2Aut) added
- Added: PixelChecksum()
- Added: Strings starting with "0x" are converted from hex when used numerically
- Added: Multi-directory #include <> paths
- Added: MouseWheel()
- Added: FileRecycleEmpty()
- Added: RegEnumKey() and RegEnumVal()

- Changed: TimerStart() renamed to TimerInit().  TimerStop() renamed to TimerDiff()
- Changed: FileSelectFolder() flag parameter changed
- Changed: REG_MULTI_SZ values allow double NULL values.
- Changed: BirOr(), BitAnd() and BitXOR() take up to 255 parameters
- Changed: Icon and windowstate options added to FileCreateShortcut()
- Changed: RunAsSet() supports extra profile handling options
- Changed: RegWrite() now accepts just the keyname in order to create a keyname with no value
- Changed: "Allow Decompilation" option added to Aut2Exe
- Changed: Aut2Exe gives feedback during compilation and gives the option to abort
- Changed: Compiled scripts run/extract much faster when using FileInstall and medium/large files
- Changed: Max number of user function limits removed
- Changed: Max number of variable limits removed
- Changed: -1 does no sleep at all for Send/Mouse delays (SendKeyDelay, etc...)
- Changed: Optional occurance parameter added to StringInStr()
- Changed: Optional default filename added to FileOpenDialog() and FileSaveDialog()
- Changed: Registry functions accept 4 letters keys (HKLM instead of HKEY_LOCAL_MACHINE, etc.)
- Changed: Remote registry keys are accepted in the form "\\computername\key\subkey"
- Changed: AutoItSetOption returns the previous setting
- Changed: (Internal)  Built-in function lookups completely rewritten
- Changed: (Internal) String functions speeded up (concat in astring and variants)
- Changed: (Internal) ControlSearch modified to include the windowsearch

- Fixed: FileGetSize() works on >2GB files and in-use files
- Fixed: The expression: If "non-blank" And 1 - now evaluates as true
- Fixed: /c command line use in compiled scripts
- Fixed: ToolTip() when the mouse is near the bottom of the screen
- Fixed: StringIsDigit()
- Fixed: Process... functions under NT4 unable to see certain processes
- Fixed: Some keywords incorrectly allowed after a THEN keyword
- Fixed: (Internal) Hotkey registering logic

3.0.101 (11th Mar, 2004) (Release)
- Added: MemGetStats()
- Fixed: Compatibility problem under Windows 95a
- Fixed: Some minor help file typos corrected

3.0.100 (29th Feb, 2004) (Release)
- Added: WinTextMatchMode (Option)
- Fixed: ExitLoop and ContinueLoop failed during a recursive function
- Fixed: Sleep(0) (or < 0 ) no longer hangs
- Fixed: $ with no name was allowed as a variable
- Fixed: For Loop bug when used in recursion
- Fixed: FileGetLongName() return value
- Fixed: @UserProfileDir under 9x
- Fixed: IsDeclared()
- Fixed: Random()

3.0.94 (21st Feb, 2004) (Beta)

SCRIPT BREAKING CHANGES for FileReadLine and FileWriteLine:

FileWriteLine now automatically writes a DOS @CRLF pair UNLESS the last character of
the string to write is already @CR or @LF (to make it possible to write non-DOS text files)

FileReadLine will correctly read a DOS, UNIX or MAC line (@CRLF, @LF and @CR terminated respectively).

FileWrite and FileRead added to add further support.

CHANGE YOUR SCRIPTS AS FOLLOWS:

From: FileWriteLine($handle, "line" & @LF)
To: FileWriteLine($handle, "line" & @CRLF) or FileWriteLine($handle, "line")

From: FileWriteLine($handle, "line")
To: FileWrite($handle, "line")

- Added: FileWrite() and FileRead()
- Changed: FileReadLine() and FileWriteLine()
- Added: ToolTip()
- Added: Eval() and IsDeclared()
- Added: CaretCoordMode (AutoItSetOption)
- Added: WinGetCaretPos()
- Added: WinGetState()
- Added: MustDeclareVars (AutoItSetOption)
- Added: Editors page in help
- Changed: EnvSet()
- Changed: WinShow() renamed to WinSetState()  (With WinShow() as an alias)
- Fixed: Splash() and moveable flag (and -1 default flag in options)
- Fixed: Odd elseif error message showing wrong line
- Fixed: Crashes with bad function calls: MsgBox(MsgBox(MsgBox))
- Fixed: HotKey crashes when unregistering a key that was not registered

- Fixed: (Internal) WinWaitDelay, SendKeyDelay, etc type commands now more accurate (previously only accurate to 10ms (NT) or 55ms (9x))
- Fixed: (Internal) Execute() recursion limit dropped to 384 levels
- FIxed: (Internal) Calls to Util_AttachThreadInput will not attach to hung windows
- Fixed: (Internal) some RegRead/RegWrite sizing problems (Ta, Chris)

3.0.93 (12th Feb, 2004)
- Added: SendAttachMode (AutoItSetOption)
- Added: Opt() is an alias for AutoItSetOption() :)
- Added: Doc updates
- Added: WinSearchChildren (AutoItSetOption)
- Changed: Splash and Progress functions have a "moveable" option
- Changed: StringStripWS (new strip all ws mode)
- Changed: InputBox (timeout param)
- Changed: Hot keys are no longer buffered when the script is paused.
- Fixed: REG_MULTI_SZ support
- Fixed: TrayIconDebug not showing correct filename
- Fixed: ControlClick, ControlCommand("CHECK")
- Fixed: Control functions now using return values rather than @error where appropriate.
- Fixed: Error with '' quotes in Aut2Exe
- Fixed: StringFormat()
- Fixed: Lexer checks that potential user function calls are for existing functions
- Fixed: Input thread attachment in Send() ( check Send("{... down}") still works)

- Changed: (Internal) Removed the only sscanf call and replaced with own code - saves 4KB.

3.0.92 (6th Feb, 2004)

Note: Script breaking changes to ControlLeftClick(), FileFindFirstFile(), SendSetCapslockState()

- Added: Dec()
- Added: BitNOT(), BitXOR(), BitShift()
- Added: TrayIconDebug (AutoItSetOption)
- Added: Dim single-line initialization and multiple variables
- Added WinTitleMatchMode 4 (AutoItSetOption)
- Added: #comments-start and #comments-end for multiline comments
- Added: DirCopy()
- Added: DirMove()
- Added: Controls will be checked by visible text as well as classname (waves to Chris :) )
- Added: Macros: @USERPROFILEDIR, @HOMEDRIVE, @HOMEPATH, @HOMESHARE, @LOGONSERVER, @LOGONDOMAIN, @LOGONDNSDOMAIN
- Removed: SendSetCapslockState() - Use Send("{CAPSLOCK on/off}")
- Changed: FileFind works differently (handles used and multiple finds now supported)
- Changed: ControlLeftClick() renamed to ControlClick() and options added.
- Changed: Window Spy options added and ability to freeze display
- Changed: StringSplit will return each char if delimiters are ""
- Changed: WinMenuSelectItem return value
- Changed: optional variation added to PixelSearch()
- Changed: optional step value added to PixelSearch()
- Changed: FileMove() overwrite flag added
- Changed: *.* assumed if a directory is used in FileCopy/FileMove/FileDelete
- Fixed: @TempDir under certain conditions
- Fixed: Hotkeys were ignored while another hotkey function was running

- Changed: (Internal) DirRemove changed
- Changed: (Internal) Sendkeys tweaked A LOT

3.0.91 (29th Jan, 2004)
- Added: Options: MouseClickDelay, MouseClickDownDelay, MouseClickDragDelay (AutoItSetOption)
- Added: REG_BINARY type for RegRead() and RegWrite()
- Added: FileChangeDir()
- Added: ControlCommand() - added GETCURRENTSELECTION
- Added: Added some standard library includes (See Program Files\AutoIt3\Include\)
- Added: SendKeyDownDelay (AutoItSetOption) (alters the amount a time a key is held down before released)
- Added: AutoIt returns an exit code of 1 if script could not be loaded
- Added: FileSetAttrib(), FileSetTime()
- Added: In Au3_Spy pixel colour is also shown in hex
- Fixed: While loops failing when used in recursive functions of themselves... (!?)
- Fixed: Small line coninuation _ bug
- Fixed: URLDownloadToFile()
- Fixed: FileRecycle() not always working
- Fixed: FileRecycle() return value
- Fixed: Relative #include use
- Fixed: Smart boolean comparision re-added
- Fixed: FileFindFirst() not releasing memory when called multiple times
- Changed: FileGetTime outputs strings with leading 0s when required
- Changed: Default value of Local/Global/Dim is the String "" (equates to 0 when used as a number)

- Changed: (Internal) More scriptfile.cpp optimization
- Changed: (Internal) Execute() recursion levels limited to 512 to prevent stack overflows

3.0.90 (20th Jan, 2004)
- Fixed: Serious nested IF bug

- Changed: (Internal) Rollback of variabletable.cpp and stacks/vectors

3.0.89 (19th Jan, 2004)
- Added: Method for standard library functions and includes
- Added: #include < > support (must be fully installed to work)
- Added: #include-once directive (put at the top of a file to make sure it is only
       included once)
- Added: @UserName and @TempDir macros
- Fixed: Nasty fatal bug in 3.0.88

3.0.88 (18th Jan, 2004)
- Added: ElseIf
- Changed: All block structures (IF/WHILE/FOR, etc.) are now checked before execution.
- Fixed: Some single hotkeys not working
- Fixed: Better detection of illegal nesting, e.g.:
         if 1 = 1
           while 1
         endif
           wend

- Changed: (Internal) lots of error checking code removed as a nice side effect of
         initial block structure checking
- Changed: (Internal) windows string functions (lstrcmp etc) moved back to C versions
         due to massive performance penalty

3.0.87 (15th Jan, 2004)
- Changed: Aut2Exe stores files it can't compress (.zip etc) rather than expanding
- Fixed: Aut2Exe crashing if FileInstall used a file less than 4 bytes
- Fixed: Aut2Exe crashing with uncompressable files
- Fixed: RegRead not working correctly with large DWORD values
- Fixed: NOT fixed when skipped during a boolean expression

- Changed: (Internal) variable_table.cpp rewritten
- Changed: (Internal) All stacks/vectors replaced with templated code

3.0.86 (12th Jan, 2004)
- Added: Enhanced boolean comparisons
- Added: Send can hold keys down, e.g. Send("{a down}") will hold the A key down (only works usefully with games)
- Fixed: 0 ^ 0 = 1
- Fixed: on_top parameter of ProgressOn()
- Fixed: No longer hanging with blank search in StringReplace()
- Fixed: Asc() giving -1 in some cases
- Fixed: Tray icon's tip not updating when un-pausing
- Changed: Single keys of 0-9, a-z can no longer be used as hotkeys if alt,ctrl or win is NOT also used.

- Changed: (Internal) FPU assembler used for advanced math (sin,cos,pow, etc) functions due to
         exe size problems under VC7

3.0.85 (9th Jan, 2004)
- Added: HotKeySet()
- Added: Abs(), Sin(), Cos(), Tan(), ASin(), ACos(), ATan(), Sqrt(), Log(), Exp()
- Added: ^ operator
- Added: Round()
- Added: Call()
- Changed: IniWrite/IniDelete() return 0 if they fail
- Changed: No longer need to use virtual keys for FileCreateShortcut()
- Fixed: Return value for FileCopy/FileInstall()
- Fixed: Incorrect use of ExitLoop/ContinueLoop trapped

- Changed: (Internal) Send() tweaking
- Fixed: (Internal) Function calling/scope slightly bugged (Adlib, Hotkey)

3.0.84 (30th Dec, 2003)
- Added: New window WinTitleMatchMode of 3 (for exact title match)
- Added: Some more details added to helpfile
- Changed: The key # is no longer used as a delimiter but as a left Win key combination.  So
           Send("#e") now presses the left win+e keys.  I don't think anyone actually used
           it as a delimiter anyway - it was just a left over from v1 and it never made
           lines easier to read anyway
- Changed: FileReadLine() and FileWriteLine() modified so that they optionally accept a filename
           instead of a filehandle for "quick 'n' dirty" file access - I'm sure this will be
           popular :)

3.0.83 (30th Dec, 2003)
- Changed: Due to popular demand, by default functions now return 0 for error and 1 for success.
           This affects the following functions: FileWriteLine, CDTray, DriveSetLabel, DirCreate,
           DirRemove, FileCopy, FileMove, FileDelete, FileInstall, ClipPut, URLDownloadToFile,
           RunAsSet, Shutdown, RegWrite, RegDelete, WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive,
           ProcessWait, ProcessWaitClose.  If you were using the return values of one of
           these functions then please check your scripts.

- Changed: ControlSend() supports {} (for most things at least...)

3.0.82 (29th Dec, 2003)
- Added: Files installed with FileInstall() now have original timestamps (created/modified)
- Added: IsNumber()
- Fixed: Number to string conversions and general float parsing

- Changed: (Internal) FileInstall() compression code updated

3.0.81
- Fixed: Yet more bugs with single line IF - regretting adding this feature already...
- Fixed: Bugs with NOT operator and the new variant code
- Fixed: Bug with clicking CANCEL on the open script window (introduced in 3.0.80)
- Fixed: StringIs... functions failing when using numbers as parameters

- Fixed: (Internal) VectorVariant modified to allow reference access to variants (instead of copying everytime)

3.0.80 (15th Dec, 2003)
- Changed: Number to String conversions tweaked
- Fixed: Massive bug fixed with arrays introduced in 3.0.76
- Fixed: Line continuation crash

- Changed: (Internal) script reading code updated for Aut2Exe and merged with AutoIt

3.0.79 (15th Dec, 2003)
- Added: Lines can be continued over many lines - use _ at the end of a line to continue it (as VBScript)
- Added: Single line IF statements possible
- Changed: Maximum line length (including total of combined lines) increased from 1023 to 4095 characters.
- Changed: "Then" keyword in IF statements no longer optional (helps with single line IFs)

e.g.
MsgBox(0, "Test", "This is some text _
    And more text _
    And even more text")

3.0.78 (15th Dec, 2003)
- Changed: Variants work differently - no longer a seperate INTEGER type
- Changed: Float() changed to Number()

    All numbers now 15digit precision (internal C double type)
    Also affects Random() you will get floating point numbers back unless you use Int()
        with the result

3.0.77 (30th Nov, 2003)
- Added: New option "TrayIconHide" (AutoItSetOption)
- Changed: "AutoIt -" prefix removed from compiled a script's tray icon
- Changed: Compiled script's file properties point to a custom web page
- Fixed: Tray icon should redraw after an explorer crash

3.0.76 (30th Nov, 2003)
- Fixed: Couple of bugs with ContinueLoop and ExitLoop
- Fixed: Statements like $test[$test[0]] now working

3.0.75 (30th Nov, 2003)
- Added: ControlGetFocus()
- Added: Local and Global keywords
- Changed: Dim (along with Local/Global) can now be used as in vbscript to declare variables
- Changed: FileOpenDialog() uses "|" as the delimiter instead of ","
- Fixed: PixelSearch()
- Fixed: SoundPlay()...maybe
- Fixed: Splash() sizing issues

3.0.74
- Added: Hex notation for integer numbers ($var = 10 or $var = 0xa)
- Added: MouseDown(), MouseUp()
- Added: TrayTip()
- Fixed: PixelCoordMode not working correctly
- Fixed: Compiled exes not producing random numbers

3.0.73
- Added: New option "RunErrorsFatal" (AutoItSetOption)
- Added: New option "ExpandEnvStrings" (AutoItSetOption)
- Changed: FileMove() moves/renames without affecting timestamps - can also be used
           for directories
- Changed: RegRead/RegWrite() now supports REG_EXPAND_SZ
- Changed: Extra options added to FileGetTime()
- Changed: Extra 250ms delay added to start and end of mouse drags
- Fixed: Odd error message fixed where a user function contained a badly formatted line

3.0.72
- Fixed: Compiler was ignoring comments near FileInstall() functions
- Fixed: Memory leak in StatusBarGetText()
- Fixed: PixelGetColor
- Added: New option "PixelCoordMode" (AutoItSetOption)

3.0.71
  Get ready for some script rewriting...*holds up banner with BETA written on it :) *

- Added: ControlSend()
- Added: Framework for AutoItSetOption() - note: this function replaces all
         functions like WinSetDelay, SendSetDelay, MouseSetMode, etc.
- Removed: MouseSetMode(), SendSetCapslockMode(), SendSetDelay(), WinSetDelay(), WinSetDetectHiddenText()
           WinSetTitleMatchMode()

3.0.70
- Fixed: SoundPlay()
- Removed: AutoItWinShow(), AutoItWinWrite(), AutoItWinGetText()
- Changed: ControlCommand() (updated with Larry's recent changes)
- Changed: RegRead() extended error codes
- Added: FileFindFirstFile(), FileFindNextFile()
- Added: AutoItWinGetTitle()
- Added: WinGetClientSize()
- Added: EnvUpdate()
- Added: SoundSetWaveVolume()
- Added: FileGetLongName(), FileGetShortName()
- Added: TimerStart(), TimerStop()

3.0.69
- Fixed: Small delay added into mouseclick functions
- Fixed: FileGetVersion()
- Fixed: WinMenuSelectItem()
- Fixed: StringSplit() buffer overrun

3.0.68
- Added: FileGetAttrib(), WinMenuSelectItem(), FileGetVersion()
- Added: Added options to ControlCommand()

- Changed: (Internal) Larry's nFlag functions split

3.0.67
- Changed: InputBox() narrowed slightly
- Fixed: AutoIt icon not refreshing if Return was used at top level of script
- Fixed: Crash with extra long lines fixed
- Fixed: @OS_VERSION weirdness fixed

- Changed: (Internal) MessagePump handled differently and recursion level of Execute() tracked

3.0.66
- Changed: StringSplit() returns full string in array if no delimiters matched (and count=1 not 0)
- Fixed: Crash related to window titles and text fixed.

3.0.65
- Added: ControlCommand() option GetCurrentLine
- Fixed: Possible bug with optional "Then" statement fixed
- (Internal) Window searching functions altered to check for hung windows

3.0.64
Fixed: IniWrite/Delete() functions were not flushing immediately under 9x.
Added: Errors now include the file name that contained the error

3.0.63
- Changed: ControlCommand() various internal changes.
- Fixed: MsgBox() character limit bug fixed
- Changed: Can now specify a custom time for AdlibEnable()

3.0.62
- Fixed: Aut2Exe icon changing code bugged
- Changed: Timing of "paused" flash and icon modified a little.

3.0.61
- Fixed: FileOpenDialog()
- Changed: (Internal)Encryption code modified - check compiling thoroughly
- Added: AutoIt icon flashes when in paused state

3.0.60
- Changed: Aut2Exe strips version info from compiled script. (Hoping to be custom versioninfo in future)
- Fixed: FileGetSize() (change made, unsure if problem fixed)
- Fixed: FileMove wasn't supported on 9x (9x has no MoveFileEx function, Dave... :) )

3.0.59
- Fixed: InputBox was not returning "" on cancel

3.0.58
- Fixed: The window text searching in AutoIt was not the same as AU3_Spy or WinGetText()
- Added: InputBox() (and very nice it is too...)
- Added: FileMove()

3.0.57
- Fixed: MsgBox under 9x was doing odd things with timeouts - tried something else.

3.0.56
- Fixed: Selecting the default icon in Aut2Exe was not saved between sessions
- Fixed: @OSLang under NT4...
- Added: SysTabControl32 tabbing

3.0.55
- Changed: Better icon support added to Aut2Exe
- Changed: (Internal) upx.exe called during the compiler to compress data -
    necessary to do it this way as you can't edit the resources of a compressed
    exe
- Changed: SoundPlay()

3.0.54
- Fixed: Compiled scripts with custom icons were failing
- Fixed: @OS_LANG under 9x

3.0.53
- Added: StringSplit()

3.0.52
- Changed: SoundPlay() option to wait added
- Added: ChangeIcon support back in Aut2Exe (32x32x16) - Slightly better than v2 in that
        a multiimage iconfile can be used - although only the 32x32x16 image is actually used.

3.0.51
- Fixed: Aut2Exe still used ' comments when including files -whoops.

3.0.50
- Changed: (Internal)A little error checking added to the lexer
- Added: @TAB, @COMSPEC
- Changed: MouseClick() parameters changed
- Added: MouseClickDrag()

3.0.49
- Fixed: Statusbar in Aut2Exe with Visual Styles
- Changed: Single line comment character is now ;
- Changed: ' and " may now be used for strings

3.0.48
- Added: StringIsFloat(), StringIsInt()
- Fixed: MsgBox() wasn't returning -1 on timeout
- Fixed: StringReplace() error if string to replace was at end of string
- Changed: StringReplace() count is now optional (assumes global)
- Added: Aut2Exe and AutoIt3 now use Visual Styles

3.0.47
- Changed: FileExists() to work with wildcards
- Changed: Extra options added to AutoItWinShow()
- Changed: RegRead returns the string "" in addition to @error if the (default) key was requested
    and not found.
- Fixed: DriveGetDrive()  (still an a: drive bug to find though)

3.0.46
- Fixed: RegDelete() return value when value does not exist
- Fixed: CDTray() open/closed problems
- Fixed: FileSelectFolder() crash due to missing initialisers

3.0.45
- Changed: Set...() functions renamed (SendSetDelay, WinSetDelay, etc.)
- Added: StatusbarGetText()

3.0.44
- Added: Break()
- Fixed: DriveStatus()
- Fixed: RegDelete()

3.0.43
- Fixed: @OSLang for 2000+
- Added: Hex(), AutoItWinGetText()
- Changed: UBound() back to how it was again (same as VBScript syntax)

3.0.42 (30th Aug, 2003)
- Tweaked: Mouse coords were 1 pixel out
- Added: MouseSetMode() to allow for screen _and_ relative coords - yay everyone's happy

3.0.41 (30th Aug, 2003)
- Fixed: Bug with invalid filehandles (again!).
- Changed: Mouse commands may now work on multiple monitors.
- Fixed: $CmdLine wasn't working correctly for compiled scripts.
- Fixed: The operator == wasn't properly comparing strings
- Fixed: INI functions, filename now doesn't need ".\file.ini" to work in the current directory
- Fixed: Bug in Run() directory would not be set if last parameter was used

3.0.40
- Added: Windows API error messages added onto errors for the Run() commands
    (directory invalid, bad logon, etc).

3.0.39 (29th Aug, 2003)
- Added: RunAsSet() (2000/XP only)
- Added: FileRecycle()

3.0.38 (28th Aug, 2003)
- Changed: WinGetText now correctly takes note of detecthiddentext setting
- Added: StringStripWS()
- Added: DriveGetLabel(), DriveGetSerial(), DriveGetFileSystem(),
        DriveSetLabel(), DriveGetType(), MouseGetCursor()

3.0.37
- Changed: Compression tweaked in Aut2Exe

- Changed: UBound($array) now returns number of dimensions
- Renamed all the IsUpper/IsAlpha, etc functions to StringIsUpper/StringIsAlpha, etc.
- Added: IsFloat(), IsArray(), IsInt(), IsString()
- Added: Mod()

3.0.36
- Fixed: Main dialog in Aut2Exe
- Added: New compression code (slower but better at higher levels)

3.0.35
- Added: FileInstall() support
- Added: SplashImageOn(), SplashTestOn(), SplashOff()
- Added: ProgressOn(), ProgressOff(), ProgressSet()
- Added: Compression level option in Aut2Exe

3.0.34
- Fixed: subscript must be > 0 in Dim statement
- Added: Compiled script reading code added
- Added: @Compiled
- Added: Aut2Exe

3.0.33 (22nd Aug, 2003)
- Added: Case Else
- Added: @DesktopWidth, @DesktopHeight
- Fixed: CDTray - closed/close
- Fixed: Incorrect reference passing of global variables
- Fixed: Bad file handle causing a crash in FileWrite/Read/Close
- Fixed: Crash with badly formatted Func statements
- Parsing speeded up (doubled the speed)
- Optimized string handling in variants

3.0.32 (20th Aug, 2003)
- Started proper version logging :)

First public beta binary - 4th Mar, 2003.

Development started - 20th Jan, 2003.


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip® 9.0 SR-1 Setup
Class:	#32770
Size:	X: 493    Y: 455    W: 413    H: 139

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Setup
Cancel
&Info...
Thank you for your interest in WinZip!

Click the "Setup" button to install WinZip 9.0 SR-1.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 540    Y: 425    W: 320    H: 199

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
Setup will install WinZip into the following folder, which it will create if necessary.
If you want to install WinZip in a different folder and/or drive, type the name of the folder below:
&Install to:
C:\Program Files\WinZip
&Browse...
OK
Cancel

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
&Next >
Close
Thank you for installing WinZip!
WinZip features include:

* Quick and easy zip and unzip
* Optional Wizard interface
* E-mail support, including Zip and E-Mail from Explorer
* Tight integration with the Windows shell
* Internet file format support, including MIME, TAR, & CAB
* 128-bit and 256-bit AES encryption

Press the F1 key on your keyboard at any time while running WinZip for context sensitive help and complete documentation.

Click Next to continue.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	License Agreement and Warranty Disclaimer
Class:	#32770
Size:	X: 473    Y: 368    W: 452    H: 279

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
As with other software, WinZip is subject to WARRANTY DISCLAIMERS and
LIABILITY LIMITATIONS, including (but not limited to) the following:
THIS SOFTWARE, AND ALL ACCOMPANYING FILES, DATA AND MATERIALS, ARE
DISTRIBUTED "AS IS", and ANY LIABILITY OF WINZIP COMPUTING, INC. (WCI)
WILL BE LIMITED EXCLUSIVELY TO REFUND OF THE LICENSE FEE PAID TO WCI.
In addition, this version of WinZip is subject to the complete
WinZip License Agreement, which you can view by clicking on the
"View License Agreement" button now.
I agree that by clicking on the "Yes" button below (or otherwise installing
or using WinZip), I accept all terms of the License Agreement, and that I
have read the License Agreement.
&Yes
&No
&View License Agreement

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
&Next >
Close
WinZip Quick Start
For helpful information on installing and using WinZip, print a copy of the "WinZip Quick Start Guide." Click "Print Quick Start".

To see the Guide without printing it, click "View Quick Start".
You can also view or print the Quick Start Guide later by choosing Quick Start from the WinZip Help Contents.

Click Next when you are ready to continue.
&Print Quick Start
&View Quick Start

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
&Next >
Close
Choose "Classic" or "Wizard", then click "Next"
You can start with the "Classic" or "Wizard" interface.  It is easy to switch between the two interfaces, and you can always change the default later.
WinZip Classic is the more powerful of the two interfaces and is recommended if you are comfortable with Windows and Zip files. Most WinZip users choose this interface.
The WinZip Wizard automates the most common tasks involving Zip files and is most useful for users who are new to Windows and Zip files.
Start with WinZip &Classic
&Start with the WinZip Wizard

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
&Next >
Close
Click "Next" to continue.
&Express setup (recommended)
&Custom setup (for advanced users)
Express Setup associates WinZip with archives, creates a program group, and puts WinZip icons on the desktop and Start menu.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
&Next >
Close
WinZip needs to associate itself with your archives.
Associations allow WinZip to be used to open archives from My Computer, Windows Explorer, etc.
Click "Next" to associate WinZip with all supported archive types.  Click "Associations" if you want more information or would like to specify the archive types with which WinZip is associated.
&Associations...

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip Setup
Class:	#32770
Size:	X: 464    Y: 341    W: 471    H: 333

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
&Help
< &Back
Finish
Close
Thank you for installing this evaluation version.
New WinZip Users:

For a quick introduction to WinZip select "Brief Tutorial" from the "Help" pull-down menu at any time or press the F1 key now.

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<
&WinZip Classic


>>>>>>>>>>>> Window Details <<<<<<<<<<<<<
Title:	WinZip (Evaluation Version)
Class:	WinZipWClass
Size:	X: 417    Y: 334    W: 566    H: 347

>>>>>>>>>>> Visible Window Text <<<<<<<<<<<
Choose "New" to create or "Open" to open an archive
ListView

>>>>>>>>>>> Hidden Window Text <<<<<<<<<<<


; Run the winzip installer
Run("winzip90.exe")

; Initial Setup Screen
WinWaitActive("WinZip® 9.0 SR-1 Setup", "&Setup")
Send("!s")

; Install location
WinWaitActive("WinZip Setup", "into the following folder")
Send("{ENTER}")

; Features overview
WinWaitActive("WinZip Setup", "WinZip features include")
Send("!n")

; License agreement
WinWaitActive("License Agreement")
Send("!y")

; Quick start
WinWaitActive("WinZip Setup", "Quick Start Guide")
Send("!n")

; Choose interface
WinWaitActive("WinZip Setup", "switch between the two interfaces")
Send("!c")
Send("!n")

; Installation type (custom/express)
WinWaitActive("WinZip Setup", "&Express setup (recommended)")
Send("!e")
Send("!n")

; Select file associations
WinWaitActive("WinZip Setup", "WinZip needs to associate itself with your archives")
Send("!n")

; Completed installation screen
WinWaitActive("WinZip Setup", "Thank you for installing this evaluation version")
Send("{ENTER}")

; Wait for winzip to load then close it
WinWaitActive("WinZip (Evaluation Version)")
WinClose("WinZip (Evaluation Version)")