Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mahmoudimus/4f2272563162d5e58a621470ab063efe to your computer and use it in GitHub Desktop.
Save mahmoudimus/4f2272563162d5e58a621470ab063efe to your computer and use it in GitHub Desktop.
AutoHotkey mappings to emulate OSX keyboard shortcuts on Windows
1. Use SharpKeys app to swap modifier keys.
LControl becomes Winkey
Winkey becomes LAlt
LAlt becomes LControl
This is not typical Mac Control-Alt-Command layout, but don't worry, we will make shortcuts work in the same manner your fingers are used to. The reason why we can't simply swap Win & Alt is because IntelliJ IDEA requires a lot of shortcuts with "Command" key (which would be Windows key in our case), and it's impossible to make them work well. So we stick to more traditional "Control"-shortcuts on the OS level. But, again, don't worry, in the end shortcuts physically will be the same os on Mac OS X.
2. Use AutoHotkey script "OS X keyboard for Windows" to remap basic shortcuts (see "OS X keyboard for Windows" AutoHotkey script).
3. For IntelliJ IDEA users:
3.1. Disable Winkey OS shortcuts (e.g. http://www.askvg.com/tip-how-to-disable-all-win-keyboard-shortcuts-hotkeys-in-windows/)
3.2. Use provided "" keymap.
http://codingmatters.blogspot.co.uk/2010/02/i-always-thought-its-not-possible-to.html
http://youtrack.jetbrains.com/issue/IDEA-119932
;
; AutoHotkey Version: 1.x
;
;
; --------------------------------------------------------------
; Emulate OSX keymap layout
; on Windows
; --------------------------------------------------------------
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance force
GroupAdd, IntelliJ_Group, ahk_class SunAwtFrame
GroupAdd, IntelliJ_Group, ahk_class SunAwtDialog
return
; --------------------------------------------------------------
; NOTES
; --------------------------------------------------------------
; ! = ALT
; ^ = CTRL
; + = SHIFT
; # = WIN
; Disable start menu on left winkey
LWin & vk07::return
LWin::return ; (or run Launchy)
; Open start menu on "CMD" + Space
LCtrl & Space::Send ^{Esc}
; Switching between windows
LCtrl & Tab::AltTab
; win + arrows for window alignment
; TODO
;following section remaps alt-delete keys to mimic OSX
;command-delete deletes whole line
^BS::Send {LShift down}{Home}{LShift Up}{Del}
;alt-function-delete deletes next word
!Delete::Send {LShift down}{LCtrl down}{Right}{Lctrl up}{LShift Up}{Del}
;alt-delete deletes previous word
!BS::Send {LShift down}{LCtrl down}{Left}{Lctrl up}{LShift Up}{Del}
;following section mimics command-q and command-w
;behaviour to close windows
^SC011::^F4 ;w
^SC010::Send {LAlt down}{Ctrl up}{F4}{LAlt up} ;q
; Ctrl+H (cmd+h) to hide window
^SC023::WinMinimize,a ;h
;following section remaps alt-arrow and command-arrow
;keys to mimic OSX behaviour
^Up::Send {Lctrl down}{Home}{Lctrl up}
^Down::Send {Lctrl down}{End}{Lctrl up}
^Left::Send {Home}
^Right::Send {End}
^+Up::Send {Shift down}{Lctrl down}{Home}{Lctrl up}{Shift up}
^+Down::Send {Shift down}{Lctrl down}{End}{Lctrl up}{Shift up}
^+Left::Send {Shift down}{Home}{Shift up}
^+Right::Send {Shift down}{End}{Shift up}
; The following remapings should NOT be applied to IntelliJ windows
#IfWinNotActive, ahk_group IntelliJ_Group
; IntelliJ IDEA has it's own shortcuts for these
!Up::Send {PgUp}
!Down::Send {PgDn}
!Left::Send ^{Left}
!Right::Send ^{Right}
!+Up::Send {Shift down}{PgUp}
!+Down::Send {Shift down}{PgDn}
!+Left::Send {Shift down}{Lctrl down}{Left}{Lctrl up}{Shift up}
!+Right::Send {Shift down}{Lctrl down}{Right}{Lctrl up}{Shift up}
#IfWinNotActive
; Language switching
; NB! The trick here is to send winkey/ctrl up at the proper time
^Space::Send {LAlt down}{LCtrl up}{LShift down}{LShift up}{LAlt up}
; Tabs switching
^!Left::Send {LCtrl down}{LShift down}{Tab}{LShift up}{LCtrl up}
^!Right::Send {LCtrl down}{Tab}{LCtrl up}
; Switching between windows of the same app
^SC056:: ; Next window Cmd+\ (left from Z)
WinGetClass, ActiveClass, A
WinGet, WinClassCount, Count, ahk_class %ActiveClass%
IF WinClassCount = 1
Return
Else
WinSet, Bottom,, A
WinActivate, ahk_class %ActiveClass%
return
; en dash
!SC00c::Send {asc 0150}
; --------------------------------------------------------------
; Application specific
; --------------------------------------------------------------
; Google Chrome
#IfWinActive, ahk_class Chrome_WidgetWin_1
; Show Web Developer Tools with cmd + alt + i
^!SC017::Send {F12} ;i
; Show source code with cmd + alt + u
^!SC016::Send {Alt up}{LCtrl down}{SC016}{LCtrl up} ;u
#IfWinActive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment