Last active
April 10, 2022 16:02
-
-
Save jmtame/24d4987aa712b3274bde0decc1b25a79 to your computer and use it in GitHub Desktop.
autohotkey script for microsoft keyboard to use macos-like keyboard layout
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
; I use a Microsoft Sculpt Ergonomic Keyboard because they're great keyboards. | |
; The problem is: I don't like Windows shortcuts. I like how the MacOS shortcuts work. | |
; I also don't like Mac keyboards because they're not ergonomic. | |
; This script remaps the keys on a Microsoft keyboard to behave more like a Mac keyboard. | |
SC044:: ; f10 | |
SoundSet, +1,, Mute | |
return | |
SC057:: ; f11 | |
SoundSet -10 | |
return | |
SC058:: ; f12 | |
SoundSet +10 | |
return | |
; ----- When saving, update the code in Notion. I'm not using Dropbox to store this file. | |
; Copying | |
!c:: | |
Send ^c | |
return | |
; Pasting | |
!v:: | |
Send ^v | |
return | |
; Print (or Play in Unity) | |
!p:: | |
Send ^p | |
return | |
; Select all | |
!a:: | |
Send ^a | |
return | |
; Window Hide | |
!h::WinMinimize, A | |
; Saving | |
!s:: | |
Send ^s | |
return | |
; Cutting | |
!x:: | |
Send ^x | |
return | |
; Opening | |
!o:: | |
Send ^o | |
return | |
; Finding | |
!f:: | |
Send ^f | |
return | |
; Undo | |
!z:: | |
Send ^z | |
return | |
; Redo | |
!y:: | |
Send ^y | |
return | |
; New tab | |
!t:: | |
Send ^t | |
return | |
; close tab | |
!w:: | |
Send ^w | |
return | |
; Close windows | |
!q:: | |
Send !{F4} | |
return | |
; minimize windows | |
!m:: | |
WinMinimize,a | |
return | |
; switch language | |
!space:: | |
Send !{Shift} | |
return | |
; open link in new tab (alt+click) | |
#IfWinActive ahk_class Chrome_WidgetWin_1 | |
!LButton:: | |
Send ^{Click} | |
return | |
#IfWinActive | |
; Alt + space triggers windows start menu | |
LAlt & Space::Send ^{ESC} | |
; Show desktop | |
!d:: ComObjCreate("Shell.Application").ToggleDesktop() | |
return | |
; In Unity, alt+d should be duplicate if the window is active | |
#IfWinActive ahk_exe Unity.exe | |
!d:: | |
Send ^d | |
#IfWinActive | |
; ----------------------------------------------------------- | |
; Chrome | |
; ----------------------------------------------------------- | |
!r:: | |
Send ^r | |
return | |
!1:: | |
Send ^1 | |
return | |
!2:: | |
Send ^2 | |
return | |
!3:: | |
Send ^3 | |
return | |
!4:: | |
Send ^4 | |
return | |
!5:: | |
Send ^5 | |
return | |
!6:: | |
Send ^6 | |
return | |
!7:: | |
Send ^7 | |
return | |
!8:: | |
Send ^8 | |
return | |
!9:: | |
Send ^9 | |
return | |
!l:: | |
Send ^l | |
return | |
; Ensures a consistent starting directory. | |
SetWorkingDir %A_ScriptDir% | |
; ----------------------------------------------------------- | |
; ----------------------------------------------------------- | |
; Sane Navigation Shortcuts with Alt | |
; | |
; An easier and more consistent way to send PgUp/PgDown/ | |
; Home/End for laptops with no dedicated keys for these | |
; functions. | |
; | |
; The following shortcuts recruit Alt as a better Fn key, | |
; since Alt is on both sides of the keyboard and isn't used | |
; much otherwise. | |
; | |
; Alt + left arrow = Home | |
; Alt + right arrow = End | |
; Alt + up arrow = PgUp | |
; Alt + down arrow = PgDn | |
; | |
; Each Alt key (right and left) must be referred to specific- | |
; ally, else problems arise. Also, it's sometimes necessary | |
; to leave out {Alt Up}. | |
; ----------------------------------------------------------- | |
; Win + Alt + Left Arrow sends Win-Home | |
#!Left:: send {Win Up}{Alt Up}#{Home} | |
; PgUp/Down + Home/End shortcuts (Alt + arrow keys): | |
; first using right-Alt | |
; + arrow keys | |
>!Up::send {RAlt Up}{PgUp} | |
>!Down::send {RAlt Up}{PgDn} | |
>!Left::send {RAlt Up}{Home} | |
>!Right::send {RAlt Up}{End} | |
; Ctrl + PgUp/Down, Home/End | |
; function for text editors and word processors | |
>!^Up::send {Alt Up}{Crtl Up}^{PgUp} | |
>!^Down::send {Alt Up}{Crtl Up}^{PgDn} | |
>!^Left::send {Alt Up}{Crtl Up}^{Home} | |
>!^Right::send {Alt Up}{Crtl Up}^{End} | |
; Shift + PgUp/Down, Home/End | |
; function for text editors and word processors | |
>!+Up::send {Alt Up}{Shift Up}+{PgUp} | |
>!+Down::send {Alt Up}{Shift Up}+{PgDn} | |
>!+Left::send {Alt Up}{Shift Up}+{Home} | |
>!+Right::send {Alt Up}{Shift Up}+{End} | |
; Ctrl + Shift + PgUp/Down, Home/End | |
; function for text editors and word processors | |
>!^+Up::send {Alt Up}{Crtl Up}{Shift Up}^+{PgUp} | |
>!^+Down::send {Alt Up}{Crtl Up}{Shift Up}^+{PgDn} | |
>!^+Left::send {Alt Up}{Crtl Up}{Shift Up}^+{Home} | |
>!^+Right::send {Alt Up}{Crtl Up}{Shift Up}^+{End} | |
; now using left Alt too | |
; + arrow keys | |
<!Up::send {RAlt Up}{PgUp} | |
<!Down::send {RAlt Up}{PgDn} | |
; Alt + left becomes jump to beginning of line or end of line for apps that are not browsers | |
#If !(WinActive("ahk_class MozillaWindowClass") or WinActive("ahk_class Chrome_WidgetWin_1") or WinActive("ahk_class CabinetWClass")) | |
<!Left::send {RAlt Up}{Home} | |
<!Right::send {RAlt Up}{End} | |
#If | |
; Notion is technically Chrome, so let's add it as an exception | |
#If WinActive("ahk_exe Notion.exe") | |
<!Left::send {RAlt Up}{Home} | |
<!Right::send {RAlt Up}{End} | |
#If | |
; Ctrl + PgUp/Down, Home/End | |
; function for text editors and word processors | |
<!^Up::send {Alt Up}{Crtl Up}^{PgUp} | |
<!^Down::send {Alt Up}{Crtl Up}^{PgDn} | |
<!^Left::send {Alt Up}{Crtl Up}^{Home} | |
<!^Right::send {Alt Up}{Crtl Up}^{End} | |
; Shift + PgUp/Down, Home/End | |
; function for text editors and word processors | |
<!+Up::send {Alt Up}{Shift Up}+{PgUp} | |
<!+Down::send {Alt Up}{Shift Up}+{PgDn} | |
<!+Left::send {Alt Up}{Shift Up}+{Home} | |
<!+Right::send {Alt Up}{Shift Up}+{End} | |
; Ctrl + Shift + PgUp/Down, Home/End | |
; function for text editors and word processors | |
<!^+Up::send {Alt Up}{Crtl Up}{Shift Up}^+{PgUp} | |
<!^+Down::send {Alt Up}{Crtl Up}{Shift Up}^+{PgDn} | |
<!^+Left::send {Alt Up}{Crtl Up}{Shift Up}^+{Home} | |
<!^+Right::send {Alt Up}{Crtl Up}{Shift Up}^+{End} | |
; Alt + left/right arrow keys conflicts with existing short- | |
; cuts in file/internet browsers (plus Alt + up arrow con- | |
; flicts in Explorer). So, use OS X keyboard shortcuts in | |
; those programs, instead (plus an imperfect compromise | |
; to replace Alt + up). | |
; | |
; In OS X, to go back/forward, Command + left and right | |
; brackets ('[]') are used. So, the same are set up here, | |
; except using Alt instead of Command. | |
; | |
; An imperfect replacement for Alt-Up (or Command-Up in | |
; OS X) is Alt + '.' (period). The mnemonic for this is that | |
; '..' is used on the command line to go up one level in a | |
; directory. | |
; --Test if browser or Explorer is active window-- | |
#If WinActive("ahk_class MozillaWindowClass") or WinActive("ahk_class Chrome_WidgetWin_1") or WinActive("ahk_class CabinetWClass") | |
; Alt-arrow navigation shortcuts for those programs | |
<!.::send !{Up} | |
<![::send !{Left} | |
<!]::send !{Right} | |
>!.::send !{Up} | |
>![::send !{Left} | |
>!]::send !{Right} | |
; --end Alt shortcuts-- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment