Thursday 20 September 2012

Great Programming Tool - AutoIt

Imagine the scenario: you need to develop a tool quickly to solve some problem. You need to decide what programming language/tool to use. You consider Java, VB.NET, Qt, Perl, Python, Adobe AIR, and a variety of BASICs (QuickBASIC, FreeBASIC, Just BASIC, XBASIC, and Rapid-Q).

If your target platform is Windows, then I would suggest that you should add AutoIt to that list.

AutoIt (pronounced "aw-toe-it") was originally developed to help automate installs on Windows. But it evolved over time to include some really clever features which allow it to do a lot more than that.

I used it recently to create a performance test script which automates Word and Excel operations in order to produce timings that help to predict the actual response times which users will experience (the company was moving its data centre to a remote location where bandwidth and latency would be potential issues).

Some of the great things about AutoIt include:
  • You can simulate keystrokes, mouse movement and window/control manipulation in order to automate tasks
  • It can generate EXE files which do not require any runtime environment (contrast that with Java and .NET!)
  • You can download it packaged with a nice editor called SciTE
  • You can even use it to create GUI applications

And do you remember (and sometimes miss!) the "Macro Recorder" which used to be an Accessory within Windows way-back-when? Well AutoIt has a tool called "Au3Recorder" which can create a script based on keystrokes and mouse movements.

The main limitations of AutoIt seem to be:
  • MS Windows only (this really is the main limitation)
  • No proper built-in debugger (although you can get debuggers for it)
  • No built-in support for creating or consuming a web service
  • You can't write multi-threaded code
  • No Try...catch blocks
As against that, there are some really cool and easy to use functions:
  • Ping - Pings a host and returns the roundtrip-time
  • TrayTip - Displays a balloon tip from the AutoIt Icon
  • ClipGet - Retrieves text from the clipboard
  • CDTray - Opens or closes the CD tray
  • PixelChecksum - Generates a checksum for a region of pixels
  • GUICtrlCreateAvi - Creates an AVI video control for the GUI.
  • DriveMapAdd - Maps a network drive
  • FileCopy - Copies one or more files
  • FileRecycleEmpty - Empties the recycle bin
  • MouseWheel - Moves the mouse wheel up or down
  • ProgressOn - Creates a customizable progress bar window
  • Shutdown - Shuts down the system
  • SplashTextOn - Creates a customizable text popup window
  • TCPSend - Sends data on a connected TCP socket
  • UDPSend - Sends data on an opened UDP socket
Some of those might sound pretty exotic but the fact is that I used TrayTip, PixelChecksum, FileCopy, and SplashTextOn in the program I mentioned earlier.