Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-05-19
5
Medium Priority
?
2,039 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 1500 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 1500 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

885 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