Is it possible to get the text under mouse curs开发者_开发百科or from a window by a program working in background?
Yes you can using P/Ivoke. Some pointers:
- WindowFromPoint
- ChildWindowFromPoint
- AttachThreadInput
- GetWindowText
I think you have to do a attach to thread input to be allowed to read the text from a control of another process.
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.
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.
精彩评论