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.
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:
Run( "program.exe", "c:\program path")
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
To close an application, you can make use of the
For example, to close Firefox:
local $pid = ProcessExists ("firefox.exe") if $pid then ProcessClose ($pid)
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
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.
WinWaitActive ("Window title", "text")
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
For example, to automate the installation of Microsoft Office, the script will look like this:
;Run the Office 2010 installer Run ("setup.exe") ;Wait for the setup window to be active WinWaitActive ("Microsoft Office Professional Plus 2010", "setup") ;Accept the license agreement Send (!a) ;Proceed to the next screen Send (!c) ;Install Office with default options WinWaitActive ("Microsoft Office Professional Plus 2010", "Choose the installation you want") Send (!i) ;Close the setup when office is installed WinWaitActive ("Microsoft Office Professional Plus 2010", "Setup Complete") Send (!c)
Since the installer will automatically close after installation, we don’t need to run the
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?
Our latest tutorials delivered straight to your inbox