AutoIt

'X'

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

AutoItX is a DLL version of AutoIt v3 that provides a subset of the features of AutoIt via an ActiveX/COM and DLL interface. This means that you can add AutoIt-like features to your favourite scripting and programming languages, e.g. VB, VBScript, Delphi, C, C++, Kixtart, and most other languages that support the use of DLLs.

As AutoItX provides a subset of the features of AutoIt v3 you should read the help file for AutoIt v3 and become familar with the basic concepts, including:

  • The AutoIt Window Info Tool
  • Windows
  • Controls

Help pages on the above topics are duplicated in this help file for reference.

The original version of AutoIt came with two controls: AutoItX (a COM/ActiveX control) and AutoItDLL (a DLL control). In this new version both the COM and DLL versions have been combined into the single AutoItX control which provides both methods of access.

How you use AutoItX depends on the host language you want to use. If you are using something that supports COM object access (like VBScript) then using AutoItX as a COM control is recommended. If you want to use AutoItX from a language such as C then using it as a DLL is simplest.

Throughout this help file examples for COM/ActiveX usage are given using VBScript, and standard DLL usage using C/C++. These are expected to be the most common ways of using AutoItX (and the two that I am most familiar with). Users of other languages should check out the AutoItX section on the AutoIt Forum for help and advice should you need it.


License

Software License

AutoItX 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 applications that utilize 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.


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:

oAutoIt.WinWaitActive "Untitled - Notepad"

and

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

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

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

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

"handle=winhandle"

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

oAutoIt.AutoItSetOption "WinTitleMatchMode", 4

oAutoIt.WinWaitActive "Untitled - Notepad"

oAutoIt.WinClose "last" ' Closes the previously matched notepad window

 Note: If "classname=", "handle=", "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.


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

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.

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


Using the COM Interface

Before you can use the COM interface to AutoItX it needs to be "registered" (This is done automatically when you install the full version of AutoIt but you may need to do it manually if you are using AutoItX seperately).

To register the COM interface:

1. Open a command prompt

2. Change directory (using CD) to the directory that contains AutoItX3.dll

3. Type regsvr32.exe AutoItX3.dll and press enter

The name of the AutoItX control is AutoItX3.Control

Here is an example of calling a the Run method of the control from VBScript:

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.Run("notepad.exe")


Methods

Method Reference

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

Method | Description
AutoItSetOption | Changes the operation of various AutoIt functions/parameters.
BlockInput | Disable/enable the mouse and keyboard.
CDTray | Opens or closes the CD tray.
ClipGet | Retrieves text from the clipboard.
ClipPut | Writes text to the clipboard.
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.
ControlGetPosHeight | Retrieves the position and size of a control relative to it's window.
ControlGetPosWidth | Retrieves the position and size of a control relative to it's window.
ControlGetPosX | Retrieves the position and size of a control relative to it's window.
ControlGetPosY | 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.
DriveMapAdd | Maps a network drive.
DriveMapDel | Disconnects a network drive.
DriveMapGet | Retreives the details of a mapped drive.
IniDelete | Deletes a value from a standard format .ini file.
IniRead | Reads a value from a standard format .ini file.
IniWrite | Writes a value to a standard format .ini file.
IsAdmin | Checks if the current user has administrator privileges.
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.
MouseGetPosX | Retrieves the current X position of the mouse cursor.
MouseGetPosY | Retrieves the current Y 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.
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.
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.
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.
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.
Shutdown | Shuts down the system.
Sleep | Pause script execution.
StatusbarGetText | Retrieves the text from a standard status bar control.
ToolTip | Creates a tooltip anywhere on the screen.
URLDownloadToFile | Downloads a file from the internet.
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.
WinGetCaretPosX | Returns the coordinates of the caret in the foreground window
WinGetCaretPosY | Returns the coordinates of the caret in the foreground window
WinGetClassList | Retrieves the classes from a window.
WinGetClientSizeHeight | Retrieves the size of a given window's client area.
WinGetClientSizeWidth | Retrieves the size of a given window's client area.
WinGetHandle | Retrieves the internal handle of a window.
WinGetPosHeight | Retrieves the position and size of a given window.
WinGetPosWidth | Retrieves the position and size of a given window.
WinGetPosX | Retrieves the position and size of a given window.
WinGetPosY | 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.
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.


Method ClipGet

Method Reference (COM)

ClipGet

Retrieves text from the clipboard.

