5
5
6
6
; -- Ahk2Exe properties
7
7
; @Ahk2Exe-SetName Polygon
8
- ; @Ahk2Exe-SetVersion 0.4 .0
8
+ ; @Ahk2Exe-SetVersion 0.5 .0
9
9
; @Ahk2Exe-SetCompanyName Soham Dasgupta
10
10
; @Ahk2Exe-SetDescription A window manager for Windows 10/11 powered by AutoHotkey
11
11
12
12
; -- Globals
13
- global APP_VERSION := " 0.4 .0"
13
+ global APP_VERSION := " 0.5 .0"
14
14
global APP_VERSION_NAME := " v" . APP_VERSION
15
15
global APP_NAME := " Polygon"
16
16
global APP_REPO_OWNER := " thesobercoder"
@@ -92,9 +92,9 @@ Toast(Message, r, l, t, b) {
92
92
title := APP_NAME . " 08ab0337-daeb-4b9c-b01d-11fbc97e1dcb"
93
93
hWnd := WinExist (title)
94
94
if (hWnd > 0 )
95
- return
95
+ WinClose (hWnd)
96
96
toastGui := Gui ()
97
- toastGui.Opt(" +ToolWindow -Caption +AlwaysOnTop +Disabled" )
97
+ toastGui.Opt(" +ToolWindow -Caption +AlwaysOnTop +Disabled +E0x20 " )
98
98
toastGui.BackColor := " 000000"
99
99
toastGui.SetFont(" cFFFFFF S18" , " Verdana" )
100
100
toastGui.add(" Text" , " Center X0 Y90 W278 H210" , Message)
@@ -104,10 +104,14 @@ Toast(Message, r, l, t, b) {
104
104
WinSetExStyle(32 , title)
105
105
Loop 60
106
106
{
107
+ hWnd := WinExist (title)
108
+ if (hWnd < 1 )
109
+ break
110
+
107
111
if (A_Index = 1 )
108
112
{
109
- WinSetTransparent(120 , title )
110
- Sleep (1000 )
113
+ WinSetTransparent(120 , hWnd )
114
+ Sleep (100 )
111
115
}
112
116
else if (A_Index = 60 )
113
117
{
@@ -117,7 +121,7 @@ Toast(Message, r, l, t, b) {
117
121
else
118
122
{
119
123
TransFade := 120 - A_Index * 2
120
- WinSetTransparent(TransFade, title )
124
+ WinSetTransparent(TransFade, hWnd )
121
125
Sleep (1 )
122
126
}
123
127
}
@@ -227,7 +231,7 @@ Center(*) {
227
231
centerX := Ceil (((l + r) - (ofl + ofr)) / 2 )
228
232
centerY := Ceil (((t + b) - (ofb + oft)) / 2 )
229
233
; -- Move the active window to the center of the current monitor
230
- WinMove (centerX - w / 2 , centerY - h / 2 , w + ofl + ofr, h + oft + ofb, hWnd)
234
+ WinMoveEx (centerX - w / 2 , centerY - h / 2 , w + ofl + ofr, h + oft + ofb, hWnd)
231
235
; -- Show layout toast
232
236
Toast(" Center" , r, l, t, b)
233
237
}
@@ -242,7 +246,7 @@ CenterHD(*) {
242
246
centerX := Ceil (((l + r) - (ofl + ofr)) / 2 )
243
247
centerY := Ceil (((t + b) - (ofb + oft)) / 2 )
244
248
; -- Move the active window to the center of the current monitor with desired size
245
- WinMove (Ceil (centerX - rw / 2 ), Ceil (centerY - rh / 2 ), rw + ofl + ofr, rh + oft + ofb, hWnd)
249
+ WinMoveEx (Ceil (centerX - rw / 2 ), Ceil (centerY - rh / 2 ), rw + ofl + ofr, rh + oft + ofb, hWnd)
246
250
; -- Show layout toast
247
251
Toast(" Center HD" , r, l, t, b)
248
252
}
@@ -255,7 +259,7 @@ CenterHalf(*) {
255
259
; -- Calculate the horizontal position for centering
256
260
CenterX := (l - ofl) + Ceil (((r - ofr) - (l - ofl)) / 2 ) - Ceil (HalfWidth / 2 )
257
261
; -- Set the window position to the center half of the monitor
258
- WinMove (CenterX, t - oft, HalfWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
262
+ WinMoveEx (CenterX, t - oft, HalfWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
259
263
; -- Show layout toast
260
264
Toast(" Center Half" , r, l, t, b)
261
265
}
@@ -268,7 +272,7 @@ CenterTwoThird(*) {
268
272
; -- Calculate horizontal position for centering
269
273
CenterX := (l - ofl) + Ceil (((r - ofr) - (l - ofl)) / 2 ) - Ceil (TwoThirdWidth / 2 )
270
274
; -- Set window position to center two third width
271
- WinMove (CenterX, t - oft, TwoThirdWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
275
+ WinMoveEx (CenterX, t - oft, TwoThirdWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
272
276
; -- Show layout toast
273
277
Toast(" Center Two Third" , r, l, t, b)
274
278
}
@@ -279,7 +283,7 @@ FirstThird(*) {
279
283
; -- Calculate the width of one third of the monitor
280
284
OneThirdWidth := Ceil ((r - l) / 3 )
281
285
; -- Set the window position to the left one third of the monitor
282
- WinMove (l - ofl, t - oft, OneThirdWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
286
+ WinMoveEx (l - ofl, t - oft, OneThirdWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
283
287
; -- Show layout toast
284
288
Toast(" First Third" , r, l, t, b)
285
289
}
@@ -292,7 +296,7 @@ CenterThird(*) {
292
296
; -- Calculate the horizontal position for centering
293
297
CenterX := (l - ofl) + Ceil (((r - ofr) - (l - ofl)) / 2 ) - Ceil (OneThirdWidth / 2 )
294
298
; -- Set the window position to the center one third of the monitor
295
- WinMove (CenterX, t - oft, OneThirdWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
299
+ WinMoveEx (CenterX, t - oft, OneThirdWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
296
300
; -- Show layout toast
297
301
Toast(" Center Third" , r, l, t, b)
298
302
}
@@ -305,7 +309,7 @@ LastThird(*) {
305
309
; -- Calculate horizontal position for right aligning
306
310
RightX := (r - ofr) - OneThirdWidth
307
311
; -- Set window position to right one third of monitor
308
- WinMove (RightX, t - oft, OneThirdWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
312
+ WinMoveEx (RightX, t - oft, OneThirdWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
309
313
; -- Show layout toast
310
314
Toast(" Last Third" , r, l, t, b)
311
315
}
@@ -316,7 +320,7 @@ TopLeftSixth(*) {
316
320
; -- Calculate the width of one third of the monitor
317
321
OneThirdWidth := Ceil ((r - l) / 3 )
318
322
; -- Set the window position to the left one third of the monitor and top half of it
319
- WinMove (l - ofl, t - oft, OneThirdWidth + ofl + ofb, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
323
+ WinMoveEx (l - ofl, t - oft, OneThirdWidth + ofl + ofb, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
320
324
; -- Show layout toast
321
325
Toast(" Top Left Sixth" , r, l, t, b)
322
326
}
@@ -327,7 +331,7 @@ BottomLeftSixth(*) {
327
331
; -- Calculate the width of one third of the monitor
328
332
OneThirdWidth := Ceil ((r - l) / 3 )
329
333
; -- Set the window position to left one third of monitor and bottom half of it
330
- WinMove (l - ofl, Ceil (b - (b - t) / 2 ), OneThirdWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
334
+ WinMoveEx (l - ofl, Ceil (b - (b - t) / 2 ), OneThirdWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
331
335
; -- Show layout toast
332
336
Toast(" Bottom Left Sixth" , r, l, t, b)
333
337
}
@@ -340,7 +344,7 @@ TopRightSixth(*) {
340
344
; -- Calculate horizontal position for right aligning
341
345
RightX := (r - ofr) - OneThirdWidth
342
346
; -- Set window position to right one third of monitor and top half of it.
343
- WinMove (RightX, t - oft, OneThirdWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
347
+ WinMoveEx (RightX, t - oft, OneThirdWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
344
348
; -- Show layout toast
345
349
Toast(" Top Right Sixth" , r, l, t, b)
346
350
}
@@ -353,7 +357,7 @@ BottomRightSixth(*) {
353
357
; -- Calculate horizontal position for right aligning
354
358
RightX := (r - ofr) - OneThirdWidth
355
359
; -- Set window position to right one third of monitor and bottom half of it
356
- WinMove (RightX, Ceil (b - (b - t) / 2 ), OneThirdWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
360
+ WinMoveEx (RightX, Ceil (b - (b - t) / 2 ), OneThirdWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
357
361
; -- Show layout toast
358
362
Toast(" Bottom Right Sixth" , r, l, t, b)
359
363
}
@@ -366,7 +370,7 @@ TopCenterSixth(*) {
366
370
; -- Calculate the horizontal position for centering
367
371
CenterX := (l - ofl) + Ceil (((r - ofr) - (l - ofl)) / 2 ) - Ceil (OneThirdWidth / 2 )
368
372
; -- Set the window position to top center one sixth of the monitor
369
- WinMove (CenterX, t - oft, OneThirdWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
373
+ WinMoveEx (CenterX, t - oft, OneThirdWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
370
374
; -- Show layout toast
371
375
Toast(" Top Center Sixth" , r, l, t, b)
372
376
}
@@ -379,7 +383,7 @@ BottomCenterSixth(*) {
379
383
; -- Calculate the horizontal position for centering
380
384
CenterX := (l - ofl) + Ceil (((r - ofr) - (l - ofl)) / 2 ) - Ceil (OneThirdWidth / 2 )
381
385
; -- Set the window position to bottom center one sixth of the monitor
382
- WinMove (CenterX, Ceil (b - (b - t) / 2 ), OneThirdWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
386
+ WinMoveEx (CenterX, Ceil (b - (b - t) / 2 ), OneThirdWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
383
387
; -- Show layout toast
384
388
Toast(" Bottom Center Sixth" , r, l, t, b)
385
389
}
@@ -390,7 +394,7 @@ LeftHalf(*) {
390
394
; -- Calculate the width of half of the monitor
391
395
HalfWidth := Ceil ((r - l) / 2 )
392
396
; -- Set the window position to the left half of the monitor
393
- WinMove (l - ofl, t - oft, HalfWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
397
+ WinMoveEx (l - ofl, t - oft, HalfWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
394
398
; -- Show layout toast
395
399
Toast(" Left Half" , r, l, t, b)
396
400
}
@@ -403,7 +407,7 @@ RightHalf(*) {
403
407
; -- Calculate horizontal position for right aligning
404
408
RightX := (r - ofr) - HalfWidth
405
409
; -- Set the window position to the right half of the monitor
406
- WinMove (RightX, t - oft, HalfWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
410
+ WinMoveEx (RightX, t - oft, HalfWidth + ofl + ofr, (b - t) + oft + ofb, hWnd)
407
411
; -- Show layout toast
408
412
Toast(" Right Half" , r, l, t, b)
409
413
}
@@ -414,7 +418,7 @@ TopLeft(*) {
414
418
; -- Calculate the width as half of the monitor
415
419
HalfWidth := Ceil ((r - l) / 2 )
416
420
; -- Set the window position to the left half of the monitor and top half of it
417
- WinMove (l - ofl, t - oft, HalfWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
421
+ WinMoveEx (l - ofl, t - oft, HalfWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
418
422
; -- Show layout toast
419
423
Toast(" Top Left" , r, l, t, b)
420
424
}
@@ -427,7 +431,7 @@ TopRight(*) {
427
431
; -- Calculate horizontal position for right aligning
428
432
RightX := (r - ofr) - HalfWidth
429
433
; -- Set the window position to start from the middle of the monitor and extend to the very right edge
430
- WinMove (RightX, t - oft, r - l - HalfWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
434
+ WinMoveEx (RightX, t - oft, r - l - HalfWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
431
435
; -- Show layout toast
432
436
Toast(" Top Right" , r, l, t, b)
433
437
}
@@ -440,7 +444,7 @@ BottomLeft(*) {
440
444
; -- Calculate the height of half of the monitor
441
445
HalfHeight := Ceil ((b - t) / 2 )
442
446
; -- Set the window position to left one third of monitor and bottom half of it
443
- WinMove (l - ofl, Ceil (b - (b - t) / 2 ), HalfWidth + ofl + ofr, HalfHeight + oft + ofb, hWnd)
447
+ WinMoveEx (l - ofl, Ceil (b - (b - t) / 2 ), HalfWidth + ofl + ofr, HalfHeight + oft + ofb, hWnd)
444
448
; -- Show layout toast
445
449
Toast(" Bottom Left" , r, l, t, b)
446
450
}
@@ -453,7 +457,7 @@ BottomRight(*) {
453
457
; -- Calculate horizontal position for right aligning
454
458
RightX := (r - ofr) - HalfWidth
455
459
; -- Set the window position to the right half of the monitor and bottom half of it
456
- WinMove (RightX, Ceil (b - (b - t) / 2 ), HalfWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
460
+ WinMoveEx (RightX, Ceil (b - (b - t) / 2 ), HalfWidth + ofl + ofr, Ceil ((b - t) / 2 ) + oft + ofb, hWnd)
457
461
; -- Show layout toast
458
462
Toast(" Bottom Right" , r, l, t, b)
459
463
}
@@ -464,7 +468,7 @@ TopHalf(*) {
464
468
; -- Calculate the height of half of the monitor
465
469
HalfHeight := Ceil ((b - t) / 2 )
466
470
; -- Set the window position to the left half of the monitor and top half of it
467
- WinMove (l - ofl, t - oft, Ceil ((r - l)) + ofl + ofr, HalfHeight + oft + ofb, hWnd)
471
+ WinMoveEx (l - ofl, t - oft, Ceil ((r - l)) + ofl + ofr, HalfHeight + oft + ofb, hWnd)
468
472
; -- Show layout toast
469
473
Toast(" Top Half" , r, l, t, b)
470
474
}
@@ -475,7 +479,7 @@ BottomHalf(*) {
475
479
; -- Calculate the height of half of the monitor
476
480
HalfHeight := Ceil ((b - t) / 2 )
477
481
; -- Set the window position to the left half of the monitor and top half of it
478
- WinMove (l - ofl, Ceil (b - (b - t) / 2 ), Ceil ((r - l)) + ofl + ofr, HalfHeight + oft + ofb, hWnd)
482
+ WinMoveEx (l - ofl, Ceil (b - (b - t) / 2 ), Ceil ((r - l)) + ofl + ofr, HalfHeight + oft + ofb, hWnd)
479
483
; -- Show layout toast
480
484
Toast(" Bottom Half" , r, l, t, b)
481
485
}
@@ -486,7 +490,7 @@ FirstFourth(*) {
486
490
; -- Calculate the width of one fourth of the monitor
487
491
OneFourthWidth := Ceil ((r - l) / 4 )
488
492
; -- Set the window position to the left one fourth of the monitor
489
- WinMove (l - ofl, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
493
+ WinMoveEx (l - ofl, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
490
494
; -- Show layout toast
491
495
Toast(" First Fourth" , r, l, t, b)
492
496
}
@@ -497,7 +501,7 @@ SecondFourth(*) {
497
501
; Calculate the width of one-fourth of the monitor
498
502
OneFourthWidth := Ceil ((r - l) / 4 )
499
503
; Set the window position to the left one-fourth of the monitor
500
- WinMove (l - ofl + OneFourthWidth, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
504
+ WinMoveEx (l - ofl + OneFourthWidth, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
501
505
; Show layout toast
502
506
Toast(" Second Fourth" , r, l, t, b)
503
507
}
@@ -508,7 +512,7 @@ ThirdFourth(*) {
508
512
; Calculate the width of one-fourth of the monitor
509
513
OneFourthWidth := Ceil ((r - l) / 4 )
510
514
; Set the window position to the right one-fourth of the monitor
511
- WinMove (l - ofl + 2 * OneFourthWidth, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
515
+ WinMoveEx (l - ofl + 2 * OneFourthWidth, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
512
516
; Show layout toast
513
517
Toast(" Third Fourth" , r, l, t, b)
514
518
}
@@ -519,11 +523,17 @@ LastFourth(*) {
519
523
; -- Calculate the width of one fourth of the monitor
520
524
OneFourthWidth := Ceil ((r - l) / 4 )
521
525
; -- Set the window position to the right one fourth of the monitor
522
- WinMove (r - OneFourthWidth - ofr, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
526
+ WinMoveEx (r - OneFourthWidth - ofr, t - oft, OneFourthWidth + ofr + ofl, (b - t) + oft + ofb, hWnd)
523
527
; -- Show layout toast
524
528
Toast(" Last Fourth" , r, l, t, b)
525
529
}
526
530
}
531
+ WinMoveEx (X := 0, Y := 0, Width := 0, Height := 0, hWnd := 0 ) {
532
+ ; -- Restore the window before moving
533
+ WinRestore (hWnd)
534
+ ; -- Move the window to the desired position and dimension
535
+ WinMove (X, Y, Width, Height, hWnd)
536
+ }
527
537
GetWindowRectEx (&hWindow := 0, &winX := 0, &winY := 0, &winW := 0, &winH := 0, &winOffsetLeft := 0, &winOffsetRight := 0, &winOffsetTop := 0, &winOffsetBottom := 0, &monRight := 0, &monLeft := 0, &monTop := 0, &monBottom := 0 ) {
528
538
; -- Get the handle of the active window
529
539
hWindow := WinExist (" A" )
0 commit comments