0

I want to access the objects and their properties in a similar way to how automation tools access them in their "UI Map" functionality. I'm assuming there's an assembly reference that will give access to running processes and whatever objects exist for that process.

Specifically, I need to access a few label control text properties in another running application.

Also, sorry if this is a duplicate - I looked around, but I'm not sure what keywords would get me to what I need.

CassOnMars
  • 6,153
  • 2
  • 32
  • 47
Zee
  • 1,780
  • 3
  • 16
  • 27
  • 1
    If I'm understanding you correctly, what you want to do is use a tool like Spy++ to determine what the control properties are you want to search for and then use pInvoke to call EnumWindows and find the controls (and their contents). Take a look at the third example here: http://www.pinvoke.net/default.aspx/user32.enumwindows – Pete Jan 29 '13 at 16:03

2 Answers2

3

This is not a common practice in C#. The term that you are looking for is to "spy" another window/application/process. There are several resources here in StackOverflow talking about this. For example:

How can I get functionality similar to Spy++ in my C# app?

To access a control in another Win32 form you need to look for the handle of that element.

Community
  • 1
  • 1
gustavodidomenico
  • 4,640
  • 1
  • 34
  • 50
1

For WPF applications, the UI Automation libraries present in .NET 4.5 make this way simpler: http://msdn.microsoft.com/en-us/library/ms747327.aspx

For older winforms applications, you'll have to actually utilize pInvoke on the User32 API. The example link Pete gave you in the comment on your question will help guide you in that direction: http://www.pinvoke.net/default.aspx/user32.enumwindows

CassOnMars
  • 6,153
  • 2
  • 32
  • 47