Andrzej Gis
Andrzej Gis

Reputation: 14306

Windows, .NET reading text under mouse cursor

Is it possible to get the text under mouse cursor from a window by a program working in background?

Upvotes: 3

Views: 1587

Answers (3)

cjbarth
cjbarth

Reputation: 4479

Before you go to far down this path, have a look at AutoIt. There is a tool called "AutoIt Window Info" that will tell you if any of the Win32 libraries can see text in the window selected. If you can't see text there, then I would suggest that you use ManagedWinapi.dll, capture the window handle, use the Image property of the returned SystemWindow class and send that to an OCR library.

Upvotes: 0

riezebosch
riezebosch

Reputation: 2028

Yes you can using P/Ivoke. Some pointers:

I think you have to do a attach to thread input to be allowed to read the text from a control of another process.

Upvotes: 2

Juho
Juho

Reputation: 953

One way would be to get the mouse cursor position and a screenshot and then just read the pixels from the screenshot near the cursor.

Hardest part in this solution is recognizing the text from picture but there should be libraries for that somewhere.

Upvotes: 1

Related Questions