Caption = "If Ignore CAPS LOCK is NOT Checked. Then the only the value of the shiftstate parameter needs to be checked. If CAPS LOCK is ON and the Shift key is hit, it will result in a shiftstate value of 0."
Height = 1035
Left = 150
TabIndex = 4
Top = 2160
Width = 3585
End
Begin Label Label2
Caption = "If Ignore CAPS LOCK is Checked. Then the physical Shift Key must not be hit with F4, and the physical Shift Key must be hit with F3 in order to trigger the Beep."
Height = 855
Left = 150
TabIndex = 3
Top = 1110
Width = 3585
End
Begin Label Label1
Caption = "Hot Keys are F4 and Shift-F3, they will cause a Beep and toggle the state of the option button."
Height = 585
Left = 480
TabIndex = 0
Top = 120
Width = 2925
End
Option Explicit
Declare Function GetKeyState% Lib "user" (ByVal vkey%)
Const VK_CAPITAL = &H14
Const VK_F3 = &H72
Const VK_F4 = &H73
Sub Command1_Click ()
Unload Me
End Sub
Sub HookKbd1_KbdHook (keycode As Integer, keystate As Long, shiftstate As Integer, discard As Integer)
Dim capslockstate%
'Trigger on the Key Down, ignore Key Up
If keystate And &H80000000 Then Exit Sub
capslockstate% = GetKeyState(VK_CAPITAL)
Select Case keycode
Case VK_F3 'Shift-F3 will cause a beep
If IgnoreCapsLock.Value Then
' Do an exclusive Or on the Caps Lock state and
' the shiftstate parameter - if True then indicates
' that the shift key was physically hit.
If (capslockstate% Xor shiftstate) Then
Beep
Toggle.Value = Not Toggle.Value
End If
Else
If shiftstate Then
Beep
Toggle.Value = Not Toggle.Value
End If
End If
Case VK_F4 'F4 will cause a beep
If IgnoreCapsLock.Value Then
' Do an exclusive Or on the Caps Lock state and
' the shiftstate parameter - if False then indicates