|
-
Nov 6th, 2001, 03:56 PM
#1
Thread Starter
Lively Member
keybd_event Function
I have been playing around just to see how things work. I thought I might try to turn on Caps Lock, Scroll Lock, and Num Lock in code... pretty simple stuff really, but I just wanted to try. Anyway, I can't get Num Lock to work. I've done it the same as the others. Anyone know why? I thought that possibly the virtual key constant for VK_NUMLOCK might be wrong... but I don't know. I used http://www.vbapi.com/ref/other/virtualkeycodes.html as my resource.
Here's my code:
Private Declare Sub keybd_event Lib "user32.dll" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const KEYEVENTF_KEYUP = &H2
Const VK_CAPITAL = &H14
Const VK_NUMLOCK = &H90
Const VK_OEM_SCROLL = &H91
'press Caps Lock
Private Sub Command1_Click()
keybd_event VK_CAPITAL, 0, 0, 0
keybd_event VK_CAPITAL, 0, KEYEVENTF_KEYUP, 0
End Sub
'press Num Lock
Private Sub Command2_Click()
keybd_event VK_NUMLOCK, 0, 0, 0
keybd_event VK_NUMLOCK, 0, KEYEVENTF_KEYUP, 0
End Sub
'press Scroll Lock
Private Sub Command3_Click()
keybd_event VK_OEM_SCROLL, 0, 0, 0
keybd_event VK_OEM_SCROLL, 0, KEYEVENTF_KEYUP, 0
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|