I want to read the text that the mouse pointer points at in other window.
For example, move the mouse pointer to some text,
middle click and get the word in any other window.
Just like "Babylon translator" does.
I want to do this, because I want to write a program
  that the user can point and click any text
  and the program would fetch the text and copy to the clipboard
  or look up the Goggle the selected word.
The key technique is how to read the texts that the mouse pointer point at in any other window.
Could anybody show how to accomplish this?
Posted on 2005-11-15 23:47:12 by guidry
You can try looking at SetCapture() - if that isn't enough, use SetWindowsHookEx to set a mouse hook.
Posted on 2005-11-16 00:07:50 by f0dder
As f0dder said, use SetCapture, and on WM_MOUSEMOVE:

mov WindowText[0],0
invoke GetCursorPos,addr pt
invoke WindowFromPoint,addr pt
invoke GetWindowText,eax,addr WindowText,300

Might have to use ChildWindowFromPointEx too - I haven't tested the code above.
Posted on 2005-11-16 02:11:58 by Ultrano
SetCapture or SetWindowsHookEx  enables the program to read data from non-client windows.
WindowFromPoint(x,y) just gets the handle of  the desired window.
And GetwindowText gets all words or the title in that window.
What I need is to capture the word at which mouse pointer points.
I try to do this because I'd like to write a one-click dictionary program,
  which requires to get the single word or phrase that the pointer point at.
How can I accomplish this?
How do I know this word's position in the desired window text?
Help me, please!
Posted on 2005-11-19 04:00:08 by guidry
1. find out whether the mouse points to an edit, or not
2. get edit's coords
4. find out which line the mouse points to
5. get that line
6. copy the text from pointed character to the left and from pointed character to the right

points 4 and 5 are for optimization purposes (it'll speed up the process a lot in cases where you have lots of text inside the edit) - you can as well read the whole text, but it can be slow/memory consuming sometimes.

If you want to get the text from something different than standard (or rich) edit control, then things get much more complicated (for example some apps display the text by drawing to offscreen device context -- without using any edit controls. you can as well go all the way, and read process' memory, but that's starting to be illegal :P ).
Posted on 2005-11-19 13:10:43 by ti_mo_n
Sounds great! Thank you very much!
However, I am not experienced enough...So I need more information...
Just take the Normal or Rich Edit for example...
Could you or anyone please tell me what are these related  Win32 API functions?

API for "find out whether the mouse points to an edit, or not"
API for "get edit's coords"
API for "find out which line the mouse points to"
API for "get that line"
API for get position of "pointed character" in the edit string

or any workable source code for ASM or C
(not C++ with MFC because codes with MFC are hard to translate to ASM)

Help me please!
Posted on 2005-11-20 06:53:47 by guidry
Use EM_CHARFROMPOS  Message to retrieve information about the character closest to a specified point ?

Right? any more information?
Posted on 2005-11-20 18:22:21 by guidry
1. WindowFromPoint / ChildWindowFromPoint pair
2. GetWindowRect
3, 4, 5. EM_GETSCROLLPOS, EM_STREAMOUT, EM_CHARFROMPOS, EM_LINEFROMCHAR

Everything is in the SDK. Read about (rich)edit controls.
Posted on 2005-11-21 00:33:09 by ti_mo_n
Thanks for those who kindly helped me.
It's so nice of you to give me advices.
Posted on 2005-11-21 17:49:53 by guidry