0

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?

Inaimathi
  • 13,853
  • 9
  • 49
  • 93
Dominic
  • 159
  • 1
  • 3
  • 13

1 Answers1

1

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.")

Sastreen
  • 597
  • 4
  • 13
  • Ok, so I can send the stream to the clipboard using My.Computer object, then do the SendKeys.Send("^V") ? – Dominic Jun 17 '15 at 18:49
  • @Dominic Yes exactly. If you need help sending it to the clipboard let me know. I've edited my post to help with this. – Sastreen Jun 18 '15 at 10:37