Am I barking up the wrong tree?

Aug 11, 2010 at 2:47 PM

I want to control a third party program.  In particular to launch it, send a key to select a menu item, make a selection from a list box, send another key and then wait until the value in a lable / caption changes.

Then do it again!

It seemed to me that White would do this very nicely.  But I'm struggling to get anywhere with it.

My code such as it is looks like this

application = Application.Attach(ProcessID);
window = (White.Core.UIItems.WindowItems.Window)application.GetWindow("MainWindowName", White.Core.Factory.InitializeOption.NoCache);
White.Core.InputDevices.AttachedKeyboard keyboard = window.Keyboard;

My first problem is that it takes some minutes to return from the GetWindow.  So long in fact that I thought the program had hung (until I used patience instead of my normal approach).

My second problem is that the three calls to Keyboard methods result in

A first chance exception of type 'System.InvalidOperationException' occurred in UIAutomationClient.dll

I don't know if I'm being dim or if White won't work with the program (I expect the program is written in C++ or VB - it's the latest version of something that's been around for ages).  I'm not clear on if it should work with all windows programs and or if there are some constraints.

So wrong tree or wrong dog?!


Any help most gratefully received!




Aug 11, 2010 at 10:59 PM

Well the more applications you have open the longer it's going to take to find the window, so you could try having as little open as possible and see if that helps.  As for the Keyboard problems I'm not sure why you are getting those exceptions.



Aug 12, 2010 at 8:22 AM

This was finding the window of the application - there should only have been one and only one is reported by a GetWindows call (which is also terribly slow).

However, I seem to have acheived most of what I want with AutoHotKey so I'm sort of happy for now.

However, I AM interested in GUI Unit tests which this should be great for.  It would be very helpful to know what constraints there were in client technology - e.g. will this work as well with a 1999 SDK application as with a 2010 WPF/WinForms app, how could I distinguish between the two and how would I code differently - or not?

THanks for your reply.