3

I am using an application, which I know, is c# with WPF. I want to grab data from some of its windows. In detail, i want to grab a grid with all content and the header. If I do copy+paste, i just get all content, but no headers.

Is there any way to connect to the process and get a handle to the control and access the controls data (without doing ocr or some other screen-capturing things) native in .net?

I know how to get a handle to the window, and the form itself just contains this grid, so if i have the window as any kind of .net-object, i will soon get the grid. The question is, if I can get to the window as .net-"native"-object.

Robert Harvey
201k55 gold badges469 silver badges682 bronze badges
asked Sep 30, 2016 at 14:29
2
  • 2
    I know you can in some way, as the 'snoop' application is able to do what you desire. Commented Dec 28, 2016 at 3:52
  • stackoverflow.com/questions/24045183/… Commented Jun 26, 2017 at 10:29

2 Answers 2

1

What do you mean by:

The question is, if I can get to the window as .net-"native"-object.

All of WPF window is implemented as .NET object. Therefore any objects placed on the WPW window is .NET object, as long as the object is also .NET object. There's no native .NET object, because native in .NET means Microsoft Windows native API (or the underlying OS API).

You can hook into a .NET application (and examine all of the objects inside of the application) as long as it's executable and not compiled in .NET Core. But hooking into a .NET application is a very difficult and tedious task, and you can hook into any .NET application easier by using Visual Studio debugger because what you are trying to accomplish is actually creating a debugger. Visual Studio debugger can be attached to any .NET running applications including WPF and Windows Forms.

answered Dec 28, 2016 at 3:38
1

Not all WPF controls have Window handles, only some controls at the base of the visual stack have them (like the Window). Consequently, you cannot use the pinvoke way of getwindowtext etc. here.

Since some "assistive technologies" like screen readers may need to access the contents, I'd suggest to look into this field to get further ideas on how to access the controls.

answered Mar 28, 2017 at 8:09

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.