tags:

views:

32

answers:

1

Is there a .net namespace or similar/simpler way to get text from windows and child classes (controls) other than using a Win32 API messages?

I think there is a way to get the handle of the active window in .net without WinAPI. Anyone know what namespace/class does that?

+1  A: 

Is there a .net namespace or similar/simpler way to get text from windows and child classes (controls) other than using a Win32 API messages?

You can use the GetWindowText API, which is a bit easier than sending a WM_GETTEXT message. But this will only work for a window, not a for a control inside a window.

I think there is a way to get the handle of the active window in .net without WinAPI. Anyone know what namespace/class does that?

I don't think there is anything like that in the framework. You can, however, retrieve the handle to the main window of a process, using the Process.MainWindowHandle property

Thomas Levesque
I found this "Microsoft Win32 to Microsoft .NET Framework API map at:http://msdn.microsoft.com/en-us/library/aa302340.aspxIt looks like it's close but not quite. I basically need a reverse-sendkeys. Looks like listening for WM_GetText with User32.dll is the only way -- I found plenty of code samples for that.
pghcpa