Skip to content

Commit 68133f1

Browse files
committed
feat: add FirstFourth and LastFourth functions
1 parent 196674e commit 68133f1

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

polygon.ahk

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,28 @@ CenterHD(*) {
238238
Toast("Center HD", r, l, t, b)
239239
}
240240
}
241+
FirstFourth(*) {
242+
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
243+
{
244+
;-- Calculate the width of one fourth of the monitor
245+
OneFourthWidth := Ceil((r - l) / 4)
246+
;-- Set the window position to the left one fourth of the monitor
247+
WinMove(l - ofl, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
248+
;-- Show layout toast
249+
Toast("First Fourth", r, l, t, b)
250+
}
251+
}
252+
LastFourth(*) {
253+
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
254+
{
255+
;-- Calculate the width of one fourth of the monitor
256+
OneFourthWidth := Ceil((r - l) / 4)
257+
;-- Set the window position to the right one fourth of the monitor
258+
WinMove(r - OneFourthWidth - ofr, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
259+
;-- Show layout toast
260+
Toast("Last Fourth", r, l, t, b)
261+
}
262+
}
241263
CenterHalf(*) {
242264
if (GetWindowRectEx(&hWnd, &x, &y, &w, &h, &ofl, &ofr, &oft, &ofb, &r, &l, &t, &b))
243265
{
@@ -544,4 +566,4 @@ WinGetPosEx(hWindow, &winX := 0, &winY := 0, &winW := 0, &winH := 0, &winOffsetL
544566
NumPut("Int", winOffsetRight := GWR_Right - Right, RECTPlus, 24)
545567
NumPut("Int", winOffsetBottom := GWR_Bottom - Bottom, RECTPlus, 28)
546568
Return &RECTPlus
547-
}
569+
}

0 commit comments

Comments
 (0)