Skip to content

Instantly share code, notes, and snippets.

@amirrajan
Forked from JustinJohnWilliams/win.ahk
Created October 30, 2020 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amirrajan/971781e7c3a0e46d264a3cb635209b97 to your computer and use it in GitHub Desktop.
Save amirrajan/971781e7c3a0e46d264a3cb635209b97 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