Skip to content

Instantly share code, notes, and snippets.

@aarmea
Last active May 17, 2016 06:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarmea/77da8c4d4caa027d8eee to your computer and use it in GitHub Desktop.
Save aarmea/77da8c4d4caa027d8eee to your computer and use it in GitHub Desktop.
Caps Lock to Control and Escape
; Maps {Caps Lock}+key to {Ctrl}+key and {Caps Lock} by itself to {Esc}.
; Does nothing on Remote Desktop windows to prevent conflicts.
; Modified from http://www.autohotkey.com/board/topic/104173-capslock-to-control-and-escape/?p=669777
SetCapsLockState Off ; This doesn't work on mstsc, so we don't attempt to resend CapsLock manually
SetTitleMatchMode, 2 ; String passed to IfWinActive can be anywhere in the window title
SetTitleMatchMode, Fast
CapsLock::
IfWinActive, Remote Desktop Connection
{
Return
}
IfWinActive, Virtual Machine Connection
{
Return
}
key=
Input, key, C L1 T1, {Esc}|{Backspace}
if (ErrorLevel = "EndKey:Backspace")
key = {Backspace}
if (ErrorLevel = "Max" or ErrorLevel = "EndKey:Backspace")
Send {Ctrl Down}%key%
KeyWait, CapsLock
Return
CapsLock up::
IfWinActive, Remote Desktop Connection
{
Return
}
IfWinActive, Virtual Machine Connection
{
Return
}
If key
Send {Ctrl Up}
else
if (A_TimeSincePriorHotkey < 1000)
Send, {Esc 2}
Return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment