-
Notifications
You must be signed in to change notification settings - Fork 0
/
windows-manager1.2.ahk
690 lines (600 loc) · 18.4 KB
/
windows-manager1.2.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
SettingsFile = HotkeySettings.ini
class ShortcutsProfile {
__New(profileName, profileFile) {
this.Name := profileName
this.File := profileFile
}
}
class Profiles {
static AltWin := new ShortcutsProfile("Alt+Win shortcuts", "ShortcutDefs-AltWin.ini")
static CtrlWin := new ShortcutsProfile("Ctrl+Win shortcuts", "ShortcutDefs-CtrlWin.ini")
static Custom := new ShortcutsProfile("Custom shortcuts", "ShortcutDefs-Custom.ini")
static Defaults := new ShortcutsProfile("Default shortcuts", "")
static None := new ShortcutsProfile("No shortcuts", "")
static Current := AltWin
}
IniRead, InitialShortcutsProfileName, %SettingsFile%, General, InitialShortcutsProfile
InitialShortcutsProfile := GetShortcutsProfileFromName(InitialShortcutsProfileName)
IniRead, PixelsPerStep, %SettingsFile%, Settings, PixelsPerStep, 50
InitializeIcon()
InitializeMenu()
KeysInUse := []
SetShortcutsProfile(InitialShortcutsProfile)
Return
InitializeIcon() {
if FileExist("AltWinHotKeys.ico") {
Menu, Tray, Icon, AltWinHotKeys.ico
}
}
InitializeMenu() {
Menu, Tray, Add, About Alt+Win HotKeys, ShowAboutDialog
Menu, Tray, Add, Settings, OpenSettings
Menu, Tray, Add, Edit Custom shortcuts, OpenCurrentShortSet
Menu, Tray, Add
Menu, Profiles, Add, % Profiles.AltWin.Name, SetAltKeyShortcuts
Menu, Profiles, Add, % Profiles.CtrlWin.Name, SetCtrlKeyShortcuts
Menu, Profiles, Add, % Profiles.Custom.Name, SetCustomShortcuts
Menu, Profiles, Add, % Profiles.Defaults.Name, SetDefaultShortcuts
Menu, Profiles, Add, % Profiles.None.Name, SetNoShortcuts
Menu, Tray, Add, Shortcut &Profiles, :Profiles
MoveStandardMenuToBottom()
}
GetShortcutsProfileFromName(ShortcutsProfileName) {
switch ShortcutsProfileName {
case Profiles.AltWin.Name: return Profiles.AltWin
case Profiles.CtrlWin.Name: return Profiles.CtrlWin
case Profiles.Custom.Name: return Profiles.Custom
case Profiles.None.Name: return Profiles.None
default: return Profiles.Defaults
}
}
SetAltKeyShortcuts() {
ChangeShortcutsProfile(Profiles.AltWin)
}
SetCtrlKeyShortcuts() {
ChangeShortcutsProfile(Profiles.CtrlWin)
}
SetCustomShortcuts() {
ChangeShortcutsProfile(Profiles.Custom)
}
SetDefaultShortcuts() {
ChangeShortcutsProfile(Profiles.Defaults)
}
SetNoShortcuts() {
ChangeShortcutsProfile(Profiles.None)
}
ChangeShortcutsProfile(ShortcutsProfile) {
if (ShortcutsProfile.File != "" AND NOT FileExist(ShortcutsProfile.File)) {
MsgBox % "Could not find shortcuts profile file: " ShortcutsProfile.File
return
}
ClearAllShortcuts()
UncheckAllProfiles()
SetShortcutsProfile(ShortcutsProfile)
MsgBox % "Move and Resize Windows is now configured for " Profiles.Current.Name
}
ClearAllShortcuts() {
global KeysInUse
For index, Keys in KeysInUse {
Hotkey, %Keys%, Off
}
KeysInUse := []
}
UncheckAllProfiles() {
Menu, Profiles, Uncheck, % Profiles.AltWin.Name
Menu, Profiles, Uncheck, % Profiles.CtrlWin.Name
Menu, Profiles, Uncheck, % Profiles.Custom.Name
Menu, Profiles, Uncheck, % Profiles.Defaults.Name
Menu, Profiles, Uncheck, % Profiles.None.Name
}
SetShortcutsProfile(ShortcutsProfile) {
Profiles.Current := ShortcutsProfile
SetShortcuts(ShortcutsProfile)
Menu, Profiles, Check, % ShortcutsProfile.Name
}
ShowAboutDialog() {
MsgBox 0, Alt+Win HotKeys, Alt+Win HotKeys - Utility to move and resize windows.`n`n Developed by Justin Clareburt
}
OpenSettings() {
global SettingsFile
Run, % "edit " SettingsFile
}
OpenCurrentShortSet() {
Run, % "edit " Profiles.Custom.File
}
MoveStandardMenuToBottom() {
Menu, Tray, Add
Menu, Tray, NoStandard
Menu, Tray, Standard
}
SetShortcuts(ShortcutsProfile) {
ShortcutsFile := ShortcutsProfile.File
if (Profiles.Current == Profiles.None) {
return
}
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveLeft", "", "!#Left")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveRight", "", "!#Right")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveUp", "", "!#Up")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveDown", "", "!#Down")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveTop", "MoveTop", "!#PgUp")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveTop2", "MoveTop", "!#Numpad8")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveBottom", "MoveBottom", "!#PgDn")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveBottom2", "MoveBottom", "!#Numpad2")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveHardLeft", "MoveHardLeft", "!#Home")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveHardLeft2", "MoveHardLeft", "!#Numpad4")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveHardRight", "MoveHardRight", "!#End")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveHardRight2", "MoveHardRight", "!#Numpad6")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveTopLeft", "MoveTopLeft", "!#Numpad7")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveTopRight", "MoveTopRight", "!#Numpad9")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveBottomLeft", "MoveBottomLeft", "!#Numpad1")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveBottomRight", "MoveBottomRight", "!#Numpad3")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveCenter", "MoveCenter", "!#Del")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveCenter2", "MoveCenter", "!#Numpad5")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeLeft", "ResizeLeft", "!+#Left")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeRight", "ResizeRight", "!+#Right")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeUp", "ResizeUp", "!+#Up")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeDown", "ResizeDown", "!+#Down")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeLarger", "ResizeLarger", "!+#PgDn")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeSmaller", "ResizeSmaller", "!+#PgUp")
ReadAndStoreHotKeyAction(ShortcutsFile, "Grow", "Grow", "!+#=")
ReadAndStoreHotKeyAction(ShortcutsFile, "Grow2", "Grow", "!+#NumpadAdd")
ReadAndStoreHotKeyAction(ShortcutsFile, "Grow3", "Grow", "!#=")
ReadAndStoreHotKeyAction(ShortcutsFile, "Grow4", "Grow", "!#NumpadAdd")
ReadAndStoreHotKeyAction(ShortcutsFile, "Grow5", "Grow", "^#+")
ReadAndStoreHotKeyAction(ShortcutsFile, "Grow6", "Grow", "^#NumpadAdd")
ReadAndStoreHotKeyAction(ShortcutsFile, "Shrink", "Shrink", "!+#-")
ReadAndStoreHotKeyAction(ShortcutsFile, "Shrink2", "Shrink", "!+#NumpadSub")
ReadAndStoreHotKeyAction(ShortcutsFile, "Shrink3", "Shrink", "!#-")
ReadAndStoreHotKeyAction(ShortcutsFile, "Shrink4", "Shrink", "!#NumpadSub")
ReadAndStoreHotKeyAction(ShortcutsFile, "Shrink5", "Shrink", "^#-")
ReadAndStoreHotKeyAction(ShortcutsFile, "Shrink6", "Shrink", "^#NumpadSub")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeHalfScreen", "ResizeHalfScreen", "!+#Del")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeThreeQuarterScreen", "ResizeThreeQuarterScreen", "!+#Home")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeFullScreen", "ResizeFullScreen", "!#Enter")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeFullScreen2", "ResizeFullScreen", "!+#Enter")
ReadAndStoreHotKeyAction(ShortcutsFile, "RestoreToPreviousPosn", "RestoreToPreviousPosn", "!#Backspace")
ReadAndStoreHotKeyAction(ShortcutsFile, "RestoreToPreviousPosnAndSize", "RestoreToPreviousPosnAndSize", "!+#Backspace")
ReadAndStoreHotKeyAction(ShortcutsFile, "SwitchToPreviousDesktop", "SwitchToPreviousDesktop", "^#,")
ReadAndStoreHotKeyAction(ShortcutsFile, "SwitchToNextDesktop", "SwitchToNextDesktop", "^#.")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveToPreviousDesktop", "MoveToPreviousDesktop", "^+#,")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveToPreviousDesktop2", "MoveToPreviousDesktop", "^+#Left")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveToNextDesktop", "MoveToNextDesktop", "^+#.")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveToNextDesktop2", "MoveToNextDesktop", "^+#Right")
ReadAndStoreHotKeyAction(ShortcutsFile, "TileWindowsVertically", "TileWindowsVertically", "!#V")
ReadAndStoreHotKeyAction(ShortcutsFile, "TileWindowsVertically2", "TileWindowsVertically", "!+#V")
ReadAndStoreHotKeyAction(ShortcutsFile, "TileWindowsHorizontally", "TileWindowsHorizontally", "!#H")
ReadAndStoreHotKeyAction(ShortcutsFile, "TileWindowsHorizontally2", "TileWindowsHorizontally", "!+#H")
ReadAndStoreHotKeyAction(ShortcutsFile, "CascadeWindows", "CascadeWindows", "!#C")
ReadAndStoreHotKeyAction(ShortcutsFile, "CascadeWindows2", "CascadeWindows", "!+#C")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeTo3Column", "", "!+#3")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeTo4Column", "", "!+#4")
ReadAndStoreHotKeyAction(ShortcutsFile, "ResizeTo5Column", "", "!+#5")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveLeftOneQuarter", "", "!#,")
ReadAndStoreHotKeyAction(ShortcutsFile, "MoveRightOneQuarter", "", "!#.")
return
}
ReadAndStoreHotKeyAction(ShortcutsFile, KeyCode, KeyAction, DefaultKeys) {
if (Profiles.Current == Profiles.Defaults) {
KeyCombo := DefaultKeys
} else {
IniRead, KeyCombo, %ShortcutsFile%, Shortcuts, %KeyCode%
}
if (KeyCombo != "ERROR") {
if (KeyAction == "") {
SetHotkeyAction(KeyCombo, KeyCode)
} else {
SetHotkeyAction(KeyCombo, KeyAction)
}
}
}
SetHotkeyAction(Keys, KeyAction) {
global KeysInUse
Hotkey, %Keys%, %KeyAction%, On
KeysInUse.Push(Keys)
}
MoveLeft:
DoMoveAndResize(-1, 0)
return
MoveRight:
DoMoveAndResize(1, 0)
return
MoveUp:
DoMoveAndResize(0, -1)
return
MoveDown:
DoMoveAndResize(0, 1)
return
MoveTop:
MoveToEdge("Top")
return
MoveBottom:
MoveToEdge("Bottom")
return
MoveHardLeft:
MoveToEdge("HardLeft")
return
MoveHardRight:
MoveToEdge("HardRight")
return
MoveTopLeft:
MoveToEdge("TopLeft")
return
MoveTopRight:
MoveToEdge("TopRight")
return
MoveBottomLeft:
MoveToEdge("BottomLeft")
return
MoveBottomRight:
MoveToEdge("BottomRight")
return
MoveCenter:
MoveWindowToCenter()
return
ResizeLeft:
DoMoveAndResize( , , -1, 0)
return
ResizeRight:
DoMoveAndResize( , , 1, 0)
return
ResizeUp:
DoMoveAndResize( , , 0, -1)
return
ResizeDown:
DoMoveAndResize( , , 0, 1)
return
ResizeLarger:
DoMoveAndResize( , , 1, 1)
return
ResizeSmaller:
DoMoveAndResize( , , -1, -1)
return
Grow:
DoMoveAndResize(-1, -1, 2, 2)
return
Shrink:
DoMoveAndResize(1, 1, -2, -2)
return
ResizeHalfScreen:
ResizeAndCenter(0.5)
return
ResizeThreeQuarterScreen:
ResizeAndCenter(0.75)
return
ResizeFullScreen:
ResizeAndCenter(1)
return
RestoreToPreviousPosn:
EnsureWindowIsRestored()
WinMove, WinX, WinY
return
RestoreToPreviousPosnAndSize:
EnsureWindowIsRestored()
WinMove, A, , WinX, WinY, WinW, WinH
return
TileWindowsVertically:
DllCall( "TileWindows", uInt,0, Int,0, Int,0, Int,0, Int,0 )
return
TileWindowsHorizontally:
DllCall( "TileWindows", uInt,0, Int,0, Int,0, Int,0, Int,0 )
return
CascadeWindows:
DllCall( "CascadeWindows", uInt,0, Int,4, Int,0, Int,0, Int,0 )
return
SwitchToPreviousDesktop()
{
send {LWin down}{LCtrl down}{Left}{LCtrl up}{LWin up}
return
}
SwitchToNextDesktop()
{
send {LWin down}{LCtrl down}{Right}{LCtrl up}{LWin up}
return
}
MoveToPreviousDesktop()
{
MoveWindowToOtherDesktop(-1)
}
MoveToNextDesktop()
{
MoveWindowToOtherDesktop(1)
}
MoveWindowToOtherDesktop(direction)
{
WinWait, A
WinHide
if (direction > 0) {
SwitchToNextDesktop()
} else {
SwitchToPreviousDesktop()
}
Sleep 100
WinShow
WinActivate
}
MoveToEdge(Edge)
{
WinNum := GetWindowNumber()
SysGet, Mon, MonitorWorkArea, %WinNum%
WinGetPos, WinX, WinY, WinW, WinH, A
if InStr(Edge, "Left")
NewX := MonLeft
if InStr(Edge, "Right")
NewX := MonRight - WinW
if InStr(Edge, "Top")
NewY := MonTop
if InStr(Edge, "Bottom")
NewY := MonBottom - WinH
RestoreMoveAndResize(A, NewX, NewY, NewW, NewH)
return
}
MoveWindowToCenter() {
WinGetPos, WinX, WinY, WinW, WinH, A
WinNum := GetWindowNumber()
DoResizeAndCenter(WinNum, WinW, WinH)
return
}
DoMoveAndResize(MoveX:=0, MoveY:=0, GrowW:=0, GrowH:=0)
{
GetMoveCoordinates(A, NewX, NewY, NewW, NewH, MoveX, MoveY, GrowW, GrowH)
RestoreMoveAndResize(A, NewX, NewY, NewW, NewH)
}
DoResizeAndCenter(WinNum, NewW, NewH)
{
GetCenterCoordinates(A, WinNum, NewX, NewY, NewW, NewH)
RestoreMoveAndResize(A, NewX, NewY, NewW, NewH)
}
ResizeAndCenter(Ratio)
{
WinNum := GetWindowNumber()
CalculateSizeByWinRatio(NewW, NewH, WinNum, Ratio)
DoResizeAndCenter(WinNum, NewW, NewH)
}
CalculateSizeByWinRatio(ByRef NewW, ByRef NewH, WinNum, Ratio)
{
WinNum := GetWindowNumber()
SysGet, Mon, MonitorWorkArea, %WinNum%
NewW := (MonRight - MonLeft) * Ratio
NewH := (MonBottom - MonTop) * Ratio
}
RestoreMoveAndResize(A, NewX, NewY, NewW, NewH)
{
EnsureWindowIsRestored()
WinMove, A, , NewX, NewY, NewW, NewH
}
GetMoveCoordinates(ByRef A, ByRef NewX, ByRef NewY, ByRef NewW, ByRef NewH, MovX:=0, MovY:=0, GrowW:=0, GrowH:=0)
{
global PixelsPerStep
WinGetPos, WinX, WinY, WinW, WinH, A
NewW := WinW + (PixelsPerStep * GrowW)
NewH := WinH + (PixelsPerStep * GrowH)
NewX := WinX + (PixelsPerStep * MovX)
NewY := WinY + (PixelsPerStep * MovY)
}
GetCenterCoordinates(ByRef A, WinNum, ByRef NewX, ByRef NewY, WinW, WinH)
{
SysGet, Mon, MonitorWorkArea, %WinNum%
ScreenW := MonRight - MonLeft
ScreenH := MonBottom - MonTop
NewX := (ScreenW-WinW)/2 + MonLeft
NewY := (ScreenH-WinH)/2 + MonTop
}
EnsureWindowIsRestored()
{
WinGet, ActiveWinState, MinMax, A
if (ActiveWinState != 0)
WinRestore, A
}
GetWindowNumber()
{
WinGetPos, WinX, WinY, WinW, WinH, A
SysGet, numMonitors, MonitorCount
Loop %numMonitors% {
SysGet, monitor, MonitorWorkArea, %A_Index%
if (monitorLeft <= WinX && WinX < monitorRight && monitorTop <= WinY && WinY <= monitorBottom){
return %A_Index%
}
}
return 1
}
ResizeTo3Column() {
ResizeToMultiColumn(3)
}
ResizeTo4Column() {
ResizeToMultiColumn(4)
}
ResizeTo5Column() {
ResizeToMultiColumn(5)
}
MoveLeftOneQuarter() {
WinNum := GetWindowNumber()
GoToColNum := GetPrevColNum(4, WinNum)
if (GoToColNum < 1) {
if (WinNum > 1) {
WinNum--
GoToColNum := 4
} else {
GoToColNum := 1
}
}
SnapToQuarterScreen(GoToColNum, WinNum)
}
MoveRightOneQuarter() {
WinNum := GetWindowNumber()
GoToColNum := GetNextColNum(4, WinNum)
if (GoToColNum > 4) {
SysGet, numMonitors, MonitorCount
if (WinNum < numMonitors) {
WinNum++
GoToColNum := 1
} else {
GoToColNum := 4
}
}
SnapToQuarterScreen(GoToColNum, WinNum)
}
ResizeToMultiColumn(ColCount) {
WinGetPos, WinX, WinY, WinW, WinH, A
WinNum := GetWindowNumber()
SysGet, Mon, MonitorWorkArea, %WinNum%
MonWorkingWidth := MonRight - MonLeft
MonWorkingHeight := MonBottom - MonTop
WinPaddingX := 0
NewY := MonTop
NewW := (MonWorkingWidth / ColCount) + (WinPaddingX * 2)
NewH := MonWorkingHeight
RestoreMoveAndResize(A, WinX, NewY, NewW, NewH)
}
SnapToQuarterScreen(ColNum, WinNum) {
WinGetPos, WinX, WinY, WinW, WinH, A
SysGet, Mon, MonitorWorkArea, %WinNum%
MonWorkingWidth := MonRight - MonLeft
ColWidth := MonWorkingWidth / 4
WinPaddingX := 0
NewX := MonLeft + ((ColNum-1) * ColWidth) - WinPaddingX
RestoreMoveAndResize(A, NewX, WinY, WinW, WinH)
}
GetPrevColNum(ColCount, WinNum) {
DestCol := GetCurrentColNum(WinNum, ColCount, bOnColEdge)
if (bOnColEdge) {
DestCol--
}
return DestCol
}
GetNextColNum(ColCount, WinNum) {
DestCol := GetCurrentColNum(WinNum, ColCount)
DestCol++
return DestCol
}
GetCurrentColNum(WinNum, ColCount, ByRef bOnColEdge := false)
{
WinGetPos, WinX, WinY, WinW, WinH, A
SysGet, Mon, MonitorWorkArea, %WinNum%
MonWorkingWidth := MonRight - MonLeft
MonWorkingHeight := MonBottom - MonTop
ColWidth := MonWorkingWidth / ColCount
AdjustX := 0
CurrentCol := 1
loop, %ColCount% {
ColStartX := Floor(MonLeft + (ColWidth * (A_Index-1)))
ColEndX := Floor(MonLeft + (ColWidth * A_Index))
if (WinX+AdjustX < ColEndX) {
bOnColEdge := (WinX = ColStartX-AdjustX)
CurrentCol := A_Index
break
}
}
return CurrentCol
}
;#c::Manager_closeWindow()
; alt-click-move.ahk
;
; When Alt + left mouse button is pressed, move the window under the cursor,
; as long as the window is not maximized, or a vnc viewer.
;
; Cody Cziesler
#SingleInstance force
!LButton::
; Get window under cursor
MouseGetPos, , , id
; Abort if window is maximized
ignore := flase
WinGet, window_minmax, MinMax, ahk_id %id%
if (window_minmax <> 0) {
ignore := true
}
; Abort if app is a vnc viewer
WinGetClass, class, A
if (InStr(class, "vnc")) {
ignore := true
}
; Send win + left mouse button (if not ignoring)
if (ignore) {
Send {Alt down}{LButton down}
}
; Get mouse and window position
CoordMode, Mouse, Screen
MouseGetPos, mouse_x, mouse_y
WinGetPos, win_x, win_y, , , ahk_id %id%
; Change win_x/win_y based on initial mouse position
win_x := mouse_x - win_x
win_y := mouse_y - win_y
; Reduce latency of movements
SetWinDelay, 0
; Set the transparency
if (!ignore) {
WinActivate, ahk_id %id%
WinSet Transparent, 150, ahk_id %id%
}
; Loop until left button released
loop {
if !GetKeyState("LButton", "P") {
break
}
if (!ignore) {
MouseGetPos, mouse_x, mouse_y
WinMove ahk_id %id%, , (mouse_x - win_x), (mouse_y - win_y)
}
}
; Reset the transparency
WinSet Transparent, Off, ahk_id %id%
; Release Alt + left mouse button
Send {Alt up}{LButton up}
return
; alt-click-move.ahk
;
; When Alt + left mouse button is pressed, move the window under the cursor,
; as long as the window is not maximized, or a vnc viewer.
;
; Cody Cziesler
#SingleInstance force
#LButton::
; Get window under cursor
MouseGetPos, , , id
; Abort if window is maximized
ignore := flase
WinGet, window_minmax, MinMax, ahk_id %id%
if (window_minmax <> 0) {
ignore := true
}
; Abort if app is a vnc viewer
WinGetClass, class, A
if (InStr(class, "vnc")) {
ignore := true
}
; Send Alt + left mouse button (if not ignoring)
if (ignore) {
Send {Alt down}{LButton down}
}
; Get mouse and window position
CoordMode, Mouse, Screen
MouseGetPos, mouse_x, mouse_y
WinGetPos, win_x, win_y, , , ahk_id %id%
; Change win_x/win_y based on initial mouse position
win_x := mouse_x - win_x
win_y := mouse_y - win_y
; Reduce latency of movements
SetWinDelay, 0
; Set the transparency
if (!ignore) {
WinActivate, ahk_id %id%
WinSet Transparent, 150, ahk_id %id%
}
; Loop until left button released
loop {
if !GetKeyState("LButton", "P") {
break
}
if (!ignore) {
MouseGetPos, mouse_x, mouse_y
WinMove ahk_id %id%, , (mouse_x - win_x), (mouse_y - win_y)
}
}
; Reset the transparency
WinSet Transparent, Off, ahk_id %id%
; Release Alt + left mouse button
Send {Alt up}{LButton up}
return