Skip to content

Instantly share code, notes, and snippets.

@JustinJohnWilliams
Last active February 22, 2021 22:03
Show Gist options
  • Save JustinJohnWilliams/df1031a03aa991ffa2115ae1272abd43 to your computer and use it in GitHub Desktop.
Save JustinJohnWilliams/df1031a03aa991ffa2115ae1272abd43 to your computer and use it in GitHub Desktop.
Move windows by 1/3
;********************************************************************************
; Move Windows by 1/3
;********************************************************************************
MoveCycle(Add) {
static SizeCycle = 0
SizeCycle := Mod(SizeCycle + Add, 7)
if (SizeCycle < 0) {
SizeCycle := SizeCycle + 7
}
if (SizeCycle = 0) {
MoveWindow(0, 33.3333)
}
else if (SizeCycle = 1) {
MoveWindow(0, 50)
}
else if (SizeCycle = 2) {
MoveWindow(0, 66.6666)
}
else if (SizeCycle = 3) {
MoveWindow(33.3333, 33.3333)
}
else if (SizeCycle = 4) {
MoveWindow(33.3333, 66.6666)
}
else if (SizeCycle = 5) {
MoveWindow(50, 50)
}
else if (SizeCycle = 6) {
MoveWindow(66.6666, 33.3333)
}
}
MoveWindow(XP, WP) {
;Get current Window
WinGetActiveTitle, WinTitle
WinGetPos, X, Y, WinWidth, WinHeight, %WinTitle%
;Get Taskbar height
WinGetPos,,, tbW, tbH, ahk_class Shell_TrayWnd
;Calculate new position and size
XNew := (A_ScreenWidth * XP / 100)
WNew := (A_ScreenWidth * WP / 100)
HNew := (A_ScreenHeight - tbH)
;MsgBox, %XNew% - %WNew%
WinRestore, %WinTitle%
WinMove, %WinTitle%,, %XNew%, 0, %WNew%, %HNew%
}
#!Left::
MoveCycle(-1)
return
#!Right::
MoveCycle(1)
return
#!Up::
MoveWindow(25, 50)
return
#!1::
MoveWindow(0, 56.25)
return
#!2::
MoveWindow(56.25, 18.75)
return
#!3::
MoveWindow(75, 25)
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment