Skip to content

Instantly share code, notes, and snippets.

@mikeplate
Created November 1, 2011 20:29
Show Gist options
  • Save mikeplate/1331810 to your computer and use it in GitHub Desktop.
Save mikeplate/1331810 to your computer and use it in GitHub Desktop.
My main AutoHotkey file with favorite shortcuts
; Set some variables we'll need later
SysGet, DeskW, 16
SysGet, DeskH, 62
SysGet, WinBorderH, 46
DeskH := DeskH - WinBorderH*8
; Create the window group EXPLORER so we can treat all such windows as a group further down
GroupAdd,EXPLORER, ahk_class CabinetWClass
#WinActivateForce
return
; Window movement and sizing into the four quadrants of the desktop
*#^Up::
WinMove,A,,0,0,DeskW/2,DeskH/2
return
*#^Left::
WinMove,A,,0,DeskH/2,DeskW/2,DeskH/2
return
*#^Right::
WinMove,A,,DeskW/2,0,DeskW/2,DeskH/2
return
*#^Down::
WinMove,A,,DeskW/2,DeskH/2,DeskW/2,DeskH/2
return
; Toggle the AlwaysOnTop property for the active window
^!t::
WinSet, AlwaysOnTop, toggle, A
return
; Quit active application with Ctrl-Q instead of Alt+F4
^Q::Send !{F4}
; When pressing Capslock key, activate all explorer windows so that they come to the front
Capslock::
WinGet, wndlist, list, ahk_group EXPLORER
Loop % wndlist
{
id := wndlist%A_Index%
WinActivate, ahk_id %id%
}
return
$Media_Play_Pause::
{
IfWinNotExist, Spotify
{
Run, "C:\Program Files (x86)\Spotify\Spotify.exe"
Return
}
Send {Media_Play_Pause}
Return
}
^8::
WinGetPos,winx,winy,winwidth,winheight,A
winwidth := winwidth - 10
WinMove,A,,winx,winy,winwidth,winheight
Return
^9::
WinGetPos,winx,winy,winwidth,winheight,A
winwidth := winwidth + 10
WinMove,A,,winx,winy,winwidth,winheight
Return
;==========================================
; Console window
#IfWinActive ahk_class ConsoleWindowClass
; Quit console application with Ctrl-Q
^Q::
Send !{Space}c
return
; Paste clipboard contents with Ctrl-V
^V::
Send !{Space}ep
return
; Start selection process (Mark) with Ctrl-M
^M::
Send !{Space}ek
return
; Change directory to the user's home directory when typing cd0 and space/return
:O:cd0::cd %USERPROFILE%{Return}
;==========================================
; Explorer window
#IfWinActive ahk_class CabinetWClass
; Start console with current directory in Explorer
^!C::
Send {!d}
ControlGetText Path , Edit1
Send {Esc}
If (InStr(Path, ":"))
Run %ComSpec% /K cd /D "%Path%"
Else
Run %ComSpec% /K cd /D "C:\"
Return
#IfWinActive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment