VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

SendKeys for Vista

Ray B Dutton  (1 Submission)   Windows API Call/Explanation   Intermediate   Wed 3rd February 2021

Replaces the Visual Basic SendKeys statement which will not work in Vista. Uses the API call to the keybd_event to send characters and control codes. I have not extensively tested this routine, but it works for all the programs I have written to control external programs. The "WAIT" option is handled for compatibility, but is not implemented.

Inputs
Since this subroutine is named SendKeys, in most cases there is no need to re-code. Just place the new SendKeys subroutine in a public section of your project. However, you can no longer depend on the "WAIT" option. It is ignored in the new SendKeys.

Assumes
I did not bother to re-create the triple code SendKeys function such as +(AC). My replacement sends only the control key (+) key and the "A" as a double key, but it sends the "C" as just a capitol "C".

Side Effects
I have not tested this routine in anything other than Visual Basic 5.0. I did not bother with some of the control fuctions like {BREAK}, {PRTSCR}, etc. You may want to.

API Declarations
Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long

Rate SendKeys for Vista (4(4 Vote))
SendKeys for Vista.bas

SendKeys for Vista Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters