Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Declare Function keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) As Boolean
Private Const KEYEVENTF_KEYDOWN = &H0 '按下
Private Const KEYEVENTF_KEYUP = &H2 '弹起
Private Sub Command1_Click()
If GetKeyState(&H14) = 0 Then
ret = keybd_event(&H14, 0, KEYEVENTF_KEYDOWN, 0)
ret = keybd_event(&H14, 0, KEYEVENTF_KEYUP, 0)
Else
ret = keybd_event(&H14, 0, KEYEVENTF_KEYDOWN, 0)
ret = keybd_event(&H14, 0, KEYEVENTF_KEYUP, 0)
End If
End Sub
'LWIN = &H5B
'RWIN = &H5C
'vbKeyCapital &H14 CAPS LOCK 键
'vbKeyNumlock &H90 NUM LOCK 键
'Scroll Lock &H91