VB Code:
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
Private Const VK_CAPITAL = &H14
Private Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
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' or VK_SCROLL as desired.
If KeyboardBuffer(VK_CAPITAL) And 1 Then
KeyboardBuffer(VK_CAPITAL) = 0
Else
KeyboardBuffer(VK_CAPITAL) = 1
End If
SetKeyboardState KeyboardBuffer(0)