Search code examples
c#reflectionhookscreen-scrapingui-automation

Screenscraping and controlling a 3rd party .NET application


Question:

What's the best approach to grab text from .Net UI controls in a running, 3rd party application, and send input to said application? Due to deploy constraints, the target platforms range from XP to Win7. Max .NET version we can use is 3.5.

Background:

My team has been tasked with integrating with a legacy application in wide use in our industry. This integration requires reading data from the 3rd party application's UI and pressing buttons on that application's UI in certain scenarios.

We have the support of the 3rd party application developer, but they have no API to perform these functions.

We've done this successfully before with plain win32 apps via api hooks, but not in .net.

I feel that I should reiterate: we have intimate knowledge of the possible UI states in application in question; clearly there are all sorts of pitfalls here if one doesn't have such deep knowledge.

I am mainly curious what others have done here. Any advice or pointers?


Solution

  • I recommend MS UI Automation.

    Try investigating your application with UI Spy. If you see enough information in UI Spy to get the job done, it should work for you. The API is not easy to jump into, but I would recommend steering clear of frameworks built on top of it to make things easier. Most of these frameworks have performance or other issues.

    If you have controls in the application that you need to manipulate which are very complex (such as controls from Infragistics), then the fact that you need to stay at .NET 3.5 might be a problem. Manipulation of the most complex stuff is best done with the UI Automation Core using the LegacyIAccessible Control Pattern.