views:

343

answers:

3

I have a program that I'm working on that register global hotkeys

I would like to use that ability to trigger highlighted text or data to be copied to the clipboard and then read from the clipboard into a variable in my program

which i will later use in reverse to paste it back out.

(example ctrl+1 copys to quque #1 and alt+1 pasts what is in quque 1)

thanks so much.

+4  A: 

You mean... like this?

Clipboard.SetText("whatever");

...or are you talking about copying text from any arbitrary window in another application? The latter is not trivial at all.

Dmitry Brant
1) yes I am talking about taking text from the global clipboard 2) i figured it would be hard to see the text highlighted on other programs (IE Firefox notepad word etc) but it woudlnt be hard to send a "copy event" to the os and have it do all the hard work for me
Crash893
+1  A: 

Well, you could possibly do a P/Invoke with SendMessage or even better SendInput Win32 APIs. That should be enough for you to simulate almost any key strokes.

James

James Poulose
do you have a link to an example?
Crash893
+1  A: 
SendKeys.Send("^c");
Crash893