Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically trigger a copy or paste in c#

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.

like image 431
Crash893 Avatar asked Dec 12 '22 23:12

Crash893


2 Answers

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.

like image 118
Dmitry Brant Avatar answered Dec 15 '22 13:12

Dmitry Brant


SendKeys.Send("^c");
like image 35
Crash893 Avatar answered Dec 15 '22 12:12

Crash893