Last active
May 17, 2016 06:10
-
-
Save aarmea/77da8c4d4caa027d8eee to your computer and use it in GitHub Desktop.
Caps Lock to Control and Escape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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