Solved

capture selected or highlighted text in c#.net windows application

Posted on 2009-05-19
5
1,903 Views
Last Modified: 2013-12-17
Hi,
i am developing windows application in c#.net.
I need to be able to copy the text from any application or document where text can be highlighted or selected(.txt, .doc, .pdf, html, .chm, .hlp, ppt, xls).

I think it is possible. but how it is possible?

appreciate any help.
Thanks in advance
0
Comment
Question by:nissiinfotechpvtltd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
ID: 24421375
You mean, I think, you need to be able to paste the text, is that correct? You can do so by using the clipboard functions:

// get text from clipboard, which a user copied in another app
string clipBoardText = "";
if(Clipboard.ContainsText())
    clipBoardText = Clipboard.GetText();

Open in new window

0
 

Author Comment

by:nissiinfotechpvtltd
ID: 24430961
Hi,
i am developing windows application in c#.net.
how to capture selected or hightlighted text from other applications such as pdf, chm,hlp etc..
It is possible. there are many softwares to do it.
how to do it?

pls help me
0
 
LVL 39

Assisted Solution

by:abel
abel earned 500 total points
ID: 24431121
I believe I just explained that. Or I don't understand you correctly. If you want to do the copy from your application, you can use a SendKeys("^{C}"), which will send the Ctrl-C (copy) to the other application, if it has the focus.

Other methods may exist, but they can become extremely complex, as it highly depends on what kind of application, what kind of windows / edit classes (window-classes, not object-classes) they use and whether they are accessible from another thread. If the behave neatly, you can try sending messages to the window that is a textbox, the easy thing would be to use a WM_COPY message, but that may not be enough. If SendKeys does not work, you can use this post: http://bytes.com/groups/net-c/255335-get-selected-text-other-process (see below). It will work on the majority of cases, but not all.
0
 
LVL 39

Expert Comment

by:abel
ID: 25218425
Use want to copy text by sending keys. First answer shows how to do it without, second shows how to do it with and gives other methods as well. Suggestion: points split between http:24431121 and http:24421375
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question