My objective is to capture the mouse and keyboard events that UFT generates in the application-under-test (AUT), for use in a third-party application. Ideally, the solution should work with existing tests, or need just minimal changes.
Using Windows hooking on the AUT would work, but this requires enumerating the AUT's window handles. Is there a generic way to get those?
The simplest solution would be doing this for objects in the test:
Set obj = Dialog("Login") Print "HWND of the login dialog: " & Hex(obj.GetROProperty("hwnd"))
The obvious downside is manually coding this for each of the objects in each of the tests.
I tried enumerating the window and dialog objects, but it turns out UFT enumerates every window whether it belongs to the AUT or not:
Set desc = Description.Create Set objChildren = Desktop.ChildObjects(desc) ' The following counts every open window on the desktop Print "Objects under Desktop: " & objChildren.Count
Surprisingly, the test's object repositories turned up empty:
' The following line outputs zero Print "Repository Count:" & RepositoriesCollection.Count
Querying individual actions' repositories also turned up no results:
Dim qtApp,qtRepositories, actName actName=Environment.Value("ActionName") Set qtApp = GetObject("", "QuickTest.Application") 'also tried with CreateObject Set qtRepositories = qtApp.Test.Actions(actName).ObjectRepositories ' The following line outputs zero Print "Action name: " & actName & " Repository count: " & qtRepositories.Count
There is still the option to use ObjectRepositoryUtil, but for that you need a repository path. As far as I can tell, the small test I have created based on the "Flight GUI" sample application, does not even contain a .tsr file which holds the object repository.
So is there another way in UFT to get the windows in the application under test?