AutoIt Tutorial: Getting Started

August 21, 2012

In this first post of my AutoIt Tutorial series I'll set the ground for the upcoming lessons where I'll assume that AutoIt is already installed and that the process of creating and running scrips is well understood.

Download and Installation

There are several possibilities to set up an environment for creating and running AutoIt scripts. My advice is to start by downloading and installing the following 2 files (later you may choose to install additional components but to start these are enough):

The first file contains all components required to create and run AutoIt scripts, including a trimmed down version of the AutoIt Script Editor. The second file contains the complete version of the editor; although optional, it is highly advisable that you install it.

The AutoIt Script Editor must be installed after the AutoIt Full Installation package, apart from that the installation process is as simple as double-clicking the executables and following the instructions. All default values are perfectly fine.

Creating and Running Scripts with the AutoIt Script Editor

AutoIt scripts can be edited with any standard text editor but the AutoIt Script Editor included in the installation makes things much easier. To launch the editor, in Windows 7, click Start Menu > All Programs > AutoIt v3 > SciTE Script Editor. The main window looks like this:

AutoIt Script Editor Main GUI

Note: When run for the first time the editor displays a blank window like the one shown above, but afterwards it will always reopen the last used file.

The File, Edit, Search and View menus contain pretty standard items, at least for an IDE, the Tools menu is where the more interesting commands appear, however most of them will only become visible and enabled when the file being edited is saved. For now, the only command we'll care about is Go (keyboard shortcut F5) which validates and runs the script being edited.

Let's try it:

  1. Type the following text:
    MsgBox(0, "Hello", "Hello, AutoIt!");
  1. Save the file with a name like "Hello.au3";
  1. Open the Tools menu and click Go. The result will be the following message box:
AutoIt Script Execution Result

Creating and Running Scripts from Windows Explorer

Scripts can also be created and run directly from Windows Explorer.

To create a new script:

  1. Open Windows Explorer and browse to the folder where the script is to be created;
  2. Right-click inside the folder and choose New > AutoIt v3 Script;
  3. Enter a name for the file.

To edit, right-click the newly created file and choose Edit Script, this will open the script in the AutoIt Script Editor.

To execute, double-click the file or right-click and choose Run Script.