Press The Caps Lock/Num Lock Button
'Add a module to your project (In the menu choose
Project -> Add Module, Then click Open)
'Add 1 CommandButton to your form (named Command1).
'Insert the following code to your module:
Declare Sub GetKeyboardState Lib "user32" (lpKeyState As Any)
Declare Sub SetKeyboardState Lib "user32" (lpKeyState As Any)
Public Const VK_CAPITAL = &H14
Public Const VK_NUMLOCK = &H90
'Insert the following code to your form:
Private Sub Command1_Click()
ReDim KeyboardBuffer(256) As Byte
GetKeyboardState KeyboardBuffer(0)
'This example show you how to press the Caps Lock button. if you
want
'to press the Num Lock button, Replace all the following 3 'VK_CAPITAL'
'with 'VK_NUMLOCK'.
If KeyboardBuffer(VK_CAPITAL) And 1 Then
KeyboardBuffer(VK_CAPITAL) = 0
Else
KeyboardBuffer(VK_CAPITAL) = 1
End If
SetKeyboardState KeyboardBuffer(0)
End Sub