forked from jgpaiva/GridMove
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GridMove.ahk
1592 lines (1393 loc) · 39.9 KB
/
GridMove.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
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;GridMove
;By jgpaiva
;date: May 2006
;function: Adjusts windows to a predefined or user-defined desktop grid.
;;options:
MButtonDrag := True ;to be able to drag a window using the 3rd mouse button
LButtonDrag:=True ;to be able to drag a window by its title
EdgeDrag := True ;to be able to bring the grid up when dragging a window to the edge
EdgeTime := 500
ShowGroupsFlag := True ;configures the showing or not of the groups
ShowNumbersFlag := True ;configures the showing or not of the numbers
TitleSize := 100
GridName = Grids/3-part.grid
GridOrder = 2 Part-Vertical,3-Part,EdgeGrid,Dual-Screen
UseCommand := True
CommandHotkey = #g
UseFastMove := True
FastMoveModifiers = #
Exceptions = QuarkXPress,Winamp v1.x,Winamp PE,Winamp Gen,Winamp EQ,Shell_TrayWnd,32768,Progman,DV2ControlHost
MButtonExceptions = inkscape.exe
MButtonTimeout = 0.3
Transparency = 200
SafeMode := True
FastMoveMeta =
SequentialMove := False
DebugMode := False
StartWithWindows := False
DisableTitleButtonsDetection := False
ColorTheme=orange
Language=EN
NoTrayIcon:=False
FirstRun:=True
;Registered=quebec
;;end of options
ScriptVersion = 1.19.72
MutexExists("GridMove_XB032")
Sysget, CaptionSize,4 ;get the size of the caption
Sysget, BorderSize, 46 ;get the size of the border
CaptionSize += BorderSize
TitleLeft := CaptionSize
if DebugMode
Traytip,GridMove,Reading INI,10
;goSub, showOptions
GetScreenSize() ;get the size of the monitors
GetMonitorSizes()
RectangleSize := 1
ComputeEdgeRectangles()
OSDcreate()
GoSub,setlanguage
GoSub, ReadIni
AeroEnabled := loadAero()
GoSub,setlanguage
SetWinDelay, 0
SetBatchLines, -1
If 0 = 1
GridName = %1%
createTrayMenus()
if DebugMode
Traytip,GridMove,Reading the grid file,10
GoSub, ApplyGrid
Mutex := False
GroupsShowing := False
EdgeFlag := True
MousePositionLock := False
WM_ENTERSIZEMOVE = 0x231
WM_EXITSIZEMOVE = 0x232
WindowY =
WindowX =
WindowWidth =
WindowHeight=
WindowXBuffer =
WindowYBuffer =
;if DebugMode
; Traytip,GridMove,Creating the grid,10
;GoSub,createGroups NOT NEEDED, GRID IS CREATED IN "APPLY GRID"
if DebugMode
Traytip,GridMove,Registering Hotkeys...,10
;hotkey definitions:
If UseCommand
Hotkey, %CommandHotkey%, Command
If MButtonDrag
Hotkey, MButton, MButtonMove
If UseFastMove
GoSub,DefineHotkeys
if SequentialMove
{
Hotkey, %FastMoveModifiers%Right,MoveToNext
Hotkey, %FastMoveModifiers%Left,MoveToPrevious
}
MPFlag := True
Settimer, MousePosition, 100
;Settimer, ReloadOnResolutionChange, 1000
HotKey,RButton,NextGrid
HotKey,RButton,off
HotKey,Esc,cancel
HotKey,Esc,off
HotKey,F12,AddCurrentToIgnore
HotKey,F11,AddCurrentToIgnoreCancel
HotKey,F12,off
HotKey,F11,off
#maxthreadsperhotkey,1
#singleinstance,force
#InstallMouseHook
#InstallKeybdHook
#noenv
; GoSub,TitleButtonInitialization
if DebugMode
Traytip,GridMove,Start process completed,10
SetBatchLines, 20ms
return
MutexExists(name) {
mutex := DllCall("CreateMutex", "UInt", 0, "UInt", 0, "str", name)
last_error := A_LastError
; DllCall("CloseHandle", "uint", mutex)
return last_error == 183 ; ERROR_ALREADY_EXISTS
}
;*******************Init
createTrayMenus()
{
global
if DebugMode
Traytip,GridMove,Creating the templates menu,10
;;tray menu:
Menu,Tray, Add, %tray_help%, AboutHelp
Menu,Tray, Default, %tray_help%
Menu,Tray, Tip, GridMove V%ScriptVersion%
Menu,Tray, Add, %tray_updates%, EnableAutoUpdate
Menu,Tray, Add, %tray_ignore%, AddToIgnore
if(Registered<>"quebec")
Menu,Tray, Add, %tray_windows%, StartWithWindowsToggle
if(Registered<>"quebec")
if(startWithWindowsQ())
Menu,Tray,Check, %tray_windows%
else
Menu,Tray,UnCheck, %tray_windows%
createTemplatesMenu()
Menu,Tray, Add, %tray_templates%, :templates_menu
If(NoTrayIcon){
msgbox,here
menu, tray, NoIcon
}else{
IfExist %A_ScriptDir%\Images\gridmove.ico
Menu,Tray, Icon,%A_ScriptDir%\Images\gridmove.ico
}
Menu,Tray, NoStandard
if DebugMode
Traytip,GridMove,Creating the options tray menu,10
createOptionsMenu()
Menu,Tray, Add,%tray_options%, :options_menu
createColorsMenu()
Menu,Tray, Add, %tray_colors%, :colors_menu
createHotkeysMenu()
Menu,Tray, Add, %tray_hotkeys%, :hotkeys_menu
Menu,Tray, Add, %tray_restart%, ReloadProgram
Menu,Tray, Add, %tray_exit%, ExitProgram
}
createTemplatesMenu()
{
global GridName
global tray_refresh
Loop,%A_ScriptDir%\Grids\*.grid
{
StringTrimRight,out_GridName2,A_LoopFileName,5
Menu,templates_menu, add, %out_GridName2%,Template-Grids
}
Menu,templates_menu,add,,
Menu,templates_menu, add,%tray_refresh%, RefreshTemplates
stringgetpos,out_pos,gridname,\,R1
if out_pos <= 0
stringgetpos,out_pos,gridname,/,R1
if out_pos <= 0
return
stringlen, len, gridname
StringRight,out_GridName,gridname,% len - out_pos -1
StringTrimRight,out_GridName2,out_GridName,5
IfExist %A_ScriptDir%\Grids\%out_GridName2%.grid
menu,templates_menu,check,%out_GridName2%
}
createOptionsMenu()
{
global
Menu,options_menu, add, %tray_safemode%, Options_SafeMode
Menu,options_menu, add, %tray_showgrid%, Options_ShowGrid
Menu,options_menu, add, %tray_shownumbers%, Options_ShowNumbers
Menu,options_menu, add, %tray_lbuttondrag%, Options_LButtonDrag
Menu,options_menu, add, %tray_mbuttondrag%, Options_MButtonDrag
Menu,options_menu, add, %tray_edgedrag%, Options_EdgeDrag
Menu,options_menu, add, %tray_edgetime%, Options_EdgeTime
Menu,options_menu, add, %tray_titlesize%, Options_TitleSize
Menu,options_menu, add, %tray_gridorder%, Options_GridOrder
If LButtonDrag
Menu,options_menu,check, %tray_lbuttondrag%
else
Menu,options_menu,Disable, %tray_titlesize%
If MButtonDrag
Menu,options_menu,check, %tray_mbuttondrag%
If EdgeDrag
Menu,options_menu,check, %tray_edgedrag%
else
Menu,options_menu,Disable, %tray_edgetime%
If ShowGroupsFlag
Menu,options_menu, Check, %tray_showgrid%
If ShowNumbersFlag
Menu,options_menu, Check, %tray_shownumbers%
If SafeMode
Menu,options_menu, Check, %tray_safemode%
}
createColorsMenu()
{
global tray_color_orange
global tray_color_blue
global tray_color_black
global colortheme
Menu,colors_menu, add, %tray_color_orange%, setColorTheme
Menu,colors_menu, add, %tray_color_blue%, setColorTheme
Menu,colors_menu, add, %tray_color_black%, setColorTheme
if(colortheme="orange")
Menu,colors_menu,check, %tray_color_orange%
if(colortheme="blue")
Menu,colors_menu,check, %tray_color_blue%
if(colortheme="black")
Menu,colors_menu,check, %tray_color_black%
}
setColorTheme:
if(A_ThisMenuItem=tray_color_orange)
colorTheme=orange
if(A_ThisMenuItem=tray_color_blue)
colorTheme=blue
if(A_ThisMenuItem=tray_color_black)
colorTheme=black
gosub, writeini
reload
return
createHotkeysMenu()
{
global
Menu,hotkeys_menu, add, %tray_usecommand%, Hotkeys_UseCommand
Menu,hotkeys_menu, add, %tray_commandhotkey%, Hotkeys_CommandHotkey
Menu,hotkeys_menu, add, %tray_fastmove%, Hotkeys_UseFastMove
Menu,hotkeys_menu, add, %tray_fastmovemodifiers%, Hotkeys_FastMoveModifiers
If UseCommand
Menu,hotkeys_menu,check, %tray_usecommand%
else
Menu,hotkeys_menu,Disable, %tray_commandhotkey%,
If UseFastMove
Menu,hotkeys_menu,check, %tray_fastmove%
else
Menu,hotkeys_menu,Disable, %tray_fastmovemodifiers%
}
startWithWindowsQ()
{
loop,%A_startup%\*.lnk
{
if (A_LoopFileName = "GridMove.lnk")
{
return true
}
}
return false
}
;*******************Drop Zone Mode
DropZoneMode:
DropZoneModeFlag := true
gosub,showgroups
Hotkey,RButton,on
Hotkey,Esc,on
Canceled := False
CoordMode,Mouse,Screen
hideGui2()
loop
{
If Canceled
{
Critical, on
Gui,2:Hide
Hotkey,RButton,off
Hotkey,Esc,off
DropZoneModeFlag := false
Critical, off
return
}
GetKeyState,State,%hotkey%,P
If State = U
break
MouseGetPos, MouseX, MouseY, window,
flagLButton:=true
Critical, on
SetBatchLines, 10ms
loop,%NGroups%
{
TriggerTop := %A_Index%TriggerTop
TriggerBottom := %A_Index%TriggerBottom
TriggerRight := %A_Index%TriggerRight
TriggerLeft := %A_Index%TriggerLeft
If (MouseY >= TriggerTop AND MouseY <= TriggerBottom
AND MouseX <= TriggerRight AND MouseX >= TriggerLeft)
{
GetGrid(A_Index)
If (GridTop = "AlwaysOnTop" OR GridTop = "Run")
{
GridTop := TriggerTop
GridLeft := TriggerLeft
GridWidth := TriggerRight - TriggerLeft
GridHeight := TriggerBottom - TriggerTop
}
If (GridTop = "Maximize")
{
GridTop := GetMonitorTop(MouseX,MouseY)
GridLeft := GetMonitorLeft(MouseX,MouseY)
GridWidth := GetMonitorRight(MouseX,MouseY) - GetMonitorLeft(MouseX,MouseY)
GridHeight := GetMonitorBottom(MouseX,MouseY) - GetMonitorTop(MouseX,MouseY)
}
If not canceled
{
if(!AeroEnabled)
WinMove,ahk_id %gui2hwnd%, ,%GridLeft%,%GridTop%,%GridWidth%,%GridHeight%
else
{
left:=GridLeft + 3
top:=GridTop + 3
width:=GridWidth - 6
height:=GridHeight - 6
WinMove,ahk_id %gui2hwnd%, ,%Left%,%Top%,%Width%,%Height%
}
}
flagLButton:=false
break
}
}
Critical, off
if flagLButton
hideGui2()
}
DropZoneModeFlag := false
Gui,2:Hide
Hotkey,RButton,off
Hotkey,Esc,off
GoSub,SnapWindow
Gosub,hidegroups
return
hideGui2()
{
global AeroEnabled
if(!AeroEnabled)
Gui,2: +ToolWindow +AlwaysOnTop -Disabled -SysMenu -Caption
else
Gui,2: +ToolWindow +AlwaysOnTop -Disabled -SysMenu
Gui,2: Show, x-10000 y-10000 w0 h0 NoActivate,% A_SPACE
}
cancel:
if not canceled
{
canceled := True
GoSub, HideGroups
Gui,2:Hide
}
return
;*******************Mbutton method
MButtonMove:
CoordMode,Mouse,Screen
MouseGetPos, OldMouseX, OldMouseY, Window,
WinGetTitle,WinTitle,ahk_id %Window%
WinGetClass,WinClass,ahk_id %Window%
WinGetPos,WinLeft,WinTop,WinWidth,WinHeight,ahk_id%Window%
WinGet,WinStyle,Style,ahk_id %Window%
WinGet,WindowId,Id,ahk_id %Window%
WinGet, WindowProcess , ProcessName, ahk_id %Window%
if SafeMode
{
if not (WinStyle & 0x40000) ;0x40000 = WS_SIZEBOX = WS_THICKFRAME
{
sendinput,{MButton down}
Keywait,mbutton
sendinput,{MButton up}
Return
}
}
If Winclass in %Exceptions%
{
sendinput,{MButton down}
Keywait,mbutton
sendinput,{MButton up}
Return
}
If WindowProcess in %MButtonExceptions%
{
sendinput,{MButton down}
Keywait,mbutton
sendinput,{MButton up}
Return
}
KeyWait,MButton,T%MButtonTimeOut%
if errorlevel = 0
{
sendinput,{MButton}
return
}
Winactivate, ahk_id %window%
Hotkey = MButton
GoSub, DropZoneMode
return
;**********************edge/lbutton method
MousePosition:
Settimer, MousePosition,off
if MousePositionLock
return
KeyWait, LButton,U
KeyWait, LButton,D
SetBatchLines, -1
CoordMode,Mouse,Relative
MouseGetPos,OldMouseX,OldMouseY,MouseWin, MouseControl
WinGetTitle,Wintitle,ahk_id %mousewin%
WinGetClass,WinClass,ahk_id %mousewin%
WinGetPos,WinLeft,WinTop,WinWidth,WinHeight,ahk_id%MouseWin%
WinGet,WinStyle,Style,ahk_id %mousewin%
WinGet,WindowId,Id,ahk_id %mousewin%
If Winclass in %Exceptions%
{
Settimer, MousePosition,10
Return
}
if SafeMode
if not (WinStyle & 0x40000) ;0x40000 = WS_SIZEBOX = WS_THICKFRAME
{
Settimer, MousePosition,10
Return
}
If (OldMouseY > CaptionSize OR OldMouseY <= BorderSize + 1 OR WinTitle = "" )
{
Settimer, MousePosition,10
return
}
if(WinWidth > 3 * TitleSize)
{
If (TitleSize < WinWidth - 100 AND LButtonDrag
AND OldmouseX > TitleLeft AND OldMouseX < TitleSize
AND (MouseControl = "" OR DisableTitleButtonsDetection))
{
Hotkey = LButton
sendinput {LButton up}
GoSub,DropZoneMode
Settimer, MousePosition,10
return
}
}
else
{
If (LButtonDrag AND OldmouseX > TitleLeft
AND OldMouseX < TitleLeft + 20 AND WinWidth > 170
AND (MouseControl = "" OR DisableTitleButtonsDetection))
{
Hotkey = LButton
sendinput {LButton up}
GoSub,DropZoneMode
Settimer, MousePosition,10
return
}
}
if not EdgeDrag
{
settimer, MousePosition,10
return
}
SetBatchLines, 10ms
CoordMode,Mouse,Screen
EdgeFlag := true
SetTimer, EdgeMove, Off
loop
{
MouseGetPos, MouseX, MouseY
GetKeyState, State, LButton, P
If (state = "U" or MousePositionLock)
{
SetTimer, EdgeMove, Off
Settimer, MousePosition,10
return
}
EdgeFlagFound := false
loop,%RectangleCount%
{
if(mouseX >= EdgeRectangleXL%A_Index% && mouseX <= EdgeRectangleXR%A_Index%
&& mouseY >= EdgeRectangleYT%A_Index% && mouseY <= EdgeRectangleYB%A_Index%)
{
EdgeFlagFound := true
break
}
}
if EdgeFlagFound
{
if EdgeFlag
{
settimer, EdgeMove, %EdgeTime%
EdgeFlag := False
}
}
else
{
SetTimer, EdgeMove, Off
EdgeFlag := True
}
sleep,100
;eternal loop
}
return
edgemove:
SetTimer, EdgeMove, Off
HotKey = LButton
sendinput, {LButton up}
MousePositionLock := true
SetBatchLines, -1
GoSub,DropZoneMode
MousePositionLock := false
EdgeFlag := True
Settimer, MousePosition,10
return
;**********************Snap Window to Grid
SnapWindow:
sendinput, {LButton up}
CoordMode,Mouse,Screen
Moved := False
loop %NGroups%
{
triggerTop := %A_Index%TriggerTop
triggerBottom := %A_Index%TriggerBottom
triggerRight := %A_Index%TriggerRight
triggerLeft := %A_Index%TriggerLeft
GridBottom :=0
GridRight :=0
GridTop :=0
GridLeft :=0
If (MouseY >= triggerTop AND MouseY <= triggerBottom
AND MouseX <= triggerRight AND MouseX >= triggerLeft)
{
GetGrid(A_Index)
If GridTop = AlwaysOnTop
{
WinSet, AlwaysOnTop, Toggle,A
return
}
If GridTop = Maximize
{
winget,state,minmax,A
if state = 1
WinRestore,A
else
PostMessage, 0x112, 0xF030,,, A,
return
}
If GridTop = Run
{
Run,%GridLeft% ,%GridRight%
return
}
WinRestore,A
Moved := True
if ShouldUseSizeMoveMessage(WinClass)
SendMessage WM_ENTERSIZEMOVE, , , ,ahk_id %windowid%
WinMove, ahk_id %windowid%, ,%GridLeft%,%GridTop%,%GridWidth%,%GridHeight%,
if ShouldUseSizeMoveMessage(WinClass)
SendMessage WM_EXITSIZEMOVE, , , ,ahk_id %windowid%
break
}
}
If Moved
StoreWindowState(WindowID,WinLeft,WinTop,WinWidth,WinHeight)
gosub, hidegroups
return
GetGrid(number)
{
global
MouseGetPos, MouseX, MouseY, window,
GridTop := %number%GridTop
GridBottom := %number%GridBottom
GridRight := %number%GridRight
GridLeft := %number%GridLeft
TriggerTop := %number%TriggerTop
TriggerBottom := %number%TriggerBottom
TriggerRight := %number%TriggerRight
TriggerLeft := %number%TriggerLeft
if GridTop in run,maximize,AlwaysOnTop
return
If GridTop = WindowHeight
{
MonitorBottom := GetMonitorBottom(MouseX, MouseY)
MonitorTop := GetMonitorTop(MouseX, MouseY)
GridTop := MouseY - 0.5 * WinHeight
If (GridTop + WinHeight > MonitorBottom)
GridTop := MonitorBottom - WinHeight
If (GridTop < MonitorTop)
GridTop := MonitorTop
GridBottom := GridTop + WinHeight
}
If GridLeft = WindowWidth
{
MonitorRight := GetMonitorRight(MouseX, MouseY)
MonitorLeft := GetMonitorLeft(MouseX, MouseY)
GridLeft := MouseX - 0.5 * WinWidth
If (GridLeft + WinWidth > MonitorRight)
GridLeft := MonitorRight - WinWidth
If (GridLeft < MonitorLeft)
GridLeft := MonitorLeft
GridRight := GridLeft + WinWidth
}
If GridTop = restore
{
data := GetWindowState(WindowID)
If data
{
GridLeft := WindowX
GridRight := WindowX + WindowWidth
GridTop := WindowY
GridBottom := WindowY + WindowHeight
}
else
{
GridLeft := WinLeft
GridRight := WinLeft + WinWidth
GridTop := WinTop
GridBottom := WinTop + WinHeight
}
}
if (GridTop = "Current")
GridTop := WinTop
else
GridTop := round(GridTop)
if (GridLeft = "Current")
GridLeft := WinLeft
else
GridLeft := round(GridLeft)
if (GridRight = "Current")
GridRight := WinLeft + WinWidth
else
GridRight := round(GridRight)
if(GridBottom = "Current")
GridBottom := WinTop + WinHeight
else
GridBottom := round(GridBottom)
GridWidth := GridRight - GridLeft
GridHeight := GridBottom - GridTop
}
;*************************************************************************Groups
showgroups:
if not ShowGroupsFlag
return
Gui,+ToolWindow +AlwaysOnTop -Disabled -SysMenu -Caption
WinSet, AlwaysOnTop, On,ahk_id %GuiId%
Gui,Show, X%ScreenLeft% Y%ScreenTop% W%ScreenWidth% H%ScreenHeight% noactivate,GridMove Drop Zone
;sleep,100
GroupsShowing := True
return
Hidegroups:
Gui,hide
return
setGuiColors()
{
global shadowcolor
global textcolor
global guicolor
global colortheme
global horizontalGrid
global verticalGrid
if(colortheme="blue")
{
Gui, Font, s15 cBlue, Tahoma
shadowcolor=555555
textcolor=0000FF
guicolor=0000EF
horizontalGrid=Gridh_blue.bmp
verticalGrid=Gridv_blue.bmp
}else if(colortheme="black")
{
Gui, Font, s15 cBlack, Tahoma
shadowcolor=333333
textcolor=000000
guicolor=333333
horizontalGrid=Gridh_black.bmp
verticalGrid=Gridv_black.bmp
}else{
Gui, Font, s15 cRed, Tahoma
shadowcolor=000000
textcolor=FFD300
guicolor=EEAA99
horizontalGrid=Gridh_orange.bmp
verticalGrid=Gridv_orange.bmp
}
}
creategroups:
gui,destroy
setGuiColors()
loop,%NGroups%
{
TriggerTop := %A_Index%TriggerTop - ScreenTop
TriggerBottom := %A_Index%TriggerBottom - ScreenTop
TriggerLeft := %A_Index%TriggerLeft - ScreenLeft
TriggerRight := %A_Index%TriggerRight - ScreenLeft
TriggerHeight := TriggerBottom - TriggerTop
TriggerWidth := TriggerRight - TriggerLeft
GridTop := %A_Index%GridTop
GridLeft := %A_Index%GridLeft
TextTop := %A_Index%TriggerTop - ScreenTop
TextTop += Round((%A_Index%TriggerBottom - %A_Index%TriggerTop) / 2 )- 11
TextLeft := %A_Index%TriggerLeft - ScreenLeft
TextLeft += Round((%A_Index%TriggerRight - %A_Index%TriggerLeft) / 2) - 5
RestoreLeft := TextLeft - 50
tempTop := triggerTop - 1
tempBottom := triggerBottom - 1
tempLeft := triggerLeft - 1
tempRight := triggerRight - 1
tempHeight := tempBottom - tempTop +2
tempWidth := tempRight - tempLeft +2
Gui, add, Picture, Y%tempTop% X%tempLeft% W%tempWidth% H3 ,%A_ScriptDir%\Images\%horizontalGrid%
Gui, add, Picture, Y%tempBottom% X%tempLeft% W%tempWidth% H3 ,%A_ScriptDir%\Images\%horizontalGrid%
Gui, add, Picture, Y%tempTop% X%tempLeft% W3 H%tempHeight% ,%A_ScriptDir%\Images\%verticalGrid%
Gui, add, Picture, Y%tempTop% X%tempRight% W3 H%tempHeight% ,%A_ScriptDir%\Images\%verticalGrid%
shadowleft := textleft + 1
shadowtop := texttop + 1
If ShowNumbersFlag
If GridTop is number
If GridLeft is number
If A_Index < 10
{
Gui, add, text, BackGroundTrans c%shadowcolor% X%ShadowLeft% Y%ShadowTop% ,%A_Index%
Gui, add, text, BackGroundTrans c%textcolor% X%TextLeft% Y%TextTop% ,%A_Index%
}
else
{
Gui, add, text,% "X" ShadowLeft - 6 " Y" ShadowTop "c"shadowcolor "BackGroundTrans" ,%A_Index%
Gui, add, text,% "X" TextLeft - 6 " Y" TextTop "c"textcolor "BackGroundTrans" ,%A_Index%
}
RestoreLeftShadow := RestoreLeft + 1
RestoreUndo := RestoreLeft + 20
RestoreUndoShadow := RestoreUndo + 1
If ShowNumbersFlag
{
If (GridTop = "WindowHeight" OR GridLeft = "WindowWidth")
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%ShadowLeft% Y%ShadowTop% ,%A_Index%
Gui, add, text,c%textcolor% BackGroundTrans X%TextLeft% Y%TextTop% ,%A_Index%
}
If Gridtop = Restore
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%RestoreUndoShadow% Y%ShadowTop% ,%A_Index%-Undo
Gui, add, text,c%textcolor% BackGroundTrans X%RestoreUndo% Y%TextTop% ,%A_Index%-Undo
}
If GridTop = Maximize
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%RestoreLeftShadow% Y%ShadowTop% ,%A_Index%-Maximize
Gui, add, text,c%textcolor% BackGroundTrans X%RestoreLeft% Y%TextTop% ,%A_Index%-Maximize
}
If GridTop = AlwaysOnTop
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%RestoreLeftShadow% Y%ShadowTop% ,%A_Index%-On Top
Gui, add, text,c%textcolor% BackGroundTrans X%RestoreLeft% Y%TextTop% ,%A_Index%-On Top
}
}
else
{
If Gridtop = Restore
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%RestoreUndoShadow% Y%ShadowTop% ,Undo
Gui, add, text,c%textcolor% BackGroundTrans X%RestoreUndo% Y%TextTop% ,Undo
}
If GridTop = Maximize
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%RestoreLeftShadow% Y%ShadowTop% ,Maximize
Gui, add, text,c%textcolor% BackGroundTrans X%RestoreLeft% Y%TextTop% ,Maximize
}
If GridTop = AlwaysOnTop
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%RestoreLeftShadow% Y%ShadowTop% ,On Top
Gui, add, text,c%textcolor% BackGroundTrans X%RestoreLeft% Y%TextTop% ,On Top
}
}
If Gridtop = Run
{
GridBottom := %A_Index%GridBottom
GridLeft := %A_Index%GridLeft
If ShowNumbersFlag
{
If (%A_Index%GridBottom != "")
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%RestoreLeftShadow% Y%ShadowTop% ,%A_Index%-%GridBottom%
Gui, add, text,c%textcolor% BackGroundTrans X%RestoreLeft% Y%TextTop% ,%A_Index%-%GridBottom%
}
else
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%RestoreLeftShadow% Y%ShadowTop% ,%A_Index%-%GridLeft%
Gui, add, text,c%textcolor% BackGroundTrans X%RestoreLeft% Y%TextTop% ,%A_Index%-%GridLeft%
}
}else
{
If (%A_Index%GridBottom != "")
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%RestoreLeftShadow% Y%ShadowTop% ,%GridBottom%
Gui, add, text,c%textcolor% BackGroundTrans X%RestoreLeft% Y%TextTop% ,%GridBottom%
}
else
{
Gui, add, text,c%shadowcolor% BackGroundTrans X%RestoreLeftShadow% Y%ShadowTop% ,%GridLeft%
Gui, add, text,c%textcolor% BackGroundTrans X%RestoreLeft% Y%TextTop% ,%GridLeft%
}
}
}
}
Gui, +AlwaysOnTop +ToolWindow -Caption +LastFound +E0x20
Gui, Color, %guicolor%
Gui, Margin,0,0
Gui,show,x0 y0 w0 h0 noactivate,GridMove Drop Zone 0xba
WinGet,GuiId,Id,GridMove Drop Zone 0xba
WinSet, TransColor, %guicolor%, ahk_id %GuiId%
Gui,2: +lastfound
gui2hwnd:=WinExist() ;handle.
if(!AeroEnabled)
{
WinSet, Transparent, %Transparency%,
Gui,2: +ToolWindow +AlwaysOnTop -Disabled -SysMenu -Caption
Gui,2: Margin,0,0
}
else
{
Gui,2: Color, 0
Aero_ChangeFrameAreaAll(gui2hwnd) ;call the Function
}
Gui,hide
return
;***********************************************************Aditional Functions
ExitProgram:
ExitApp
return
ReloadProgram:
Reload
return
RefreshTemplates:
Menu,templates_menu,DeleteAll
createTemplatesMenu()
return
Hotkeys_UseCommand:
If UseCommand
UseCommand := False
else
UseCommand := True
GoSub,WriteIni
Reload
return
Hotkeys_UseFastMove:
If UseFastMove
UseFastMove := False
else
UseFastMove := True
GoSub,WriteIni
Reload
return
Hotkeys_CommandHotkey:
inputbox,input, %input_hotkey_title%,%input_hotkey%,,,,,,,,%CommandHotkey%
if errorlevel <> 0
return
CommandHotkey := input
GoSub, WriteIni
reload
return
Hotkeys_FastMoveModifiers:
inputbox,input, %input_fastmove_title%,%input_fastmove%,,,,,,,,%FastMoveModifiers%
if errorlevel <> 0
return
FastMoveModifiers := input
GoSub, WriteIni