Create Automation Scripts For Windows With AutoIt

There are plenty of automation tools for Windows. You can use the built-in Task Scheduler to schedule tasks, or use Folder Actions to set up events for folders. If those are not enough for you and and you prefer to use a more complicated and powerful automation tool, AutoIt is a useful tool for you to create automation scripts.

AutoIt is a scripting language which is more powerful than batch scripting and can automate almost any kind of task in Windows.

Getting Started

AutoIt is not a complex scripting language. If you have some programming knowledge, you will be able to pick up AutoIt very easily. It will take a while for you to be familiar with the syntax, but once you get it going, you will be able to make use of it to automate repetitive tasks and create other programs that work in Windows.

First of all, you will need to download the AutoIt installer and install it in Windows. The default installation of AutoIt comes with a lite version of SciTE editor, which you can use for creating basic scripts. If you require more advanced functionality, you may need to download and install the complete SciTE editor.

AutoIt documentation is also available online. It includes (almost) everything you need to know about AutoIt language.

Below, we will show you a few examples of what AutoIt is capable of doing:

Automating the launching and closing of applications

To launch an application, use the Run command in AutoIt:


You can also run the application with different user credentials with the RunAs command. If you want to wait for a particular application to close before launching the next one, you can use RunWait command.

To close an application, you can make use of the ProcessClose command.

For example, to close Firefox:

Automating program installations

The beauty and power of AutoIt is that you can automate virtually anything in Windows, including the installation of application. If you are a network administrator and want to automatically install programs silently without user intervention, AutoIt can do this very easily.

Basically, you will need to run the setup installer first by using the Run function:

You can also give full path of the program if it is not in the current directory.

Then we need to wait until the interface appears on the screen. We can use WinWaitActive function for this purpose.


When the window becomes active, we will be using the shortcut keys to go through the setup process. Most of the installers allow you to use keyboard shortcuts to proceed with the installation process. Usually the keyboard shortcut is denoted by an underline letter, so you will need to press “Alt” and the underlined letter for action.

In AutoIt, you can use the Send function for processing the keyboard shortcut.

And when you only need to press the Enter key, simply send Enter:

And when the installation is complete, you can close the window by using WinClose function.

For example, to automate the installation of Microsoft Office, the script will look like this:

Since the installer will automatically close after installation, we don’t need to run the WinClose function.

Creating Macros

What makes AutoIt even better is the Macro recorder which can be used for lengthy and tedious sequences of keystrokes. The Macro recorder is available in the full version of SciTE editor.


To access the Macro recorder, open SciTE editor and go to “Tools -> AU3Recorder” or simply press “Alt + F6” shortcut key. The macro recorder will record all your keystrokes and then simulate those keystrokes when the script is run. The only limitation of the macro recorder is that we don’t get WinWaitActive function inserted automatically between each keystroke. It is important to include WinWaitActive function otherwise the script will complete its execution even before the first setup screen appears.



While there are several other ways to automate programs and tasks in Windows, AutoIt is much more powerful and can perform the most tedious tasks very easily.

Do you use automation in your daily work routine or are comfortable with doing things manually?

Usman Khurshid

Usman is a technology enthusiast and loves tweaking Microsoft products. In addition to MakeTechEasier, he contributes regularly to


  1. “It is important to include WinWaitActive function otherwise the script will complete its execution even before the first setup screen appears.”

    While you are correct in the reason for using the WinWaitActive function, there’s a problem with using just that function by itself: the window being waited for could appear but, for numerous reasons, never become active, causing the script to wait forever (or until it gets cancelled). What should be used is the following:

    WinWait(“title”, “text”)
    If Not WinActive(“title”, “text”) Then WinActivate(“title”, “text”)
    WinWaitActive(“title”, “text”)

    The first command waits until the specified window appears. The second command checks to see if the window is active and if it isn’t, activates it so that the WinWaitActive function sees it and allows the script to carry on.

    “The only limitation of the macro recorder is that we don’t get WinWaitActive function inserted automatically between each keystroke”

    Are you sure? The version of the recorder I currently have installed (admittedly a little old) doesn’t put the WinWaitActive function itself in each place the macro has to wait for a window but instead puts the 3 lines I have above into a function at the beginning of the macro, and then puts a call to *that* function in each place that the macro has to wait for a window. This is an efficient programming style, in which you don’t have large blocks of code repeated numerous times throughout the source file…it comes from a time when programmers had to keep their source files as short and tight as possible in order to keep the programs themselves as small as possible. The only reason I don’t like this new way of using WinWaitActive is that if debugging is turned on, then all that is indicated is that the macro is waiting in the new function. If you weren’t watching carefully, you have no idea what it’s waiting *for*…which makes it difficult to fix the problem.

    1. Hi Rick. First of all, thanks a lot for a very detailed and insightful comment. I really appreciate it.

      When we are installing a new software, we tend to wait until the software is installed before doing anything else. Thats why I ‘didn’t think activating the window was necessary because 99% of the times, the next window will automatically get activated. I have created automatic installations for some programs and didn’t get into any issues even without the if not active statement. But definitely, in a distracting environment or automating anything else than installing programs, that condition will be helpful and sometimes necessary.

      I don’t usually use the Macro to automate my functions but for this article, I did use the Macro for installing Office 2010. It didn’t add the WinWaitActive function by itself and I had to add it myself. I’m using the latest SciTE Editor 3.3. I will test the Macros with another installation and let you know if it works or not.

  2. P.S. Your “Connect with: Twitter” button doesn’t seem to work. It brought up a window allowing me to log into Twitter, but it didn’t grab my name/photo to use when posting here…I still had to use the “Post as guest” button to post my comments.

Comments are closed.