Numeric keypad (NumLock off) does the following to the active window:
0 tiny (cycle through three positions)
1 full-screen
2 half-screen (cycle through two positions)
3 third-screen (cycle through three positions)
4 quarter-screen (cycle through four portrait + four landscape positions)
6 sixth-screen (cycle through six positions)
8 eighth-screen (cycle through eight positions)
Before using, set values for marginLeft, marginTop, etc. to reflect your own Windows Taskbar location & size.
Code: Select all
/*
wm4k -- simple window management for 4k monitors
by Roel Hammerschlag, September 2014
Before using, set values for marginLeft etc. below to reflect
your own location & size of Windows Taskbar.
Hotkeys are designed for NumLock OFF.
*/
SetBatchLines, -1
SetTitleMatchMode, 2
SetTitleMatchMode, fast
SetWinDelay, 10
#NoEnv
#SingleInstance force
#WinActivateForce
xGross := 3840
yGross := 2160
marginLeft := 0
marginRight := 0
marginTop := 30
marginBottom := 0
xAvailable := xGross - marginLeft - marginRight
yAvailable := yGross - marginTop - marginBottom
xStep := xAvailable // 12
yStep := yAvailable // 2
xPos00 := marginLeft
xPos01 := marginLeft + xStep
xPos02 := marginLeft + xStep*2
xPos03 := marginLeft + xStep*3
xPos04 := marginLeft + xStep*4
xPos05 := marginLeft + xStep*5
xPos06 := marginLeft + xStep*6
xPos07 := marginLeft + xStep*7
xPos08 := marginLeft + xStep*8
xPos09 := marginLeft + xStep*9
xPos10 := marginLeft + xStep*10
xPos11 := marginLeft + xStep*11
yPos00 := marginTop
yPos01 := marginTop + yStep
tinyWidth := xAvailable // 8
tinyHeight := yAvailable // 4
xPosTiny0 := xPos03 - tinyWidth // 2
xPosTiny1 := xPos06 - tinyWidth // 2
xPosTiny2 := xPos09 - tinyWidth // 2
yPosTiny := yPos01 - tinyHeight // 2
NumpadEnd:: ;"1" on num pad invokes full-screen window
WinMove, A, , xPos00, yPos00, xStep*12, yStep*2
return
NumpadDown:: ;"2" on num pad handles 1/2-screen windows
WinGetPos, x, y, width, height, A
if (width = xStep*6 and height = yStep*2)
{
if (y = yPos00)
{
if (x = xPos00)
WinMove, A, , xPos06, yPos00
else
WinMove, A, , xPos00, yPos00
}
else ;1/2-screen window is off grid
WinMove, A, , xPos00, yPos00
}
else ;any other size window
WinMove, A, , xPos00, yPos00, xStep*6, yStep*2
return
NumpadPgDn:: ;"3" on num pad handles 1/3-screen windows
WinGetPos, x, y, width, height, A
if (width = xStep*4 and height = yStep*2)
{
if (y = yPos00)
{
if (x = xPos00)
WinMove, A, , xPos04, yPos00
else if (x = xPos04)
WinMove, A, , xPos08, yPos00
else
WinMove, A, , xPos00, yPos00
}
else ;1/3-screen window is off grid
WinMove, A, , xPos00, yPos00
}
else ;any other size window
WinMove, A, , xPos00, yPos00, xStep*4, yStep*2
return
NumpadLeft:: ;"4" on num pad handles 1/4-screen windows
WinGetPos, x, y, width, height, A
if (width = xStep*3 and height = yStep*2) ;portrait format 1/4-screen window
{
if (y = yPos00)
{
if (x = xPos00)
WinMove, A, , xPos03, yPos00
else if (x = xPos03)
WinMove, A, , xPos06, yPos00
else if (x = xPos06)
WinMove, A, , xPos09, yPos00
else if (x = xPos09) ;if in last position convert to landscape
WinMove, A, , xPos00, yPos00, xStep*6, yStep
else ;off x grid only
WinMove, A, , xPos00, yPos00 ;go home
}
else ;completely off grid
WinMove, A, , xPos00, yPos00
}
else if (width = xStep*6 and height = yStep) ;landscape format 1/4-screen window
{
if (y = yPos00)
{
if (x = xPos00)
WinMove, A, , xPos06, yPos00
else if (x = xPos06)
WinMove, A, , xPos00, yPos01
else ;off x grid only
WinMove, A, , xPos00, yPos00 ;return to beginning of row
}
else if (y = yPos01)
{
if (x = xPos00)
WinMove, A, , xPos06, yPos01
else if (x = xPos06) ;if in last posisiton convert to portrait
WinMove, A, , xPos00, yPos00, xStep*3, yStep*2
else ;off x grid only
WinMove, A, , xPos00, yPos01 ;return to beginning of row
}
else ;completely off grid
WinMove, A, , xPos00, yPos00
}
else ;any other size window
WinMove, A, , xPos00, yPos00, xStep*3, yStep*2
return
NumpadRight:: ;"6" on num pad handles 1/6-screen windows
WinGetPos, x, y, width, height, A
if (width = xStep*4 and height = yStep)
{
if (y = yPos00)
{
if (x = xPos00)
WinMove, A, , xPos04, yPos00
else if (x = xPos04)
WinMove, A, , xPos08, yPos00
else if (x = xPos08)
WinMove, A, , xPos00, yPos01
else ;off x grid only
WinMove, A, , xPos00, yPos00 ;go home
}
else if (y = yPos01)
{
if (x = xPos00)
WinMove, A, , xPos04, yPos01
else if (x = xPos04)
WinMove, A, , xPos08, yPos01
else ;off x grid only, or in last position
WinMove, A, , xPos00, yPos00 ;go home
}
else ;completely off grid
WinMove, A, , xPos00, yPos00 ;go home
}
else ;any non-1/8 window
WinMove, A, , xPos00, yPos00, xStep*4, yStep
return
NumpadUp:: ;"8" on num pad handles 1/8-screen windows
WinGetPos, x, y, width, height, A
if (width = xStep*3 and height = yStep)
{
if (y = yPos00)
{
if (x = xPos00)
WinMove, A, , xPos03, yPos00
else if (x = xPos03)
WinMove, A, , xPos06, yPos00
else if (x = xPos06)
WinMove, A, , xPos09, yPos00
else if (x = xPos09)
WinMove, A, , xPos00, yPos01
else ;off x grid only
WinMove, A, , xPos00, yPos00 ;go home
}
else if (y = yPos01)
{
if (x = xPos00)
WinMove, A, , xPos03, yPos01
else if (x = xPos03)
WinMove, A, , xPos06, yPos01
else if (x = xPos06)
WinMove, A, , xPos09, yPos01
else ;off x grid only, or in last position
WinMove, A, , xPos00, yPos00 ;go home
}
else ;completely off grid
WinMove, A, , xPos00, yPos00 ;go home
}
else ;any non-1/8 window
WinMove, A, , xPos00, yPos00, xStep*3, yStep
return
NumpadIns:: ;"0" on num pad makes a Tiny window
WinGetPos, x, y, width, height, A
if (width = tinyWidth and height = tinyHeight)
{
if (y = yPosTiny)
{
if (x = xPosTiny0)
WinMove, A, , xPosTiny1, yPosTiny
else if (x = xPosTiny1)
WinMove, A, , xPosTiny2, yPosTiny
else ;Tiny window is in row but not snapped to grid
WinMove, A, , xPosTiny0, yPosTiny ; or it's in last available grid position
}
else ;Tiny window is off the grid
WinMove, A, , xPosTiny0, yPosTiny
}
else ;any non-Tiny window
WinMove, A, , xPosTiny0, yPosTiny, tinyWidth, tinyHeight
return