ClipGet

Parameters

None.

Return Value

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

Remarks

None.

Related

ClipPut

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

text = oAutoIt.ClipGet()
WScript.Echo "Clipboard contains:" & text


Method ClipPut

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ClipPut "I am copied to the clipboard"


Method DriveMapAdd

Method Reference (COM)

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 oAutoIt.error (see below). (See Remarks)

Remarks

When the function fails (returns 0) oAutoIt.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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' Map X drive to \\myserver\stuff using current user
oAutoIt.DriveMapAdd "X:", "\\myserver\stuff"

' Map X drive to \\myserver2\stuff2 using the user "jon" from "domainx" with password "tickle"
oAutoIt.Drivemap "X:", "\\myserver2\stuff2", 0, "domainx\jon", "tickle"


Method DriveMapDel

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' Map X drive to \\myserver\stuff using current user
oAutoIt.DriveMapAdd "X:", "\\myserver\stuff"

' Disconnect
oAutoIt.DriveMapDel "X:"


Method DriveMapGet

Method Reference (COM)

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 oAutoIt.error to 1.

Remarks

None.

Related

DriveMapAdd, DriveMapDel

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' Map X drive to \\myserver\stuff using current user
oAutoIt.DriveMapAdd "X:", "\\myserver\stuff"

' Get details of the mapping
WScript.Echo "Drive X: is mapped to " & DriveMapGet("X:")


Method IniDelete

Method Reference (COM)

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. If no key name is 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

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.IniDelete "C:\Temp\myfile.ini", "section2", "key"


Method IniRead

Method Reference (COM)

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

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
var = IniRead "C:\Temp\myfile.ini", "section2", "key", "NotFound"
WScript.Echo "Result: " & var


Method IniWrite

Method Reference (COM)

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

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.IniWrite "C:\Temp\myfile.ini", "section2", "key", "this is a new value"


Method AutoItSetOption

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oldvalue = oAutoIt.Opt("SendAttachMode", 0)


Method PixelChecksum

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' Get initial checksum
checksum = oAutoIt.PixelChecksum(0,0, 50,50)


Method PixelGetColor

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
var = oAutoIt.PixelGetColor( 10 , 100 )
WScript.Echo "The color is" & var


Method PixelSearch

Method Reference (COM)

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 string containing the pixel's coordinates in the format "x,y"
Failure: | Sets oAutoIt.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


Method Send

Method Reference (COM)

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.

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 65}")

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

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.Send "#r"
oAutoIt.WinWaitActive "Run"
oAutoIt.Send "notepad.exe{Enter}"
oAutoIt.WinWaitActive "Untitled -"
oAutoIt.Send "Today's time/date is {F5}"


Method ToolTip

Method Reference (COM)

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 | 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 a linefeed character to create multi-line tooltips.

Related

TrayTip

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' This will create a tooltip in the upper left of the screen
oAutoIt.ToolTip "This is a tooltip", 0, 0
oAutoIt.Sleep 2000 ' Sleep to give tooltip time to display


Method BlockInput

Method Reference (COM)

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/XP | User input is blocked and AutoIt can simulate most input.

Note that functions such as WinMove() will still work on Windows 98/Me when BlockInput is enabled.

Related

Send

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

oAutoIt.BlockInput 1

oAutoIt.Run "notepad.exe"
oAutoIt.WinWaitActive "Untitled - Notepad"
oAutoIt.Send "{F5}"

oAutoIt.BlockInput 0


Method CDTray

Method Reference (COM)

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:
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.CDTray "E:", "open"


Method IsAdmin

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

If oAutoIt.IsAdmin Then WScript.Echo "Admin rights detected"


Method URLDownloadToFile

Method Reference (COM)

URLDownloadToFile

Downloads a file from the internet.

URLDownloadToFile ( "URL", "filename" )

Parameters

URL | URL of the file to download.
valuename | Filename to download to.

Return Value

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

Remarks

Internet Explorer 3 or greater must be installed for this function to work. Firewalls or presence of multiple network adapters may cause this function to fail. Also, some websites may block such downloads.

The file is obtained from IE cache whenever possible. You might be able to force a (re)download from the internet by supplying a fake cgi parameter, for example: "http://.../test.exe?fakeParam=42"

Related

None.

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.URLDownloadToFile "http://www.mozilla.org", "C:\foo.html"
oAutoIt.URLDownloadToFile "http://www.hiddensoft.com", "C:\mydownload.htm"


