Many larger applications having scripting capabilities built in to allow you to automate repetitive tasks but what do you do if you need to script a repetitive task for an application that doesn't have a scripting or macro language built in?  You could use VBScript and the SendKeys function. This works for simple things but it isn't always robust enough. What if you need to do something more complex, for instance: launch an application, wait for the main window to open, resize the window, send some keystrokes, and then click on a specific UI element? Unfortunately VBScript and its set of built-in functions don't always cut it when you need to move beyond SendKeys.

When your needs go beyond what VBScript can do natively you might want to take a look at AutoIt. AutoIt is a small suite of tools, the main component being a stand-alone scripting language. What sets AutoIt apart from other scripting languages is that it is targeted at GUI application scripting and its built-in set of functions enable the finer level of control lacking in VBScript and other scripting languages. The AutoIt scripting language is very VB-like and easy to pick up if you're already familiar with VB. AutoIt has a rich feature set including (taken from the AutoIt web site):

  • Provide a general-purpose scripting language for all Windows versions
  • Simulate keystrokes (supports most keyboard layouts)
  • Simulate mouse movements and clicks
  • Move, resize and manipulate windows
  • Interact directly with "controls" on a window (set/get text from edit controls, check boxes and radio buttons, select items in drop-down lists, etc.)
  • Create complex user interfaces (GUI's)
  • Work with the clipboard to cut/paste text items
  • Provide a scriptable RunAs function for Windows 2000/XP/2003

However what is really interesting to me is that AutoIt also includes a scriptable COM object essentially making its core application scripting capabilities available to any other COM capable languages including VBA, VBScript, PowerShell, or .Net. The COM interface on this object seems well thought out and is very easy to use. I started using AutoIt for this feature as I needed to automate an application from within Outlook's VBA scripting. Using the AutoIt COM object I was able to write Outlook VBA code to control another application including starting the application, waiting for its main window to launch, and intelligently sending data to the right parts of its UI.

And best of all, AutoIt is free. It can be found here.

Note: PowerShell is on the horizon and by all accounts it should be a very powerful tool but it also seems to lack some of this finer level of control for scripting GUI applications. You can however access the AutoIt COM object as well as the full .Net library.


Comments (5) -

JP
7/28/2007 6:30:02 PM #

Hi David,

First of all I must totally agree with you about the greatness of AutoIt. It's very easy to use. At least, if you use the help function and SciTe. Wink

I was just googling for some information regarding Outlook automation with use of AutoIt, and landed on this page. Unfortunately it was not very helpfull to me.

But as there was no comment from anybody I thought I'd leave you this message. Filling up your HD space and adding up to the internet's global database indexed by Google (and others).
Wink

Greetings !

JP #2
1/17/2008 3:19:00 PM #

Hi David,

I'm a different JP than the first and I wanted to be the second person (and the second JP) to say "Hi" and post a little comment.

Good stuff!

Jay K.
8/30/2008 1:10:43 AM #

Wow!  This is great!  Thanks for the pointer to Autoit.  I was looking for a good tool to do exactly this.  After playing with it for a bit, I think it will work great.

SG
7/27/2010 4:27:11 PM #

Thanks for the tip! AutoIt is exactly what I needed.

Keewl
2/4/2011 3:38:02 PM #

AutoIt is great, thanks.

Comments are closed

Flux and Mutability

The mutable notebook of David Jade