Function CapsLock() As Boolean
CapsLock = (GetKeyState(VK_CAPITAL) And 1 = 1)
End Function
Private Sub Form_Load()
If CapsLock() = 1 Then Label1 = "On" Else Label1 = "Off"
End Sub
Private Sub cmdToggle_Click()
GetKeyboardState kbArray
kbArray.kbByte(VK_CAPITAL) = _
IIf(kbArray.kbByte(VK_CAPITAL) = 1, 0, 1)
SetKeyboardState kbArray
If CapsLock() Then
Label1.Caption = "On"
Else
Label1.Caption = "Off"
End If
End Sub
Private Sub cmdTurnOn_Click()
GetKeyboardState kbArray
kbArray.kbByte(VK_CAPITAL) = 1
SetKeyboardState kbArray
If CapsLock() Then
Label1.Caption = "On"
Else
Label1.Caption = "Off"
End If
End Sub
Private Sub cmdTurnOff_Click()
GetKeyboardState kbArray
kbArray.kbByte(VK_CAPITAL) = 0
SetKeyboardState kbArray
If CapsLock() Then
Label1.Caption = "On"
Else
Label1.Caption = "Off"
End If
End Sub
|