Method MouseClick

Method Reference (COM)

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 oAutoIt.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, MouseGetPosX, MouseGetPosY, MouseMove, MouseCoordMode (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' Double click at the current mouse pos
oAutoIt.MouseClick "left"
oAutoIt.MouseClick "left"

' Double click at 0,500
oAutoIt.MouseClick "left", 0, 500, 2


Method MouseClickDrag

Method Reference (COM)

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 oAutoIt.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, MouseGetPosX, MouseGetPosY, MouseMove, MouseCoordMode (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' Left click drag from 0,200 to 600, 700
oAutoIt.MouseClickDrag "left", 0, 200, 600, 700


Method MouseDown

Method Reference (COM)

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, MouseGetPosX, MouseGetPosY, MouseMove, MouseCoordMode (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

oAutoIt.MouseDown "left"
oAutoIt.Sleep 100
oAutoIt.MouseUp "left"


Method MouseGetCursor

Method Reference (COM)

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

MouseGetPosX, MouseGetPosY

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

oAutoIt.Sleep 2000 'allow time to move mouse before reporting ID
cursor = MouseGetCursor()
WScript.Echo "ID = " & cursor


Method MouseGetPosX

Method Reference (COM)

MouseGetPosX

Retrieves the current X position of the mouse cursor.

MouseGetPosX

Parameters

None.

Return Value

Returns the current X position of the mouse cursor.

Remarks

See MouseCoordMode for relative/absolute position settings. If relative positioning, numbers may be negative.

Related

MouseClick, MouseClickDrag, MouseGetPosY, MouseMove, MouseCoordMode (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

posx = oAutoIt.MouseGetPosX()
posy = oAutoIt.MouseGetPosX()

WScript.Echo "Mouse x,y:" & posx & "," & posy


Method MouseGetPosY

Method Reference (COM)

MouseGetPosY

Retrieves the current Y position of the mouse cursor.

MouseGetPosY

Parameters

None.

Return Value

Returns the current Y position of the mouse cursor.

Remarks

See MouseCoordMode for relative/absolute position settings. If relative positioning, numbers may be negative.

Related

MouseClick, MouseClickDrag, MouseGetPosX, MouseMove, MouseCoordMode (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

posx = oAutoIt.MouseGetPosX()
posy = oAutoIt.MouseGetPosX()

WScript.Echo "Mouse x,y:" & posx & "," & posy


Method MouseMove

Method Reference (COM)

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, MouseGetPosX, MouseGetPosY, MouseCoordMode (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

oAutoIt.MouseMove 10, 100
oAutoIt.MouseMove 700, 700, 0


Method MouseUp

Method Reference (COM)

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, MouseGetPosX, MouseGetPosY, MouseMove, MouseCoordMode (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

oAutoIt.MouseDown "left"
oAutoIt.Sleep 100
oAutoIt.MouseUp "left"


Method MouseWheel

Method Reference (COM)

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, oAutoIt.error is set to 1.

This function only works on NT, 2000, XP and later operating systems.

Related

MouseClick, MouseClickDrag, MouseGetPosX, MouseGetPosY, MouseMove, MouseCoordMode (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' Move the wheel up 10 times
oAutoIt.MouseWheel "up", 10


Method ProcessClose

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ProcessClose "notepad.exe"

PID = oAutoIt.ProcessExists("notepad.exe")
oAutoIt.ProcessClose(PID)


Method ProcessExists

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
If ProcessExists("notepad.exe") Then
WScript.Echo "Notepad is running."
End If


Method ProcessSetPriority

Method Reference (COM)

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 oAutoIt.error to 1. May set oAutoIt.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 oAutoIt.error will be set to 2.

Related

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.Run "Notepad.exe"
oAutoIt.ProcessSetPriority "notepad.exe", 0
' Notepad should now have Idle/Low priority


Method ProcessWait

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ProcessWait "notepad.exe"


Method ProcessWaitClose

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

'waits until no instance of notepad.exe exists
oAutoIt.ProcessWaitClose "notepad.exe"

' This will wait until this particular instance of notepad has exited
PID = oAutoIt.Run("notepad.exe")
oAutoIt.ProcessWaitClose(PID)


Method Run

Method Reference (COM)

Run

Runs an external program.

Run "filename" [, "workingdir" [, flag]]

Parameters

filename | The 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: see Remarks.

Remarks

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.

The error property is set to 1 as an indication of failure.

Related

RunAsSet, RunWait

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.Run "Notepad.exe", "", oAutoIt.SW_MAXIMIZE


Method RunAsSet

Method Reference (COM)

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 | The user name to use.
domain | The domain name to use.
password | 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

RunAsSet, RunWait

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' Set the RunAs parameters to use local adminstrator account
oAutoIt.RunAsSet "Administrator", "MyDom", "adminpassword"

' Run registry editor as admin
oAutoIt.RunWait "regedit.exe"

' Reset user's permissions
oAutoIt.RunAsSet


Method RunWait

Method Reference (COM)

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: | see Remarks.

Remarks

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.

The error property is set to 1 as an indication of failure.

Related

ProcessWait, ProcessWaitClose, RunAsSet, RunWait

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
val = oAutoIt.RunWait("Notepad.exe", "C:\WINDOWS", oAutoIt.SW_MAXIMIZE)

' script waits until Notepad closes
WScript.Echo "Program returned with exit code:" & val


Method Shutdown

Method Reference (COM)

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

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 can be achieved with third-party software such as http://grc.com/wizmo/wizmo.htm

Related

ProcessClose

Example

' Force a reboot
Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.Shutdown 6


Method RegDelete

Method Reference (COM)

RegDelete

Deletes a key or value from the registry.

RegDelete "keyname" [, "valuename"]

Parameters

keyname | The registry key to write to.
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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.RegDelete "HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey"


Method RegEnumKey

Method Reference (COM)

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

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
var = oAutoIt.RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE", 1)
WScript.Echo "First SubKey under HKLM\Software: " & var
$var = RegEnumKey("HKEY_LOCAL_MACHINE\SOFTWARE", 2)
WScript.Echo "Second SubKey under HKLM\Software: " & var


Method RegEnumVal

Method Reference (COM)

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

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
var = oAutoIt.RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\HiddenSoft\AutoIt3", 1)
WScript.Echo "First Value Name under in AutoIt3 key" & var
var = oAutoIt.RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\HiddenSoft\AutoIt3", 2)
WScript.Echo "Second Value Name under in AutoIt3 key: " & var


Method RegRead

Method Reference (COM)

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 numeric 1 and sets the oAutoIt.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 a linefeed character.

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
var = oAutoIt.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion", "ProgramFilesDir")
WScript.Echo "Program files are in:" & var


Method RegWrite

Method Reference (COM)

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 | The valuename to write to.
type | Type of key to write: "REG_SZ", "REG_MULTI_SZ", "REG_EXPAND_SZ", "REG_DWORD", or "REG_BINARY".
value | 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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' Write a single REG_SZ value
oAutoIt.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_SZ", "Hello this is a test"

' Write the REG_MULTI_SZ value of "line1" and "line2"
oAutoIt.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_MULTI_SZ", "line1" & @LF & "line2"

' INCORRECT uses of REG_MULTI_SZ
oAutoIt.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_MULTI_SZ", "line1" & @LF & "line2" & @LF
oAutoIt.RegWrite "HKEY_LOCAL_MACHINE\SOFTWARE", "TestKey", "REG_MULTI_SZ", "line1" & @LF & @LF & "line2" & @LF


Method Sleep

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.Sleep 5000 'five seconds


Method ControlClick

Method Reference (COM)

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.
When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlClick "Untitled -", "", "MDIClient1"


Method ControlCommand

Method Reference (COM)

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), oAutoIt.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.
When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2". Use AU3_Spy.exe to obtain a control's number.

When using text instead of ClassName# in "Control" commands, be sure to use the entire text of the control. Partial text will fail.

Related

ControlDisable, ControlEnable, ControlFocus, ControlGetPos, ControlGetText, ControlHide, ControlClick, ControlMove, ControlSetText, ControlShow, StatusbarGetText, WinMenuSelectItem, WinGetClassList

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlCommand "Untitled - Notepad", "", "Edit1", "GetLineCount", ""


Method ControlDisable

Method Reference (COM)

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

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlEnable, ControlHide, ControlCommand

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlDisable "Untitled -", "", "MDIClient1"


Method ControlEnable

Method Reference (COM)

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

Use with caution.
When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlDisable, ControlShow, ControlCommand

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlEnable "Untitled -", "", "MDIClient1"


Method ControlFocus

Method Reference (COM)

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

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlCommand, WinActivate

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlFocus "Untitled - Notepad", "", "Edit1"


Method ControlGetFocus

Method Reference (COM)

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 ControlRef# of the control that has keyboard focus within a specified window.
Failure: | Returns a blank string and sets oAutoIt.error to 1 if window is not found.

Remarks

None.

Related

ControlFocus, ControlCommand, WinActive

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
a = oAutoIt.ControlGetFocus("Untitled - Notepad")


Method ControlGetHandle

Method Reference (COM)

ControlGetHandle

Retrieves the internal handle of a control.

ControlGetHandle "title", "text", "controlID"

Parameters

title | The title of the window to read.
text | The text of the window to read.
controlID | The control to interact with. See Controls.

Return Value

Success: | Returns a string containing the control handle value.
Failure: | Returns "" (blank string) and sets oAutoIt.error to 1 if no window matches the criteria.

Remarks

None.

Related

WinTitleMatchMode (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
handle = oAutoIt.ControlGetHandle("Untitled - Notepad", "", "Edit1")


Method ControlGetPosX

Method Reference (COM)

ControlGetPosX

Retrieves the position and size of a control relative to it's window.

ControlGetPosX "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 X coordinate of the control.
Failure: | Sets oAutoIt.error to 1.

Remarks

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlCommand, ControlGetPosHeight, ControlGetPosWidth, ControlGetPosY, ControlMove, WinMove

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

posx = ControlGetPosX("Untitled - Notepad", "", "Edit1")
posy = ControlGetPosY("Untitled - Notepad", "", "Edit1")
poswidth = ControlGetPosWidth("Untitled - Notepad", "", "Edit1")
posheight = ControlGetPosHeight("Untitled - Notepad", "", "Edit1")


Method ControlGetPosY

Method Reference (COM)

ControlGetPosY

Retrieves the position and size of a control relative to it's window.

ControlGetPosY "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 Y coordinate of the control.
Failure: | Sets oAutoIt.error to 1.

Remarks

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlCommand, ControlGetPosHeight, ControlGetPosWidth, ControlGetPosX, ControlMove, WinMove

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

posx = ControlGetPosX("Untitled - Notepad", "", "Edit1")
posy = ControlGetPosY("Untitled - Notepad", "", "Edit1")
poswidth = ControlGetPosWidth("Untitled - Notepad", "", "Edit1")
posheight = ControlGetPosHeight("Untitled - Notepad", "", "Edit1")


Method ControlGetPosWidth

Method Reference (COM)

ControlGetPosWidth

Retrieves the position and size of a control relative to it's window.

ControlGetPosWidth "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 width of the control.
Failure: | Sets oAutoIt.error to 1.

Remarks

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlCommand, ControlGetPosHeight, ControlGetPosX, ControlGetPosY, ControlMove, WinMove

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

posx = ControlGetPosX("Untitled - Notepad", "", "Edit1")
posy = ControlGetPosY("Untitled - Notepad", "", "Edit1")
poswidth = ControlGetPosWidth("Untitled - Notepad", "", "Edit1")
posheight = ControlGetPosHeight("Untitled - Notepad", "", "Edit1")


Method ControlGetPosHeight

Method Reference (COM)

ControlGetPosHeight

Retrieves the position and size of a control relative to it's window.

ControlGetPosHeight "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 height of the control.
Failure: | Sets oAutoIt.error to 1.

Remarks

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlCommand, ControlGetPosWidth, ControlGetPosX, ControlGetPosY, ControlMove, WinMove

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

posx = ControlGetPosX("Untitled - Notepad", "", "Edit1")
posy = ControlGetPosY("Untitled - Notepad", "", "Edit1")
poswidth = ControlGetPosWidth("Untitled - Notepad", "", "Edit1")
posheight = ControlGetPosHeight("Untitled - Notepad", "", "Edit1")


Method ControlGetText

Method Reference (COM)

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 oAutoIt.error to 1 and returns a blank string of "".

Remarks

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

WinGetText, StatusbarGetText, ControlSetText, ControlCommand

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
var = oAutoIt.ControlGetText("Untitled - Notepad", "", "Edit1")


Method ControlHide

Method Reference (COM)

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

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlShow, ControlCommand, WinSetState

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlHide "Untitled -", "", "MDIClient1"


Method ControlListView

Method Reference (COM)

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 | Additional parameter required by some commands; use "" if parameter is not required.
option2 | 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 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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlListView "C:\Program Files\NSIS", "", "SysListView321", "SelectAll", "", ""
oAutoIt.ControlListView "C:\Program Files\NSIS", "", "SysListView321", "Deselect", "2", "5"


Method ControlMove

Method Reference (COM)

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

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlCommand, WinMove

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlMove "Untitled -", "", "MDIClient1", 0, 0, 200, 200


Method ControlSend

Method Reference (COM)

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 can be quite useful to send capital letters without messing up the state of "Shift."

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".
Note, this function cannot send all the characters that the usual Send function can (notably ALT keys) but it can send most of them--even to non-active or hidden windows!

Related

ControlCommand, Send

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlSend "Untitled", "", "Edit1", "This is a line of text in the notepad window"


Method ControlSetText

Method Reference (COM)

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

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlGetText, ControlCommand

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

oAutoIt.Run "notepad.exe"
oAutoIt.WinWait "Untitled -"
oAutoIt.ControlSetText "Untitled -", "", "Edit1", "New Text Here"


Method ControlShow

Method Reference (COM)

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

When using a control name in the Control functions, you need to add a number to the end of the name to indicate which control. For example, if there two controls listed called "MDIClient", you would refer to these as "MDIClient1" and "MDIClient2".

Related

ControlHide, ControlEnable, ControlCommand

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.ControlShow "Untitled -", "", "MDIClient1"


Method StatusbarGetText

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

oAutoIt.AutoItSetOption("WinTitleMatchMode", 2)
text = oAutoIt.StatusbarGetText "Internet Explorer"
WScript.Echo "Internet Explorer's status bar says: " & text


Method WinActivate

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.WinActivate "Untitled - Notepad", ""


Method WinActive

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

If oAutoIt.WinActive("Untitled -") Then
WScript.Echo "Window was active"
End If


Method WinClose

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.WinClose "Untitled - Notepad", ""


Method WinExists

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

If oAutoIt.WinExists("Untitled -") Then
WScript.Echo "Window exists"
EndIf


Method WinGetCaretPosX

Method Reference (COM)

WinGetCaretPosX

Returns the coordinates of the caret in the foreground window

WinGetCaretPosX

Parameters

None.

Return Value

Success: | Returns the X coordinate of the caret.
Failure: | Sets oAutoIt.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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
x = oAutoIt.WinGetCaretPosX()
y = oAutoIt.WinGetCaretPosY()


Method WinGetCaretPosY

Method Reference (COM)

WinGetCaretPosY

Returns the coordinates of the caret in the foreground window

WinGetCaretPosY

Parameters

None.

Return Value

Success: | Returns the Y coordinate of the caret.
Failure: | Sets oAutoIt.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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
x = oAutoIt.WinGetCaretPosX()
y = oAutoIt.WinGetCaretPosY()


Method WinGetClassList

Method Reference (COM)

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 oAutoIt.error to 1 if no window matches the criteria.

Remarks

Class names are linefeed 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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

text = oAutoIt.WinGetClassList("Untitled -", "")
WScript.Echo "Text read was:" & text


Method WinGetClientSizeWidth

Method Reference (COM)

WinGetClientSizeWidth

Retrieves the size of a given window's client area.

WinGetClientSizeWidth "title" [, "text"]

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns the width of the window's client area
Failure: | Returns numeric 1 and sets oAutoIt.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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

$width = oAutoIt.WinGetClientSizeWidth("")
$height = oAutoIt.WinGetClientSizeHeight("")


Method WinGetClientSizeHeight

Method Reference (COM)

WinGetClientSizeHeight

Retrieves the size of a given window's client area.

WinGetClientSizeHeight "title" [, "text"]

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns the height of the window's client area
Failure: | Returns numeric 1 and sets oAutoIt.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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

$width = oAutoIt.WinGetClientSizeWidth("")
$height = oAutoIt.WinGetClientSizeHeight("")


Method WinGetHandle

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
handle = oAutoIt.WinGetHandle("classname=Notepad", "")


Method WinGetPosX

Method Reference (COM)

WinGetPosX

Retrieves the position and size of a given window.

WinGetPosX "title" [, "text"]

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns the X coordinate of the window.
Failure: | Returns numeric 1 and sets oAutoIt.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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
x = oAutoIt.WinGetPosX("")
y = oAutoIt.WinGetPosY("")
width = oAutoIt.WinGetPosWidth("")
height = oAutoIt.WinGetPosHeight("")


Method WinGetPosY

Method Reference (COM)

WinGetPosY

Retrieves the position and size of a given window.

WinGetPosY "title" [, "text"]

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns the Y coordinate of the window.
Failure: | Returns numeric 1 and sets oAutoIt.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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
x = oAutoIt.WinGetPosX("")
y = oAutoIt.WinGetPosY("")
width = oAutoIt.WinGetPosWidth("")
height = oAutoIt.WinGetPosHeight("")


Method WinGetPosWidth

Method Reference (COM)

WinGetPosWidth

Retrieves the position and size of a given window.

WinGetPosWidth "title" [, "text"]

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns the width of the window.
Failure: | Returns numeric 1 and sets oAutoIt.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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
x = oAutoIt.WinGetPosX("")
y = oAutoIt.WinGetPosY("")
width = oAutoIt.WinGetPosWidth("")
height = oAutoIt.WinGetPosHeight("")


Method WinGetPosHeight

Method Reference (COM)

WinGetPosHeight

Retrieves the position and size of a given window.

WinGetPosHeight "title" [, "text"]

Parameters

title | The title of the window to read.
text | [optional] The text of the window to read.

Return Value

Success: | Returns the height of the window.
Failure: | Returns numeric 1 and sets oAutoIt.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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
x = oAutoIt.WinGetPosX("")
y = oAutoIt.WinGetPosY("")
width = oAutoIt.WinGetPosWidth("")
height = oAutoIt.WinGetPosHeight("")


Method WinGetProcess

Method Reference (COM)

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 string containing the numeric Process ID (PID).
Failure: | Returns "".

Remarks

None.

Related

ProcessWait, ProcessWaitClose

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
WScript.Echo oAutoIt.WinGetProcess("Untitled - Notepad")


Method WinGetState

Method Reference (COM)

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 oAutoIt.error to 1 if the window is not found.

Remarks

None.

Related

BitAND, WinGetPos

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
state = oAutoIt.WinGetState "Untitled", ""


Method WinGetText

Method Reference (COM)

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.

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
text = oAutoIt.WinGetText("Untitled -", "")
WScript.Echo "Text read was:" & text


Method WinGetTitle

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

title = oAutoIt.WinGetTitle "Untitled -", ""
WScript.Echo "Full title read was:" & title


Method WinKill

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.WinKill "Untitled - ", ""


Method WinMenuSelectItem

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

' This will select File, Page Setup in notepad
oAutoIt.WinMenuSelectItem "Untitled - ", "", "&File", "Page Set&up..."


Method WinMinimizeAll

Method Reference (COM)

WinMinimizeAll

Minimizes all windows.

WinMinimizeAll

Parameters

None.

Return Value

None.

Remarks

Send("#m") is a possible alternative.

Related

WinMinimizeAllUndo, WinSetState

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.WinMinimizeAll


Method WinMinimizeAllUndo

Method Reference (COM)

WinMinimizeAllUndo

Undoes a previous WinMinimizeAll function.

WinMinimizeAllUndo

Parameters

None.

Return Value

None.

Remarks

Send("#+m") is a possible alternative.

Related

WinMinimizeAll, WinSetState

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.WinMinimizeAllUndo


Method WinMove

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.WinMove "Untitled -", "", 0, 0, 200, 200


Method WinSetOnTop

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.WinSetOnTop "Untitled -", "", 1


Method WinSetState

Method Reference (COM)

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

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

oAutoIt.WinSetState "Untitled -", "", oAutoIt.SW_HIDE
oAutoIt.Sleep 3000
oAutoIt.WinSetState "Untitled -", "", oAutoIt.SW_SHOW


Method WinSetTitle

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
oAutoIt.WinSetTitle "Untitled - ", "", "My New Notepad"


Method WinSetTrans

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

oAutoIt.Run("notepad.exe", "", oAutoIt.SW_MINIMIZE)
oAutoIt.WinWaitActive("Untitled - Notepad")
oAutoIt.WinSetTrans "Untitled - Notepad","", 50


Method WinWait

Method Reference (COM)

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

The script polls for window match every 250 milliseconds or so.

Related

WinActive, WinExists, WinWait, WinWaitActive, WinWaitClose, WinWaitNotActive, WinWaitDelay (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

'Wait for the window "Untitled" to exist

oAutoIt.Run "notepad.exe"
oAutoIt.WinWait "Untitled"

'Wait a maximum of 5 seconds for "Untitled" to exist
oAutoIt.WinWait "Untitled", "", 5


Method WinWaitActive

Method Reference (COM)

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

AutoIt polls for a window match every 250 milliseconds or so.

Related

WinActive, WinExists, WinWait, WinWaitClose, WinWaitNotActive, WinWaitDelay (Option)

Example

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

'Wait for the window "Untitled" to exist and be active
oAutoIt.WinWaitActive "Untitled"

'Wait a maximum of 5 seconds for "Untitled" to exist and be active
oAutoIt.WinWaitActive "Untitled", "", 5


Method WinWaitClose

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

'Wait for the window "Untitled" to not exist
oAutoIt.WinWaitClose "Untitled"

'Wait a maximum of 5 seconds for "Untitled" to not exist
oAutoIt.WinWaitClose "Untitled", "", 5


Method WinWaitNotActive

Method Reference (COM)

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

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")

'Wait for the window "Untitled" to not be active
oAutoIt.WinWaitNotActive "Untitled"

' Wait a maximum of 5 seconds for "Untitled" to not be active
oAutoIt.WinWaitNotActive "Untitled", "", 5


Macros

Properties Reference

Below is an list of all the properties available in AutoItX.

e.g.

Set oAutoIt = WScript.CreateObject("AutoItX3.Control")
error = oAutoIt.error()

Macro | Description
error | Status of the error flag (equivalent to the @error macro in AutoIt v3)
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.


Using the COM Interface

Using the DLL Interface

AutoItX can be used as a standard DLL from any language capable of calling functions in external DLLs.

The following files are provided to allow you to use the DLL (for the C/C++ language):

AutoIt3.h - C language header file showing the exported functions and parameters

AutoItX3.lib - Microsoft format import library

Files to ease the support of other languages may be provided with AutoItX if submitted by users (needed: VB, Delphi, etc.)

Documentation for each function is not provided as the function calls are identical to the COM version and it should be easy to work out what is required with the COM documentation and the AutoIt3.h file. The only difference to the COM version is that the functions that receive text - such as AU3_WinGetTitle have an additional parameter called nBufSize - this should be set to the available size of the output text buffer.

e.g. The prototype for AU3_WinGetText is:

void AU3_WinGetTitle(const char *szTitle, const char *szText, char *szRetText, int nBufSize);

The return buffer is szRetText, and an example (C language) usage would be:

char szMyTitle[200];

AU3_WinGetTitle("Untitled - Notepad", "", szMyTitle, 200);

MessageBox(NULL, szMyTitle, "Returned window title was:", MB_OK);

nBufSize is simply used to avoid buffer overruns in any text that is passed back.


Language Reference

Appendix Reference

  • ASCII Characters
  • 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 |


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

AutoItX was created from the AutoIt v3 source code by Jonathan Bennett.

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>

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 AutoItX v3. For the full technical log including beta versions click here.

7th Apr, 2005 - v3.1.1

No changes to AutoItX. See main AutoIt changelog.

7th Feb, 2005 - v3.1.0

  • Added: WinGetProcess()
  • Added: "main", "primary", "menu", "secondary" added as valid mouse button types
  • Added: ControlListView()
  • Added: ControlGetHandle()
  • Added: WinSetTrans()
  • Removed: URLDownloadToFile() (to be replaced with InetGet in the next version)
  • Changed: IniDelete() can also delete entire sections
  • Changed: The mouse and pixel functions now have an additional "client area" mode.
  • Changed: PixelChecksum() now has optional step parameter
  • Changed: Control...() functions now accept the Control ID as an extra way to identify a control
  • Fixed: StatusBarGetText() failed when used with no "Text" parameter


3.1.1 (7th Apr, 2005) (Release)

No AutoItX changes (See main AutoIt changelog)

3.1.0 (7th Feb, 2005) (Beta)

- Added: WinGetProcess()
- Added: "main", "primary", "menu", "secondary" added as valid mouse button types.
- Added: ControlListView()
- Added: ControlGetHandle()
- Added: WinSetTrans()

- Removed: URLDownloadToFile() (to be replaced with InetGet in the next version)

- Changed: IniDelete() can also delete entire sections
- Changed: The mouse and pixel functions now have an additional "client area" mode.
- Changed: PixelChecksum() now has optional step parameter
- Changed: Control...() functions now accept the Control ID as an extra way to identify a control

- Fixed: StatusBarGetText() failed when used with no "Text" parameter