Crash893
Crash893

Reputation: 11702

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.

Upvotes: 4

Views: 5771

Answers (3)

Crash893
Crash893

Reputation: 11702

SendKeys.Send("^c");

Upvotes: 5

James Poulose
James Poulose

Reputation: 39

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

Upvotes: 1

Dmitry Brant
Dmitry Brant

Reputation: 7709

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.

Upvotes: 7

Related Questions