Jeremy
Jeremy

Reputation: 46420

How to capture window text

I need to build the ability to capture text from a window, like how this utility works. You specify a windows handle and it will return the text inside the window, regardless if the text is selectedable or can be copy pasted. It's not using any OCR technique either. How can I write this in a .net environment? Can someone explain the technique being used?

Upvotes: 1

Views: 570

Answers (2)

Oleg
Oleg

Reputation: 601

TextGRAB SDK capture text by intercepting API function calls and than calculates what text was displayed in the window. To say the truth not sure if that's possible to implement this in .NET.

Regarding WM_GETWINDOWTEXT, GetWindowText() - this simply won't work for many controls (e.g. lists of different kind, etc)

Upvotes: 1

shoosh
shoosh

Reputation: 79011

If you have the handle of the windows you can send it a WM_GETWINDOWTEXT windows message and see what you get in return.

There will never be a fool-proof way to do this without OCR since some application, for instance, anything that creates a GUI using Java, may render the text as graphics and not use the windows facilities of giving windows text.

Upvotes: 1

Related Questions