Get word under mouse cursor in Windows

Greetings to all

My friend and I are discussing the possibility of a new project: a translation program that will display the translation whenever you hover over any word in any control, even a static, unchangeable one. I know that there are many browser plugins to do similar things on web pages; we are thinking about how we will do this system-wide (on Windows).

Of course, the main difficulty is to determine the word that the user is in. I know MSAA and Automation, but as far as I can tell, these things let you get the entire contents of the control, not the specific word the mouse is over.

I came across this (proprietary) application that does exactly what we want to do: http://www.gettranslateit.com/

Somehow they can get the exact word that the user is in almost any application (it seems he has problems with several applications, in particular with Windows Explorer). It even captures text from explicitly drawn controls. At first I thought I needed to use OCR. But even when I compress the font so far that the text becomes a completely unreadable blob, it can still recognize words. (And yet, he won’t know anything if I change the font to Wingdings. But maybe this is by design?)

Any ideas on how he accomplishes this seemingly impossible task?

EDIT: Wingdings, , , OCR.

+3
2

GDI, , , .

+1

, GDI , . , WM_GETFONT, , , , , - GetTextExtentPoint32, , . , ...

dumpbin /imports , API .

+1

Source: https://habr.com/ru/post/1768344/


All Articles