Skip to content

Instantly share code, notes, and snippets.

@mikew
Last active June 13, 2016 00:04
Show Gist options
  • Save mikew/18a0e5c6f6bdbf1bb3be0a9cfa3b5df8 to your computer and use it in GitHub Desktop.
Save mikew/18a0e5c6f6bdbf1bb3be0a9cfa3b5df8 to your computer and use it in GitHub Desktop.
#NoEnv
; Recommended for performance and compatibility with future AutoHotkey releases.
; Needs to be the absolute first thing.
; Enable warnings to assist with detecting common errors.
; #Warn
; Recommended for new scripts due to its superior speed and reliability.
SendMode Input
; Ensures a consistent starting directory.
SetWorkingDir %A_ScriptDir%
; Select All ⌘A Ctrl+A
#a::Send, ^a
; Undo ⌘Z Ctrl+Z
#z::Send, ^z
; Redo ⌘⇧Z Ctrl+Y
; Atom, at least with vim-mode, will only redo with Ctrl+Shift+Z.
#+z::
IfWinActive, ahk_exe atom.exe
Send, ^+z
Else
Send, ^y
return
;#+z::Send, ^y
; Cut ⌘X Ctrl+X
#x::Send, ^x
; Copy ⌘C Ctrl+C
#c::Send, ^c
; Paste ⌘V Ctrl+V
#v::Send, ^v
; Open ⌘O Ctrl+O
#o::Send, ^o
; Save ⌘S Ctrl+S
#s::Send, ^s
; Find ⌘F Ctrl+F
#f::Send, ^f
; Find Next ⌘G F3
#g::Send, {F3}
; Find Previous ⌘⇧G Shift+F3
#+g::Send, +{F3}
; Refresh ⌘R F5
#r::Send, {F5}
; Hard Refresh ⌘⇧R Shift+F5
#+r::Send, +{F5}
; New Tab ⌘T Ctrl+T
; Send ^P to Atom to open file chooser.
; Send ^, to VS to open file chooser.
#t::
IfWinActive, ahk_exe atom.exe
Send, ^p
Else IfWinActive, ahk_exe devenv.exe
Send, ^,
Else
Send, ^t
return
; Close Tab ⌘W Ctrl+W
#w::Send, ^w
; Hide ⌘H Minimize
#h::WinMinimize, A
; Quit ⌘Q Close Window
; WinClose works, but will close the desktop.
; Prefer Alt+F4 since it presents a nice restart menu.
;#q::WinClose, A
#q::Send, !{F4}
; Home ⌘Left Home
#Left::Send, {Home}
; Select to home ⌘⇧Left Shift+Home
#+Left::Send, +{Home}
; Delete to home ⌘⌫ Shift+Home, Delete
#BS::Send, +{Home}{BS}
; End ⌘Right End
#Right::Send, {End}
; Select to end ⌘⇧Right Shift+End
#+Right::Send, +{End}
; Top ⌘Up Ctrl+Home
#Up::Send, ^{Home}
; Select to top ⌘⇧Up Ctrl+Shift+Home
#+Up::Send, ^+{Home}
; Bottom ⌘Down Ctrl+End
#Down::Send, ^{End}
; Select to bottom ⌘⇧Down Ctrl+Shift+End
#+Down::Send, ^+{End}
; Next Tab ^⇥ Ctrl+Tab
; Atom treats Ctrl+Tab as "cycle by recent order", and Ctrl+PgDown as "next tab"
#}::
IfWinActive, ahk_exe atom.exe
Send, ^{PgDn}
Else
Send, ^{Tab}
return
; Previous Tab ^⇧⇥ Ctrl+Shift+Tab
#{::
IfWinActive, ahk_exe atom.exe
Send, ^{PgUp}
Else
Send, ^+{Tab}
return
; App Switcher ⌘⇥ Alt+Tab
#Tab::AltTabAndMenu
#+Tab::AltTabAndMenu
; Release alt when windows key released.
!LWin up::Send, {Alt up}
!RWin up::Send, {Alt up}
; Run Command ⌘Space Win+R
#Space::FileDlg := ComObjCreate("Shell.Application").FileRun, FileDlg := ""
; Focus Taskbar ⌘⌥D Win+T
#!d::Send, #t
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment