Emulate copy-paste from Keyboard wedge application in VB.net

13.5k views Asked by At

We have an application (written in VB 2005) that reads incoming characters on a virtual serial port (on which a Cognex barcode scanner is connected), validate the stream and send it to the focused object using the SendKeyscommand.

It has worked perfectly for years, but now customers have new software and the SendKeys no longer works for a specific field in this software (it works everywhere else but this field). They did some tests and found out that, when they copy-paste text, it works using ctrl-c, ctrl-v.

My question is: how can I emulate those keystroke from our application?

1

There are 1 answers

2
Sastreen On BEST ANSWER

With SendKeys, the control key is ^. Then any additional keys can follow.

So copy would be:

SendKeys.Send("^c")

And paste:

SendKeys.Send("^v")

Instead of copying, you can just directly put it on the clipboard (like you suggested), like: My.Computer.Clipboard.SetText("This is a test string.")