Get system currently selected text

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I'm facing a problem with my Windows Forms app. When my main Form is
activated, I want to capture the currently selected text from any other
programs (Word, IE, Notepad, ...) for further processing.

How could I do that ? I guess I have to rely on P/Invoke, but no idea how to
do it. Anybody can help me ?

Thanks in advance

Dotnetjunky
 
If you manage to get a handle to the window, then you can use
GetWindowText API to get the text from that window. But finding the
window is the tricky part.

Take a look at this article written in VC++
http://www.codeproject.com/dialog/windowfinder.asp

It does all that you want to do, you will probably have to use lot of
P/Invoke to translate that functionality to .Net

These sites will help
http://www.pinvoke.net/
http://blogs.msdn.com/adam_nathan


Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
 
Back
Top