Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Capturing selected text - is it possible?

Please help!!
I am writing a dialog based application (I am relatively new to this) and
before I display the dialog I want to get the currently selected text in
another running application. I do not know if this is possible - any tips
or help would be greatly appreciated!! Thanks
[296 byte] By [Tom] at [2007-11-10 12:52:01]
# 1 Re: Capturing selected text - is it possible?
if you have Spy++ (which comes with VC++ e.g.) on your system, examine the
app from where you want to get the text, and look for the particular text
control. Once you've found it in the spy's list, right click it and choose
properties. Write down the control ID.
Now your app can call FindWindow or EnumWindows to get the main window handle
of the running application and then you can call GetDlgItem to get the
current window handle of the text control. Retrieving its contents is done by
SendMessage with the required message id's (see Win API).

Hth,
Christof

Tom wrote:

> Please help!!
> I am writing a dialog based application (I am relatively new to this) and
> before I display the dialog I want to get the currently selected text in
> another running application. I do not know if this is possible - any tips
> or help would be greatly appreciated!! Thanks
Christof Helm at 2007-11-11 20:40:31 >