Skip to content

Instantly share code, notes, and snippets.

@larsch
Created September 11, 2009 11:38
Show Gist options
  • Select an option

  • Save larsch/185242 to your computer and use it in GitHub Desktop.

Select an option

Save larsch/185242 to your computer and use it in GitHub Desktop.
AutoHotkey script for window positioning like on Windows 7
;;
;; Mimic Windows7 window positions using Win+Up/Left/Right
;; Not tested with multiple monitors
;;
#up::
WinRestore A
WinMaximize A
return
#left::
cxsizeframe := DllCall("GetSystemMetrics", "UInt", 32)
cysizeframe := DllCall("GetSystemMetrics", "UInt", 33)
WinGetPos x, y, width, height, ahk_class Shell_TrayWnd
WinGetPos desk_x, desk_y, desk_width, desk_height, ahk_class Progman
new_width := desk_width / 2 + cxsizeframe
new_height := desk_height - height + 2 * cxsizeframe
new_x := 0 - cxsizeframe
new_y := 0 - cysizeframe
WinMaximize A
WinMove A,, %new_x%, %new_y%, %new_width%, %new_height%
return
#right::
cxsizeframe := DllCall("GetSystemMetrics", "UInt", 32)
cysizeframe := DllCall("GetSystemMetrics", "UInt", 33)
WinGetPos x, y, width, height, ahk_class Shell_TrayWnd
WinGetPos desk_x, desk_y, desk_width, desk_height, ahk_class Progman
new_x := desk_width / 2
new_y := 0 - cysizeframe
new_width := desk_width / 2 + cxsizeframe
new_height := desk_height - height + 2 * cysizeframe
WinMaximize A
WinMove A,, %new_x%, %new_y%, %new_width%, %new_height%
return
#down::
WinGet, MinMax, MinMax, A
if (MinMax = 1 or MinMax = -1)
WinRestore A
else
WinMinimize A
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment