Based on paftdunk's script, I added the possibility to fine-tune the window size in steps of 1/6 of screen size.
The script is useful for big screens like 1920x1200 and allows to arrange windows in a lot of useful combinations, e.g. three windows full height side-by-side, or 1 window 2/3 wide of the screen and two windows sharing the remaining 1/3.
I added functions to expand and contract the window to the left, right, up and down.
Windows key + Numpad Division expands to the left,
Windows key + Numpad Multiplication expands to the right,
Windows key + Numpad Subtraction expands to the top,
Windows key + Numpad Addition expands to the bottom,
Windows key + Alt + (same key as above) contracts the respective window from that margin.
Another small change is a bigger value for the bottom offset (changed 30 to 60) - in my layout, the system tray is thicker and 30 did not work well, a small part of the window remained hidden behind it.
Code:
; Easy window location and size utility "One sixth", version 1.0
; Based on script by paftdunk
; Modifications by Mak Sym
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance force
SetBatchLines -1
; -------------------
; START CONFIGURATION
; -------------------
HotKey, #Left, StickLeft
HotKey, #Numpad4, StickLeft
HotKey, #NumpadLeft, StickLeft
HotKey, #Right, StickRight
HotKey, #Numpad6, StickRight
HotKey, #NumpadRight, StickRight
HotKey, #Up, StickUp
HotKey, #Numpad8, StickUp
HotKey, #NumpadUp, StickUp
HotKey, #Down, StickDown
HotKey, #Numpad2, StickDown
HotKey, #NumpadDown, StickDown
HotKey, #Numpad5, CenterWindow
HotKey, #NumpadClear, CenterWindow
HotKey, #Numpad7, StickNW
HotKey, #NumpadHome, StickNW
HotKey, #Numpad1, StickSW
HotKey, #NumpadEnd, StickSW
HotKey, #Numpad9, StickNE
HotKey, #NumpadPgUp, StickNE
HotKey, #Numpad3, StickSE
HotKey, #NumpadPgDn, StickSE
HotKey, #Numpad0, MinWin
HotKey, #NumpadIns, MinWin
HotKey, #NumpadDot, TrayWin
HotKey, #NumpadDel, TrayWin
HotKey, #NumpadDiv, ExpandLeft
HotKey, #NumpadMult, ExpandRight
HotKey, #!NumpadDiv, ContractLeft
HotKey, #!NumpadMult, ContractRight
HotKey, #NumpadSub, ExpandUp
HotKey, #NumpadAdd, ExpandDown
HotKey, #!NumpadSub, ContractUp
HotKey, #!NumpadAdd, ContractDown
; --------------------
; END OF CONFIGURATION
; --------------------
OnExit, ExitSub
IsHidden = 0
return
ExpandLeft:
WinGetPos, WX, WY, WW, WH, A
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , WX - (A_ScreenWidth / 6), , WW + (A_ScreenWidth / 6)
return
ContractLeft:
WinGetPos, WX, WY, WW, WH, A
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , WX + (A_ScreenWidth / 6), , WW - (A_ScreenWidth / 6)
return
ExpandRight:
WinGetPos, WX, WY, WW, WH, A
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , WX, , WW + (A_ScreenWidth / 6)
return
ContractRight:
WinGetPos, WX, WY, WW, WH, A
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , WX, , WW - (A_ScreenWidth / 6)
return
ExpandUp:
WinGetPos, WX, WY, WW, WH, A
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , , WY - ((A_ScreenHeight - 60) / 6), , WH + ((A_ScreenHeight - 60) / 6)
return
ContractUp:
WinGetPos, WX, WY, WW, WH, A
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , , WY + ((A_ScreenHeight - 60) / 6), , WH - ((A_ScreenHeight - 60) / 6)
return
ExpandDown:
WinGetPos, WX, WY, WW, WH, A
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , , WY, , WH + ((A_ScreenHeight - 60) / 6)
return
ContractDown:
WinGetPos, WX, WY, WW, WH, A
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , , WY, , WH - ((A_ScreenHeight - 60) / 6)
return
StickLeft:
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , 0, 0, A_ScreenWidth / 2, A_ScreenHeight - 60
return
StickRight:
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , A_ScreenWidth / 2, 0, A_ScreenWidth / 2, A_ScreenHeight - 60
return
StickUp:
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , 0, 0, A_ScreenWidth, (A_ScreenHeight - 60 ) / 2
return
StickDown:
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , 0, (A_ScreenHeight - 60 ) / 2, A_ScreenWidth, (A_ScreenHeight - 60 ) / 2
return
CenterWindow:
WinGetPos, , , WW, WH, A
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , ( A_ScreenWidth - WW ) / 2, (A_ScreenHeight - 60 - WH ) / 2
return
StickNW:
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , 0, 0, A_ScreenWidth / 2, (A_ScreenHeight - 60 ) / 2
return
StickSW:
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , 0, (A_ScreenHeight - 60 ) / 2, A_ScreenWidth / 2, (A_ScreenHeight - 60 ) / 2
return
StickNE:
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , A_ScreenWidth / 2, 0, A_ScreenWidth / 2, (A_ScreenHeight - 60 ) / 2
return
StickSE:
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMove, A, , A_ScreenWidth / 2, (A_ScreenHeight - 60 ) / 2, A_ScreenWidth / 2, (A_ScreenHeight - 60 ) / 2
return
MinWin:
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
WinMinimize, A
return
TrayWin:
WinGet, UID, ID, A
WinGetClass, class, A
if class != Shell_TrayWnd
if class != Progman
if class != DV2ControlHost
GroupAdd, TrayWindow, ahk_id %UID%
if IsHidden = 0
{
WinHide, ahk_group TrayWindow
IsHidden = 1
;TrayTip,, hidden 1
}
else
{
WinShow, ahk_group TrayWindow
IsHidden = 0
;TrayTip,, hidden 0
}
return
ExitSub:
WinShow, ahk_group TrayWindow
ExitApp
[Moderator's note: Corrected code tags.]