Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Long
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_CAPITAL = &H14
Private Const VK_NUMLOCK = &H90
Private Sub Command1_Click()
If GetKeyState(VK_CAPITAL) And &H1 Then
Else
'按下NUMLOCK 键
Call keybd_event(VK_NUMLOCK , 0, 0, 0)
Call keybd_event(VK_NUMLOCK , 0, KEYEVENTF_KEYUP, 0)
End If
End Sub
Private Sub Command2_Click()
If GetKeyState(VK_NUMLOCK ) And &H1 Then
'按下NUMLOCK 键
Call keybd_event(VK_NUMLOCK , 0, 0, 0)
Call keybd_event(VK_NUMLOCK , 0, KEYEVENTF_KEYUP, 0)
End If
End Sub