Click here to Skip to main content
15,886,110 members
Articles / All Topics

Windows Automation Tools/Scripts

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
29 Dec 2013CPOL5 min read 11.6K   3  
Several nice tools and scripting languages to automate Windows GUI applications.

After the successful run with JMeter earlier to load test our web pages, I have been on a mission to find an open source tool to automate our GUI application. So far, I have not found any good (free) open source tool. But, I stumbled upon several nice tools and scripting languages to automate Windows GUI applications.

JMeter was very good for the Web. Since each web page can be generated (HTML), the tool could simulate page to page navigation well. If only we can do this for the GUI screens? It’s all compiled code and a GUI doesn’t look like it can be tampered with (until I found below scripts). So, you essentially need to work on it like a black box, so you can automate a GUI application only by capturing it’s external interfaces – mouse clicks, keys types and windows messages to and from the application.

Sikuli

I started with Sikuli. This is a great tool/script. It’s Python based and lets you capture screen shots of different parts of the screen and drive your script by looking for these images. They call it Computer Vision. You can build a library of standard images (For example, Button with the label OK) and reuse them across the application(s). As long as your application has GUI standards, this will work out great. It’s a great concept and it seems to work decently.

sikuli ide

Fig 1. Sikuli IDE. Notice the version # in the title r930 is the latest and stable version.

Sikuli IDE lets you capture screenshots from within and use these in functions For e.g., wait function, waits for a screen matching the screenshot to appear. After you create your script in IDE and save it, the underlying script is actually saved as a Python script, with the all the images saved.

siklui ltx script

Fig 2. Corresponding Python Script

Sikuli has a full array of built in (global) functions. See documentation for more.

Note: Above script has UDF – user defined functions. When you record script through AutoIt3 Recorder, it will have one long script. I’ve divided these into functions.

Sikuli is a great tool. It deserves more research and I reserve it for future. I am more of a scripting guy and I like text based scripts. (It’s easier to find and replace globally and you can even write a script to generate another). So, I continued my search for my text based scripting language. Also, I had some issue with the installation. Though it worked initially, the runtime (a batch file running Java jar) kept getting corrupted for some reason. Then I tried their portable version, it seemed to work OK so far. But, if you are having issues with Sikuli installation, please see here, here, here, here. I did not see any recorder for Sikuli, though I saw references to one all over the web.

AutoIt3

Then I landed on AutoIt. It’s great tool. I’ve really grown to like it. It has a BASIC kind of language (actually more like PERL, C, etc.) and lets you program everything from mouse clicks to taking complete control of a GUI application window. Apparently original AutoIt reached version 2 and stopped. There is a new branch called AutoIt3. This version is bigger and better than previous versions. See here for full history of the product.

AutoIt3 scripts can be edited in integrated Scite Editor. All popular editors like Notepad++ also support Autoscript syntax. AutoIt3 comes with a Recorder as well. I was able to run our application and record it into a script that I could use repeatedly. I am just beginning to explore this tool. I will post more as I explore the tool further.

au3 scripts in notepadpp

Fig 3 AutoIt3 Script edited in Notepadd++

When you install AutoIt3, the commands are integrated into Windows Explorer menu. You can edit or Run script from here. Edit opens Scite Editor by default.

au3 explorer menu

Fig 4. Au3 Commands integrated into Windows Explorer menu

Autoit3 Samples

AutoIt site has a very good forum with lots of skilled people supporting it. A section called “Example Scripts” provides lots of good sample scripts. For a real dive into AutoIt3, take a look at a script called Control Viewer. The author has taken the pains to develop it in AutoIt3 itself. It shows you how to create GUI in Autoscript, and using this you can identify controls (widgets) on any Windows application currently running. (AutoIt3 comes with AutoInfo which has similar functionality, but CV has it better!). For some reason the author has discontinued it, but you can down the EXE and the scripts from the main page.

au3 cv script gui

Fig 5. Control Viewer window – GUI built in AutoIt3 script!

AutoHotKey (AHK)

The third product I looked at, but haven’t done much with, is AutoHotKey (AHK). Apparently it combines strengths of 2 different programs, AutoIt (older version) and Hotkey. One immediate observation about AHK scripts was that it didn’t look as structured as AutoIt scripts. But, I could be wrong. There are debates about AutoIt vs. AHK. See here for a comparison, though somewhat old. AutoIt3 wins hands down for me at the moment.

I will post more as I explore any of these tools for use in test automation. If you are interested, here are some interesting links about the topic:

References

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) City of Los Angeles
United States United States
Originally a Physics major, fell in love with Microprocessors and switched to Computer Science 20+ years ago. Since then, dabbled in various languages including, PowerBuilder, Oracle, Java, C, C++, Perl, Python etc. Constantly striving for quality and performance too.

I try to help fellow developers with technology as a way of "giving back to the community". Blogging became a natural extension of that effort. Still learning to perfect that art. If one new programmer out there benefits from this blog, my time and effort are fully worth it.

The underlying theme in my blogs is power and beauty of programming (and technology in general). A well written program gives me the sense of awe you get when you look at a man made wonder like Angkor Wat. You experience poetry, art, mystique, power all at once. A program and the troubleshooting that ensues also gives you a feeling you get while reading a mystery novel!

Comments and Discussions

 
-- There are no messages in this forum --