The power of AutoHotKey

By : |December 4, 2012 0

In the life cycle of an embedded product, there is a challenging and time consuming phase – Testing. In this phase, quality is a big concern with time as a critical factor. Testing itself is divided in functional, stress, performance, concurrency and regression etc. phases. In all the phases, mostly, tester has to run similar tests with different combinations. But sometimes for a tester, the testing phase becomes mindless, repeated, tedious and boring which can cause less interest in job in addition to work quality reduction. Such factor enables use of Automation Tool in the testing phase of the product.

AutoHotKey is a free, open-source, light weight automation tool which can perform a repetitive and redundant task without human intervention resulting less time and less human errors. AutoHotKey is a scripting language for Windows OS with support of GUI development as well. Instead of wasting hours clicking buttons and hitting keys, this is the perfect time to learn tools such as AutoHotKey to make your Windows PC do the work for you.

In my opinion the name ‘AutoHotKey’ does not do justice to the capabilities of the software. It’s not merely another scripting language that sets up Windows hotkeys but there is much more inside this free, robust and flexible utility.



In a typical embedded product test setup, a Windows host PC is connected to the Embedded Board. It takes care of connecting debugger/IDE tool to the Embedded Device Under Test (DUT). The connection can be via USB based JTAG or UART based serial port. The windows host machine can also open an SSH based login terminal onto the DUT and run tests as required. Many times when tester wants to run regression test, remote login is used to fire the test.

In such scenario, to start a test, most of the time user will follow steps such as;

a)Power up the board
b)Connect the debugger to the board
c)Wait for DUT to boot
d)Login to the DUT using SSH or other login mechanism
e)Run some commands on DUT to make it ready for a test
f)Launch test as per requirement (stress, regression, performance etc.)
g)Check the log for pass/fail results

Instead of performing above steps manually, AutoHotKey can be used to launch programs, retrieve content from some window, send mouse clicks, run loops etc. What tester has to do is: Install AutoHotKey, Develop a script that manipulates all the tasks and run the script to launch a test.

There are plenty of incentives AutoHotKey offers for a tester of an Embedded System. The following section describes some of the powerful features of AutoHotKey.

Ease of script development: To take advantage of the flexibility and power of AutoHotKey, a little amount of programming is required. That makes AutoHotKey an easiest scripting tool to develop a script. Addition to that, AutoHotKey supports a monitoring tool. User can start the monitor tool; perform some manual ‘steps’ on Windows host and then stop the monitoring tool. The tool will provide ‘statements’ that you can copy in a file with extension ‘ahk’. If user does a double click on the script, same ‘steps’ will be performed on windows machine, needless to say “Automatically”.

Monitoring and Controlling a window: Let’s say user want to launch a test once “device booted” message is displayed on debugger window. AutoHotKey can retrieve any text from specified window and wait before performing further action. AutoHotKey also allows user to write particular text on a window as such user is typing a command to run a test. AutoHotKey also includes commands for manipulating the position and size of windows.

Simulating Key Press and Mouse Clicks: AutoHotKey can simulate combinations of keys and mouse click events which can be used to open an application and launch test. For example using a single click, user can open ‘Tera Term’ (a serial utility), configure it for a specific serial port, connect to the DUT and launch a test. AutoHotKey Scripts can be easily written for opening programs, documents, and websites.

DUT Power Control: The Embedded DUT can be controlled thru a network switch which can be controlled on Windows Host. Thus AutoHotKey can control the window of the network switch.

Loops and Conditions: AutoHotKey provides rich set of commands (syntax) for loop and condition handling. User can perform a series of commands repeatedly: making it very useful for regression and stress testing.

GUI Development: AutoHotKey provide APIs to develop GUI on top of your test. GUI APIs can create and manage windows and controls. Such windows can be used as data entry forms or custom user interfaces. A typical use-case can be: Display a menu to select/specify test number, test type, Iteration count, test input parameters, hardware version, software version etc.

Logging Features: An AutoHotKey script can display messages on screen or write the messages to a file. With single line of script one can displays the specified text in a small window containing one or more buttons (such as YES and NO). Important test information can be logged into a file and can be analyzed later on.

The features described above are some of the notable features. There are plenty of others like timers, sound commands, TrayTip, string management, InputBox, file operations, registry management etc. can be used to ease testing process and save testing time.

Getting Started with AutoHotKey is as easy as pie. It’s really a counting 1-2-3 job.

There are almost endless possibilities of what can be done with AutoHotKey for automating your test procedure. But the tool is limited to Windows only however, sorry Mac and Linux geeks. Worthless to repeat that user can always login to Linux running on DUT using SSH terminal from Windows Host and use AutoHotKey script to play with SSH terminal.

Conclusion: AutoHotKey is a useful tool to automate repetitive and redundant testing procedure of an Embedded System. The plus points like ease of development, recording tool, open-source, GUI development support, window monitoring similarity to C language etc. can make it widely excepted by Embedded Engineers. Not only time saving but better quality then manual testing can be easily achieved.

(The author is Technical Leader in Embedded Department of eInfochips Inc.)

No Comments so fars

Jump into a conversation

No Comments Yet!

You can be the one to start a conversation.