Sending Shift, CTRL, Alt key down from VB

darinf

New member
Joined
Apr 16, 2007
Messages
4
Programming Experience
Beginner
I am writing a driver for a custom external USB controller.

I want to be able to emulate keyboard keystrokes. I know I can send keys to other applications through VB, but I can't figure out how to have my external key pad emulate the Shift, Control, or Alt key being held down.

For example, I want my VB app to detect a key being pressed on the external keypad and then have Windows work like the Shift key is being held down or the Control Key or the Alt key.

Essentially I want my external keypad to do exactly the same thing as the regular keyboard Shift, Control and Alt.

Is there a function in VB to send a "Control Lock" or "Alt Lock"? Even setting the "Shift Lock" isn't exactly the same as holding down the Shift key.

I hope that makes sense.

Any help pointing me in the right direction would be greatly appreciated.

Thanks in advance,
-Darin Fong
 
Look into the SendKeys class, it tells you how you can send the CTRL, ALT ,SHIFT modifiers with VB.NET (although I don't see how it have anything to do with writing a hardware driver?).
 
As far as I understand, SendKeys will only send keystrokes. I know I can send , for example, a CTRL-A keystroke, but I want to have VB "hold down" the control key, NOT send a Control keystroke. See the difference?

I don't want to send a keystroke. I want VB to send a CONTROL key down (and stay down) command.

I hope that's more clear.

It looks like it can be done in VB 6 using the VBsendkeys code, but I can't seem to get that translated to VB .NET. Any Ideas?

I am not writing a "driver" per se. The driver exists. I am trying to write a program to remap the keys on an external keypad to Windows keystrokes.

Thanks for your help,
-Darin
 
I figured it out by looking at this sample code:

http://www.codeproject.com/vb/net/screen.asp

He uses the keyboard API:

Declare Function keybd_event Lib "user32" Alias "keybd_event" _
(ByVal bVk As Byte, ByVal bScan _
As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) As Long

And then a statement like this:

keybd_event(VK_SHIFT, 0, 0, 0)
To "press" the shift key down

keybd_event(VK_SHIFT, 0, 2, 0)
To "release" the shift key

-Darin
 
Back
Top