Behold the Caps Lock key, a vestige of a previous era and scourge to the modern user. I never use the Caps Lock key, and I get the impression that most users don’t. Yet it still becomes accidentally activated, producing bothersome effects.
AutoHotkey is capable of disabling the Caps Lock key. AutoHotkey is a tiny program that lets you assign behavior to keystrokes, mouse actions, and more. It is actually very powerful and can run extremely complex scripts, which makes it somewhat intimidating. For these reasons I avoided it, although Lifehacker frequently praised it, until I finally took the plunge. I’ll never go back.
SetCapsLockState, AlwaysOff
Disabling the Caps Lock key is a one liner. But that seems like such a waste of a key; can’t I do something useful with it? Yes I can!
SetCapsLockState, AlwaysOff CapsLock:: if (!capsDown) { capsDown := 1 Process, Exist, trillian.exe if (%ErrorLevel% == 0) { Run, C:\Program Files (x86)\Trillian\trillian.exe } else { IfWinActive, ahk_class TSSHELLWND WinActivate, ahk_class Shell_TrayWnd IfWinExist, Trillian WinActivate else SendInput, +^{t} } } return CapsLock Up:: capsDown := 0 IfWinExist, Trillian SendInput, +^{t} return
This script shows my Trillian contact list while I hold Caps Lock and hides it when I release the key. Now with one keystroke I can easily peek to see who is online and return to my work undisturbed. It even launches Trillian if it is not already running. I greatly prefer this to Trillian’s dock/autohide feature because I was always making Trillian pop open when I didn’t mean to.
If you want to use this script, be sure to set the run command to Trillian’s location on your computer, and assign the Hotkey Ctrl+Shift+T to the action “Contact List: Toggle Visible” (this setting is found within Automation in Trillian’s Preferences).
I’m sure this script could be adapted to toggle other programs and Instant Messengers.
Note: This works on three of my computers running Windows 7 and Trillian Astra, but I imagine it would work with Trillian 3 and other versions of Windows.
Here is a version that works with Pidgin. It’s kinda hacky, but works well enough most of the time.
;SetCapsLockState, AlwaysOff ;Remove semicolon to disable capslock
^CapsLock:: ;Control + Capslock. Remove ^ to make it just Capslock
if (!capsDown) ;If CapsLock is not currently being held
{
capsDown := 1 ;Indicate that Capslock is currently being held
Run, C:\Program Files\Pidgin\pidgin.exe ;Run Pidgin. This will start it if it’s not running, and pull up the buddy list if it is.
}
return
^CapsLock Up:: ;Again, Control + CapsLock. Remove ^ to make it just Capslock.
capsDown := 0 ;Indicate that Capslock is NOT currently being held
IfWinExist, ahk_class gdkWindowToplevel ;If the Pidgin Buddy list is present
WinHide, ;Hide it
return
Note: By default this script uses Ctrl+CapsLock as I occassionally find CapsLock useful. However, to stop it being a nuisance, I have another little AHK code snippet…
Capslock:: ;;Beep once when capslock turned on, twice when turned off
GetKeyState, state, CapsLock, T
If (state := GetKeyState(“Capslock”, “T”)) {
SetCapsLockState, Off
SoundBeep, 600, 250
SoundBeep, 600, 250
Return
}
SetCapsLockState, On
SoundBeep, 600, 750 ; Play the default pitch and duration.
Return
As the comment at the start of the script says, this makes the computer produce one 750ms beep when caps lock is turned on, and two 250ms beeps when it’s turned off. Helps prevent accidental activation.
Hope you find these useful!