Skip to content

Instantly share code, notes, and snippets.

@Macrofig
Last active February 2, 2020 14:23
Show Gist options
  • Save Macrofig/7f584b755d47f449b0479f72a2e2f7ee to your computer and use it in GitHub Desktop.
Save Macrofig/7f584b755d47f449b0479f72a2e2f7ee to your computer and use it in GitHub Desktop.
Autohotkey script to emulate some MacOS keyboard shortcuts on Windows
/*
Attempts to add MacOS keyboard shortcuts/commands to Windows
NOTE:
In many cases, I use the CTRL key because I am using a Mac keyboard and
therefore swapped the COMMAND (Windows) key with the CONTROL key.
See this blog post, specifcally the "On Windows" section:
https://www.howtogeek.com/219156/how-to-remap-your-windows-cutcopypaste-to-os-x-like-controls-and-vice-versa/
Might need to download Sharpkeys from here: https://github.com/randyrants/sharpkeys/releases
Download AutoHotKey here: https://autohotkey.com/
## Usage
Follow the tutorial here: https://autohotkey.com/docs/Tutorial.htm#s12
1. Install AutoHotkey
2. Download this script
3. Double click this script (AHK should automatically be associated with the `.ahk` file type.)
4. PROFIT
*/
; Remaps the alt+tab to ctrl+tab
; CREDIT: https://superuser.com/a/1248610/852737
LControl & Tab::
AltTabMenu := true
If GetKeyState("Shift","P")
Send {Alt Down}{Shift Down}{Tab}
else
Send {Alt Down}{Tab}
return
#If (AltTabMenu)
~*LControl Up::
Send {Shift Up}{Alt Up}
AltTabMenu := false
return
#If
; CTRL+(UP|DOWN)
; Emulates CMD+(up|down)
; Moves cursor to top or bottom of document
^Up::Send {Ctrl Down}{Home}{Ctrl Up}
^Down::Send {Ctrl Down}{End}{Ctrl Up}
; CTRL+(LEFT|RIGHT)
; Emulates CMD+(left|right)
; Moves cursor to start or end of current line.
^Left::Send {Home}
^Right::Send {End}
; TODO!
; Emulates OPT+SHIFT+(up|down)
; Moves selection up or down one paragraph
; CTRL+Backspace
; Emulates CMD+delete
; Deletes line from the cursor to the start of the line
; Note: You will see a flash as the script does actually have to select the line
^Backspace::Send {Shift Down}{Home}{Shift Up}{Backspace}
; ALT+Backspace
; Emulates OPT+delete
; Deletes the current word
!Backspace::Send {Shift Down}{Ctrl Down}{Left}{Ctrl Up}{Shift Up}{Backspace}
; CTRL+SHIFT+(LEFT|RIGHT)
; Emulates CMD+SHIFT+(left|right)
; Creates/modifies selection from cursor to home or end of current line
^+Left::Send {Shift Down}{Home}{Shift Up}
^+Right::Send {Shift Down}{End}{Shift Up}
; CTRL+SHIFT+(UP|DOWN)
; Emulates CMD+SHIFT+(up|down)
; Creates/modifies selection to top or bottom of document.
^+Up::Send {Shift Down}{Ctrl Down}{Home}{Ctrl Up}{Shift Up}
^+Down::Send {Shift Down}{Ctrl Down}{End}{Ctrl Up}{Shift Up}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment