I've been doing some work recently that requires me to perform automated windows events - a colleague pointed me at Autoit (http://www.autoitscript.com/autoit3/).

It's a free scripting framework that allows you to build automated scripts that interact with windows. The help system is excellent, and the SciTE editor that you can optionally download makes writing the actual scripts a breeze.

You can use all of the standard programming constructs - if, for while etc. You can check for windows based on window title and content, you can interact with window components and you can wait for window events to occur.

There are several use cases for this tool - testing Windows GUI apps, scripting installers and performing unattended batch operations.