AutoItX3 and QTP Part 2

First, let’s take a look at how I solved my problem of automating keystrokes from the number pad. This will be genericized so that you can run it inside QTP or even just save it in a .vbs file and execute it. It launches Notepad, waits for the notepad window to exist, makes sure it is activated, and then sends the keystrokes to generate the copyright symbol ©.

Through messing around with AutoIt while trying to solve the problem of simulating typing on the number pad, I found that it is a great compliment to QTP’s functionality. The mouse simulations are great, the window management methods are wonderful (wait for a particular window’s existence, etc.), the registry management methods are outstanding, it has methods for setting and retrieving data from the system’s clipboard, and the list goes on and on! So, I really wanted to use AutoIt for more than just that one test case. That just presents the problem of knowing whether or not the system running the tests in the future would have the AutoItX3 COM object available.

To work around that fact, I figured out I could uploaded the AutoItX3.dll file to the Quality Center project’s “Subject” folder and create a quick script that can be run at the beginning of a test set in a stand-alone script or as part of any test script that requires AutoIt’s functionality. The code downloads and sets up the AutoIt COM object automatically on the machine running the tests. This script could most likely be refined, but I just haven’t really had the time or need to at this point. (Click here to view full-screen)

Of course, this code could be used to load any COM object. This could be really handy if you develop your own custom dll’s for your tests. Other enhancements could be to make paths more dynamic, but I’m confident that this would work on any computer in my current client’s organization.

More Resources