Solved

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

Posted on 2009-05-19
5
1,753 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
  • 3
5 Comments
 
LVL 39

Accepted Solution

by:
abel earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

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…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now