Last active
December 13, 2020 03:58
-
-
Save zsimic/eb8c7f08bab4e3ab469115e178b5e078 to your computer and use it in GitHub Desktop.
This file contains 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
; -- Remap Alt -> Ctrl on Windows (to behave like ⌘CMD+key on mac) | |
; Via https://www.autohotkey.com/docs/misc/Remap.htm | |
; This remaps Alt -> Ctrl completely, except for Alt+Tab and Alt+F4 | |
#SingleInstance ignore | |
SetCapsLockState, AlwaysOff ; disable caps lock entirely | |
CapsLock::return | |
RAlt::RCtrl ; Right Alt key is simply mapped to Ctrl, RAlt+Tab won't work as usual (only LAlt+Tab will) | |
LAlt:: | |
CancelAltRemap := false ; Allows to cancel the LAlt -> LCtrl remap in certain cases | |
Hotkey, *F4, F4Press, On | |
Hotkey, *Tab, TabPress, On | |
Send {LCtrl Down} ; Remap LAlt -> LCtrl | |
KeyWait, LAlt | |
if CancelAltRemap | |
Send {LAlt Up} ; Remap is cancelled | |
else | |
Send {LCtrl Up} ; Effective remap | |
Hotkey, *F4, F4Press, Off | |
Hotkey, *Tab, TabPress, Off | |
return | |
F4Press: | |
if (!CancelAltRemap) { | |
CancelAltRemap := true | |
Send {LCtrl Up} ; Undo the initiated remap | |
Send {LAlt Down} ; Press down LAlt instead | |
} | |
Send {Blind}{F4} | |
return | |
TabPress: | |
if (!CancelAltRemap) { | |
CancelAltRemap := true | |
Send {LCtrl Up} ; Undo the initiated remap | |
Send {LAlt Down} ; Press down LAlt instead | |
} | |
Send {Blind}{Tab} | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment