Skip to content

Instantly share code, notes, and snippets.

@zsimic
Last active December 13, 2020 03:58
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 zsimic/eb8c7f08bab4e3ab469115e178b5e078 to your computer and use it in GitHub Desktop.
Save zsimic/eb8c7f08bab4e3ab469115e178b5e078 to your computer and use it in GitHub Desktop.
; -- 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