Qt based applications contain widgets which are not immediately accessible through the Au3Info tool. There are many forum posts on the subject of querying Qt based applications using Au3Info, with the result that it returns only a single QWidget object for the entire application or window.
Qt is a framework which wraps, or masks, the underlying native Win32 controls within it's GUI. Like other similar frameworks and languages (such as Java), Qt includes accessibility features which allow other non-Qt applications to interact with the framework. Tools like AutoIT can use these accessibility features to automate Qt applications.
I have not yet found a Qt accessibility bridge which AutoIT can use (such as in the form of a Windows DLL).
However, I have found a very useful tool called Ranorex Spy (http://www.ranorex.com/gui-testing-guide/spy.html), which uses the accessibility features of Qt to expose information about the QWidgets within an application, in a similar manner to Au3Info. There doesn't appear to be any license associated with Ranorex Spy, so I have attached the tool to this post for the benefit of others.
Use Ranorex Spy in the same manner that you use Au3Info. With the application you want to automate already open, drag the Finder Tool (crosshair) in Ranorex Spy over the application, and you'll notice that it can identify the widgets within the application (in the same manner that Au3Info would).
You can then use this information within the standard AutoIT function calls. Here are some examples.
If the QWidget has a "Caption/text", as identified in Ranorex Spy, then use the following AutoIT call to click on that control:
ControlClick("window title", "", "[TEXT:the Caption/text from Ranorex Spy]")
If the QWidget doesn't have a "Caption/text", then you can use the "Handle" from Ranorex Spy instead. Paste the handle value into the following AutoIT script:
Const $handle_to_find = "paste the handle from Ranorex Spy here" For $i = 1 to 1000 $handle = ControlGetHandle("window title", "", "[CLASS:QWidget; INSTANCE:" & $i & "]") if @error = 1 Then ExitLoop if ($handle = $handle_to_find) Then ConsoleWrite("Found QWidget handle " & $handle_to_find & " at instance: " & $i & @CRLF) ExitLoop EndIf Next
Run the script and it should give you the QWidget instance number of the control. Use this instance number in the following AutoIT call to click on that control:
ControlClick("window title", "", "[CLASS:QWidget; INSTANCE:insert the instance number here]")
Hope this is useful to all those having trouble automating Qt.
Apologies everyone, but I've had to remove the "RanorexSpy.zip" attachment because I've run out of upload quota for the site. Contact me if you'd like a copy.
Edited by seangriffin, 11 February 2012 - 02:10 PM.