Adam Caudill

Security Leader, Researcher, Developer, Writer, & Photographer

My greatest work!

This post was imported from an old blog archive, and predates the creation of AdamCaudill.com.

I am thrilled!

I have done it!

I have completed the most useful program ever developed… at least if you are like me and hit Caps-Lock every couple minutes. I know, I had you all excited, but although this really isn’t that great, it was fun to hack together and at least I’ll use it. You can get the exe, sounds and code here. To exit it, just press & hold caps-lock & ctrl for a couple seconds. It’s really a very simple application, the core is in this code:

Private Sub MonitorCapsLock()
  Dim blnLastWasTrue As Boolean
  Do
    If CBool(GetKeyState(VK_CAPITAL)) = True Then
        'caps-lock is on
        If (CBool(GetAsyncKeyState(VK_LCONTROL)) = True) _
            And (CBool(GetAsyncKeyState(VK_CAPITAL)) = True) Then
            'control is down, time to exit
            oThread.Abort()
        Else
            'play the alarm
            If blnLastWasTrue = False Then
                blnLastWasTrue = True
                PlayWav(False, AppPath() & "Woman Screem.wav")
            End If
        End If
    Else
        blnLastWasTrue = False
    End If
    Threading.Thread.Sleep(750)
  Loop
End Sub

It all boils down to three APIs, GetKeyState, GetAsyncKeyState and PlaySound to play the wav file. If you have any improvements or suggestions, let me know.

Adam Caudill