I have an application that needs to introspect running third-party .NET applications – for which I have no source. I need to be able to read the on-screen forms, controls and their on-screen relative positions.
What libraries or technologies (Microsoft or otherwise) are available?
What I need:
- To perform this programmatically (i.e. I’m not interested in a Visual Studio plugin) from an application that I will write
- To support all (or as many as possible) CLR applications
- To be able to find all open screens/forms
- For a given screen/form, discover all the controls
-
For a control, read properties such as:
- It’s on-screen value (i.e. the text in an input field),
- Font size, colour and style,
- Location on the form
- Any label
- The parent panel/group for the control
-
Detect where the screen focus is
What I don’t need (but would except as extra value):
- To discover other objects or recover the run-time object graph
- To decompile or otherwise obtain the third-party source
- Discover the class hierarchy of the application
- Drill into other aspects of the application’s runtime state
- To introspect native C++ applications
- To introspect an application from another computer/VM.
It sounds like you’re trying to automate other programs. Well, the good news is that Microsoft have produced an entire library for UI Automation: