-
Notifications
You must be signed in to change notification settings - Fork 0
/
MG_Edit.ahk
1815 lines (1566 loc) · 43.9 KB
/
MG_Edit.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
Critical
Configs=Interval`nTimeoutThreshold`nTimeout`nThreshold`nDGInterval`nLongThresholdX`nLongThresholdY`nLongThreshold`n8Dir`nUseNavi`nUseExNavi`nEditCommand`nActiveAsTarget`nTraySubmenu
ListConf=ORangeDefault`nORangeA`nORangeB
reset()
Config_Interval=20
Config_TimeoutThreshold=12
Config_Timeout=400
Config_Threshold=60
Config_DGInterval=0
Config_LongThresholdX=800
Config_LongThresholdY=600
Config_LongThreshold=700
Config_8Dir=0
Config_ORangeDefault=3
Config_ORangeA=3
Config_ORangeB=3
Config_UseNavi=0
Config_UseExNavi=1
Config_TraySubmenu=0
Config_ActiveAsTarget=0
Config_EdgeMode=1
loadIniFile(A_ScriptDir . "\MouseGesture.ini")
RuleType_WClass=1
RuleType_CClass=2
RuleType_Exe=3
RuleType_Title=4
RuleType_Custom=5
RuleType_Include=6
RuleType_1=WClass
RuleType_2=CClass
RuleType_3=Exe
RuleType_4=Title
RuleType_5=Custom
RuleType_6=Include
HT:=AddCustomTemplateSub("","Window Elements","HT")
AddCustomTemplate(HT,"Titlebar","MG_HitTest()=""Caption""")
AddCustomTemplate(HT,"Titlebar Icon","MG_HitTest()=""SysMenu""")
AddCustomTemplate(HT,"Minimize Button","MG_HitTest()=""MinButton""")
AddCustomTemplate(HT,"Maximize Button","MG_HitTest()=""MaxButton""")
AddCustomTemplate(HT,"Close Button","MG_HitTest()=""CloseButton""")
AddCustomTemplate(HT,"Help Button","MG_HitTest()=""HelpButton""")
AddCustomTemplate(HT,"","")
AddCustomTemplate(HT,"Menubar","MG_HitTest()=""Menu""")
AddCustomTemplate(HT,"Vertical Scrollbar","MG_HitTest()=""VScroll""")
AddCustomTemplate(HT,"Horizontal Scrollbar","MG_HitTest()=""HScroll""")
AddCustomTemplate(HT,"Window Frame","MG_HitTest()=""Border""")
AddCustomTemplate(HT,"Resizable Corner","MG_HitTest()=""SizeBorder""")
AddCustomTemplate(HT,"Other Area","MG_HitTest()=""Client""")
AddCustomTemplate(HT,"","")
AddCustomTemplate(HT,"Tree/List","MG_TreeListHitTest()")
CS:=AddCustomTemplateSub("","Mouse Cursor","CS")
AddCustomTemplate(CS,"Normal (Arrow)","MG_GetCursor()=0x10011")
AddCustomTemplate(CS,"Line (Text Input)","MG_GetCursor()=0x10013")
AddCustomTemplate(CS,"Finger (Link Hover)","MG_GetCursor()=0x1002d")
AddCustomTemplate(CS,"Sand Glass","MG_GetCursor()=0x10015")
AddCustomTemplate(CS,"Cross","MG_GetCursor()=0x10017")
AddCustomTemplate(CS,"Disabled","MG_GetCursor()=0x10025")
AddCustomTemplate(CS,"Arrow + Sand Glass","MG_GetCursor()=0x10027")
AddCustomTemplate(CS,"Arrow + Question Mark","MG_GetCursor()=0x10029")
AddCustomTemplate(CS,"4-Direction Arrow","MG_GetCursor()=0x10023")
AddCustomTemplate(CS,"Up-Down Arrow","MG_GetCursor()=0x10021")
AddCustomTemplate(CS,"Left-Right Arrow","MG_GetCursor()=0x1001f")
AddCustomTemplate(CS,"UL-DR Arrow","MG_GetCursor()=0x1001b")
AddCustomTemplate(CS,"UR-DL Arrow","MG_GetCursor()=0x1001d")
AddCustomTemplate(CS,"","")
AddCustomTemplate(CS,"Any of the above curors","MG_GetCursor()<0x10030")
AddCustomTemplate(CS,"Default (Application Specified)","MG_GetCursor()>0x10030")
WS:=AddCustomTemplateSub("","Window Status","WS")
AddCustomTemplate(WS,"Maximized","MG_Win(""MinMax"")=1")
AddCustomTemplate(WS,"Normal","MG_Win(""MinMax"")=0")
AddCustomTemplate(WS,"Transparent","MG_Win(""Transparent"")<255")
AddCustomTemplate(WS,"Opaque","MG_Win(""Transparent"")=""""")
AddCustomTemplate(WS,"Topmost","MG_Win(""ExStyle"")&0x08")
AddCustomTemplate(WS,"Non-Topmost","!(MG_Win(""ExStyle"")&0x08)")
KS:=AddCustomTemplateSub("","Keyboard Status","KS")
AddCustomTemplate(KS,"Shift Key Down","GetKeyState(""Shift"")")
AddCustomTemplate(KS,"Shift Key Up","!GetKeyState(""Shift"")")
AddCustomTemplate(KS,"Ctrl Key Down","GetKeyState(""Ctrl"")")
AddCustomTemplate(KS,"Ctrl Key Up","!GetKeyState(""Ctrl"")")
AddCustomTemplate(KS,"Alt Key Down","GetKeyState(""Alt"")")
AddCustomTemplate(KS,"Alt Key Up","!GetKeyState(""Alt"")")
Buttons=LB`nRB`nMB`nX1B`nX2B`nWU`nWD
Button_LB=Left-Button Down
Button_RB=Right-Button Down
Button_MB=Middle-Button Down
Button_X1B=Button-4 Down
Button_X2B=Button-5 Down
Button_WU=Wheel-Up
Button_WD=Wheel-Down
Button_X3B=Button-6 Down
Button_X4B=Button-7 Down
Button_X5B=Button-8 Down
Button_X6B=Button-9 Down
Button_X7B=Button-10 Down
Button_X8B=Button-11 Down
Button_X9B=Button-12 Down
Button_LT=Left-Trigger Down
Button_RT=Right-Trigger Down
Button_ET=Touch Screen Top (All)
Button_ETA=Touch Screen Top (Left Half)
Button_ETB=Touch Screen Top (Right Half)
Button_ET1=Touch Screen Top (Left 1/3)
Button_ET2=Touch Screen Top (Center 1/3)
Button_ET3=Touch Screen Top (Right 1/3)
Button_EB=Touch Screen Bottom (All)
Button_EBA=Touch Screen Bottom (Left Half)
Button_EBB=Touch Screen Bottom (Right Half)
Button_EB1=Touch Screen Bottom (Left 1/3)
Button_EB2=Touch Screen Bottom (Center 1/3)
Button_EB3=Touch Screen Bottom (Right 1/3)
Button_EL=Touch Screen Bottom (All)
Button_ELA=Touch Screen Bottom (Upper Half)
Button_ELB=Touch Screen Bottom (Lower Half)
Button_EL1=Touch Screen Bottom (Upper 1/3)
Button_EL2=Touch Screen Bottom (Middle 1/3)
Button_EL3=Touch Screen Bottom (Lower 1/3)
Button_ER=Touch Screen Bottom (All)
Button_ERA=Touch Screen Bottom (Upper Half)
Button_ERB=Touch Screen Bottom (Lower Half)
Button_ER1=Touch Screen Bottom (Upper 1/3)
Button_ER2=Touch Screen Bottom (Middle 1/3)
Button_ER3=Touch Screen Bottom (Lower 1/3)
Button_CRT=Touch Screen Right-Top Corner
Button_CLT=Touch Screen Left-Top Corner
Button_CRB=Touch Screen Right-Bottom Corner
Button_CLB=Touch Screen Left-Bottom Corner
#Include *i %A_ScriptDir%\MG_MyButtonNames.ahk
LBButtons=
loadButtons()
if 1=/ini2ahk
{
FileDelete,%A_ScriptDir%\MG_Config.ahk
FileAppend,% ToAhk(),%A_ScriptDir%\MG_Config.ahk
ExitApp
}
GoSub,CreateGui
GuiControl,,LBButtons,`n%LBButtons%
AddActionTemplate("Key Stroke","Send,%[Format: +^!#{Key}`nModifier: + Shift、^ Ctrl、! Alt、# Win`nThe { } surrounding the key can be omitted`n{Key Down} for Press Down、{Key Up} for Press Up]%")
AddActionTemplate("Execute Toolbar Button Command","ButtonIDPicker")
AddActionTemplate("Execute Menubar Commond","WinMenuSelectItem,,,%[Menu Item (Delimiter: [,] Max: 6 Level Deep)]%")
AddActionTemplate("Run Program","Run,%[Input Program Command Line:]%")
AddActionTemplate("Copy to Clipboard","Clipboard=`n(%`RTrim0`n%[Input Text to be copied:]%`n)")
AddActionTemplate("Move Cursor to Position","MG_Move()")
AddActionTemplate("Activate Window","WinActivate")
AddActionTemplate("Minimize Window","WinMinimize")
AddActionTemplate("Maximize Window","WinMaximize")
AddActionTemplate("Restore Window","WinRestore")
AddActionTemplate("Close Window","WinClose")
AddActionTemplate("Send Window to Bottom","WinSet,Bottom")
AddActionTemplate("Kill Process","Process,Close,% MG_Win(""pid"")")
AddActionTemplate("Change Window Transparency","WinSet,Trans,%[Transparency (0-255):]%")
AddActionTemplate("Turn off Window Transparency","WinSet,Trans,Off")
AddActionTemplate("Turn on Window Topmost","WinSet,Topmost,On")
AddActionTemplate("Turn off Window Topmost","WinSet,Topmost,Off")
AddActionTemplate("Toggle Window Topmost","WinSet,Topmost,Toggle")
AddActionTemplate("Post Message","PostMessage,,,")
AddActionTemplate("Send Message","SendMessage,,,")
AddActionTemplate("Scroll Window","if(MG_While()){`nMG_InstantScroll()`n}")
AddActionTemplate("Scroll Window (IE Style)","if(MG_While()){`nMG_InstantScroll(0)`n}")
AddActionTemplate("Drag-Scroll","if(MG_While()){`nMG_DragScroll(%[Format: ppc_x,ppc_y`nCursor movement quantum (Pixel)`nDefault: 12,8]%)`n}")
AddActionTemplate("Sound Volume","SoundSet,%[0 ... 100: Set absolute value`n+1 ... +100/-1 ... -100: Increment/Decrement]%,MASTER,VOLUME")
AddActionTemplate("Mute Sound","SoundSet,%[[+]: Toggle ON/OFF`n[0]: OFF`n[1]: ON]%,MASTER,MUTE")
AddActionTemplate("Play a Sound","SoundPlay,%[Input WAVE File Path:]%")
AddActionTemplate("Timer","if(MG_Timer(-500))`n return`n")
AddActionTemplate("Wait for Input","MG_Wait(500)")
AddActionTemplate("Repeat until Button Up","if(MG_While(%[Input Interval: (Millisecond)]%)){`n`n}")
AddActionTemplate("Abort Current Gesture","MG_Abort()")
AddActionTemplate("Show Text as Tooltip","MG_Tooltip=`n(`n)")
ShowTargets()
ShowGestures()
ShowConfig()
Critical,Off
Gui,Show,,Mouse Gesture 2 Configuration
return
CreateGui:
/*
Menu,FileMenu,Add,クリップボードからインポート(&C),ImportFromClipboard
Menu,FileMenu,Add,
Menu,FileMenu,Add,保存(&S),MenuSave
Menu,FileMenu,Add,終了(&X),MenuExit
Menu,AppMenu,Add,新規作成(&N),TargetNew
Menu,AppMenu,Add,削除(&D),TargetDelete
Menu,AppMenu,Add,定義`テキストをコピー(&C),CopyTarget
Menu,GestureMenu,Add,新規作成(&N),GestureNew
Menu,GestureMenu,Add,削除(&D),GestureDelete
Menu,GestureMenu,Add,定義`テキストをコピー(&C),CopyGesture
;Menu,GestureMenu,Add,関連する条件定義`もコピー(&C),Dummy
Menu,MainMenu,Add,ファイル(&F),:FileMenu
Menu,MainMenu,Add,条件定義`(&F),:AppMenu
Menu,MainMenu,Add,ジェスチ`ャ定義`(&F),:GestureMenu
Gui,Menu,MainMenu
*/
Gui,+Delimiter`n
Gui,Add,Tab,x8 y2 w376 h340,Condition Definition`nGesture Definition`nAction Binding`nOptions
Gui,Add,Button,Section w20 h20 gTargetNew,+
Gui,Add,Button,x+0 w20 h20 gTargetDelete vBTargetDelete,-
Gui,Add,Button,x+0 w20 h20 gCopyTarget,C
Gui,Add,Button,x+0 w20 h20 gTargetUp,↑
Gui,Add,Button,x+0 w20 h20 gTargetDown,↓
Gui,Add,ListBox,xs y+1 w100 h280 Section vLBTarget gLBTargetSelect AltSubmit
Gui,Add,Text,vLabel1 ys x+8 Section w40,&Name
Gui,Add,Edit,x+2 w126 vETargetName gETargetNameChange
Gui,Add,Button,x+2 w50 h20 Disabled gTargetRename vBTargetRename,Change
Gui,Add,ListView,xs y+4 w220 h178 section NoSortHdr vLVRule gLVRuleSelect AltSubmit,Type`nCondition Value
LV_ModifyCol(1,65)
LV_ModifyCol(2,150)
Gui,Add,Button,x+1 w20 h20 gRuleUp vBRuleUp Disabled,↑
Gui,Add,Button,y+60 w20 h20 gRuleDelete vBRuleDelete Disabled,×
Gui,Add,Button,y+60 w20 h20 gRuleDown vBRuleDown Disabled,↓
Gui,Add,DropDownList,xs y+2 w138 vDDLAnd gDDLAndChoose AltSubmit,Match Any Rule`nMatch All Rules
Gui,Add,Button,x+2 yp h20 vBAddRule gBAddRulePress Disabled,Add
Gui,Add,Button,x+2 h20 vBUpdateRule gBUpdateRulePress Disabled,Update
Gui,Add,Text,vLabel2 xs y+4 w40,&Type
Gui,Add,DropDownList,x+2 w134 vDDLRuleType AltSubmit,Window Class`nControl Class`nFile Name`nTitle`nCustom Condition`nMatch Other Rules
Gui,Add,Button,x+2 h20 gBRulePicker,Helper
Gui,Add,Text,vLabel3 xs y+4 w40,&Value
Gui,Add,Edit,x+2 w178 vERuleValue,
; Gesture Definition
Gui,Tab,2
Gui,Add,Button,Section w20 h20 gGestureNew,+
Gui,Add,Button,x+0 w20 h20 gGestureDelete,-
Gui,Add,Button,x+0 w20 h20 gCopyGesture,C
Gui,Add,Button,x+0 w20 h20 gGestureUp,↑
Gui,Add,Button,x+0 w20 h20 gGestureDown,↓
Gui,Add,ListBox,xs y+2 w100 h280 Section vLBGesture1 gLBGestureSelect1 AltSubmit
Gui,Add,Text,vLabel4 ys x+8 Section w40,&Name
Gui,Add,Edit,x+2 w126 vEGestureName1
Gui,Add,Button,x+2 w50 h20 Disabled gGestureRename1 vBGestureRename1,Change
Gui,Add,ListBox,xs y+4 w220 h80 section vLBGesturePattern gLBGesturePatternSelect AltSubmit,
Gui,Add,Button,x+1 w20 h20 gGesturePatternUp vBGesturePatternUp Disabled,↑
Gui,Add,Button,y+5 w20 h20 gGesturePatternDelete vBGesturePatternDelete Disabled,×
Gui,Add,Button,y+5 w20 h20 gGesturePatternDown vBGesturePatternDown Disabled,↓
Gui,Add,Edit,xs y+4 h20 w138 vEGesture gEGestureChange
Gui,Add,Button,x+2 h20 vBAddGesturePattern gBAddGesturePattern Disabled,Add
Gui,Add,Button,x+2 h20 vBUpdateGesturePattern gBUpdateGesturePattern Disabled,Update
Gui,Add,Text,vLabel5 xs y+4 Section,Movement
Gui,Add,Button,xs ys+24 w24 h24 gDir7 Disabled vBStrokeUL,\
Gui,Add,Button,x+1 w24 h24 gDir8 Disabled vBStrokeU,↑
Gui,Add,Button,x+1 w24 h24 gDir9 Disabled vBStrokeUR,/
Gui,Add,Button,xs y+2 w24 h24 gDir4 Disabled vBStrokeL,←
Gui,Add,Button,x+26 w24 h24 gDir6 Disabled vBStrokeR,→
Gui,Add,Button,xs y+2 w24 h24 gDir1 Disabled vBStrokeDL,/
Gui,Add,Button,x+1 w24 h24 gDir2 Disabled vBStrokeD,↓
Gui,Add,Button,x+1 w24 h24 gDir3 Disabled vBStrokeDR,\
Gui,Add,Button,xs y+16 w73 h36 gGesturePatternBS vBGesturePatternBS,Remove Last Input in List
Gui,Add,ListBox,x+12 ys+2 w132 h132 vLBButtons gLBButtons AltSubmit,
Gui,Add,Button,xp+0 y+4 w132 h20 gBButtonUp vBButtonUp Disabled,Any Button Up
; Action Binding
Gui,Tab,3
Gui,Add,Button,Section w20 h20 gGestureNew,+
Gui,Add,Button,x+0 w20 h20 gGestureDelete,-
Gui,Add,Button,x+0 w20 h20 gCopyGesture,C
Gui,Add,Button,x+0 w20 h20 gGestureUp,↑
Gui,Add,Button,x+0 w20 h20 gGestureDown,↓
Gui,Add,ListBox,xs y+2 w100 h280 Section vLBGesture2 gLBGestureSelect2 AltSubmit
Gui,Add,Text,vLabel7 ys x+8 Section w40,&Name
Gui,Add,Edit,x+2 w126 vEGestureName2
Gui,Add,Button,x+2 w50 h20 Disabled gGestureRename2 vBGestureRename2,Change
Gui,Add,ListView,xs y+4 w220 h110 section NoSortHdr vLVAction gLVActionSelect AltSubmit,Condition`nAction
LV_ModifyCol(1,75)
LV_ModifyCol(2,140)
Gui,Add,Button,x+1 w20 h20 gActionUp vBActionUp Disabled,↑
Gui,Add,Button,y+25 w20 h20 gActionDelete vBActionDelete Disabled,×
Gui,Add,Button,y+25 w20 h20 gActionDown vBActionDown Disabled,↓
Gui,Add,Text,vLabel8 xs y+4 w48,&Condition
Gui,Add,DropDownList,x+2 h20 w88 vDDLTarget r8
Gui,Add,Button,x+2 h20 Disabled vBAddAction gBAddActionPress,Add
Gui,Add,Button,x+2 h20 Disabled vBUpdateAction gBUpdateActionPress,Update
Gui,Add,Edit,xs w220 h86 -Wrap vEAction WantTab T16
Gui,Add,DropDownList,xp+0 y+4 h20 w188 r16 vDDLActionTemplate AltSubmit
Gui,Add,Button,x+2 h20 vBAddActionLine gBAddActionLinePress,Add
; Options
Gui,Tab,4
Gui,Add,GroupBox,y+4 w224 h142 Section,Detection Threshold (Pixel)
Gui,Add,Text,xs+4 yp+16 w160 vLabel14,Detection Start
Gui,Add,Edit,x+2 w48 vConfig_TimeoutThreshold
Gui,Add,UpDown
Gui,Add,Text,xs+4 y+4 w160 vLabel10,Normal Stroke
Gui,Add,Edit,x+2 w48 vConfig_Threshold
Gui,Add,UpDown
Gui,Add,Text,xs+4 y+4 w160 vLabel11,4-Direction Horizontal [LL] [RR]
Gui,Add,Edit,x+2 w48 vConfig_LongThresholdX
Gui,Add,UpDown
Gui,Add,Text,xs+4 y+4 w160 vLabel12,4-Direction Vertical [UU] [DD]
Gui,Add,Edit,x+2 w48 vConfig_LongThresholdY
Gui,Add,UpDown
Gui,Add,Text,xs+4 y+4 w160 vLabel13,8-Direction Long Diagonal
Gui,Add,Edit,x+2 w48 vConfig_LongThreshold
Gui,Add,UpDown
Gui,Add,GroupBox,xs y+8 w224 h92 ,Time Threshold (Millisecond)
Gui,Add,Text,xs+4 yp+16 w160 vLabel15,Gesture Timeout
Gui,Add,Edit,x+2 w48 vConfig_Timeout
Gui,Add,UpDown
Gui,Add,Text,xs+4 y+4 w160 vLabel16,Double Gesture Interval
Gui,Add,Edit,x+2 w48 vConfig_DGInterval
Gui,Add,UpDown
Gui,Add,Text,xs+4 y+4 w160 vLabel17,Stroke Sampling Period
Gui,Add,Edit,x+2 w48 vConfig_Interval
Gui,Add,UpDown
Gui,Add,CheckBox,xs y+12 vConfig_ActiveAsTarget,Always Use Active Window as Target
Gui,Add,CheckBox,xs y+8 vConfig_TraySubmenu,Cascade Mouse Gesture Tray Menu
Gui,Add,CheckBox,xs y+8 vConfig_UseNavi,Show Gesture Hints by Default
Gui,Add,CheckBox,x+4 vConfig_UseExNavi,Show Hints as Arrows (32-bit only)
Gui,Add,CheckBox,ys+8 xs+230 w120 Section vConfig_8Dir,8-Direction Mode
Gui,Add,GroupBox,y+6 w122 h114 Section,Diagonal Angle
Gui,Add,Text,xs+4 yp+16 w66 vLabel18,First Stroke
Gui,Add,DDL,x+6 w38 vConfig_ORangeDefault AltSubmit,0`n30`n45`n60`n90
Gui,Add,Text,xs+4 y+10 w66 vLabel19,After Orthogonal
Gui,Add,DDL,x+6 w38 vConfig_ORangeA AltSubmit,0`n30`n45`n60`n90
Gui,Add,Text,xs+4 y+10 w66 vLabel20,After Diagonal
Gui,Add,DDL,x+6 w38 vConfig_ORangeB AltSubmit,0`n30`n45`n60`n90
Gui,Add,GroupBox,xs Section y+30 w122 h68,Define New Button
Gui,Add,Text,xs+4 yp+16 w32 vLabel21,Name
Gui,Add,Edit,x+0 w44 vNewButtonName
Gui,Add,Button,x+2 w32 h20 gDefineNewButton,Add
Gui,Add,Text,xs+4 yp+24 w32 vLabel22,Key
Gui,Add,Edit,x+0 w76 vNewButtonKey
Gui,Tab
Gui,Add,Button,x8 y350 w130 gImportFromClipboard,&Import from Clipboard
Gui,Add,Button,x240 y350 w64 gSaveExit,&OK
Gui,Add,Button,x+4 w64 gExit,&Cancel
Loop,40{
GuiControlGet,pos,pos,Label%A_Index%
if(!ErrorLevel){
posY+=4
posX+=2
GuiControl,Move,Label%A_Index%,x%posX% y%posY%
}
}
return
GuiClose:
GuiEscape:
Exit:
ExitApp
Dummy:
return
Dir1:
Gui,Submit,NoHide
if(Config_8Dir){
GuiControl,,EGesture,%EGesture%1
}
return
Dir2:
Gui,Submit,NoHide
if(Config_8Dir){
GuiControl,,EGesture,%EGesture%2
}else{
GuiControl,,EGesture,%EGesture%D
}
return
Dir3:
Gui,Submit,NoHide
if(Config_8Dir){
GuiControl,,EGesture,%EGesture%3
}
return
Dir4:
Gui,Submit,NoHide
if(Config_8Dir){
GuiControl,,EGesture,%EGesture%4
}else{
GuiControl,,EGesture,%EGesture%L
}
return
Dir6:
Gui,Submit,NoHide
if(Config_8Dir){
GuiControl,,EGesture,%EGesture%6
}else{
GuiControl,,EGesture,%EGesture%R
}
return
Dir7:
Gui,Submit,NoHide
if(Config_8Dir){
GuiControl,,EGesture,%EGesture%7
}
return
Dir8:
Gui,Submit,NoHide
if(Config_8Dir){
GuiControl,,EGesture,%EGesture%8
}else{
GuiControl,,EGesture,%EGesture%U
}
return
Dir9:
Gui,Submit,NoHide
if(Config_8Dir){
GuiControl,,EGesture,%EGesture%9
}
return
LBButtons:
if(A_GuiEvent="DoubleClick"){
Gui,Submit,NoHide
GuiControl,,EGesture,% EGesture . Button_%LBButtons% . "_"
}
return
BButtonUp:
Gui,Submit,NoHide
GuiControl,,EGesture,%EGesture%_
return
MenuSave:
return
TargetNew:
Target_Count++
Target_%Target_Count%_Name=Target_%Target_Count%
Target_%Target_Count%_Count=0
Target_%Target_Count%_IsAnd=0
ShowTargets()
ShowTarget(Target_Count)
return
TargetUp:
if(Target_Editing>1){
TargetSwap(Target_Editing-1,Target_Editing)
ShowTargets()
ShowTarget(Target_Editing-1)
}
return
TargetDown:
if(Target_Editing<Target_Count){
TargetSwap(Target_Editing,Target_Editing+1)
ShowTargets()
ShowTarget(Target_Editing+1)
}
return
TargetDelete:
/*
Loop,%Target_Count%{
if(A_Index>Target_Editing){
TargetSwap(A_Index-1,A_Index)
}
}
Target_Count--
ShowTargets()
ShowTarget(Target_Editing)
return
*/
TargetDelete(Target_Editing)
ShowTargets()
ShowTarget((Target_Editing>Target_Count) ? Target_Count : Target_Editing)
return
TargetDelete(idx){
global
if(Target_%idx%_Name="Disable"){
MsgBox,Disable Condition Can NOT be deleted
return
}
Msgbox,1,Delete Confirm,% "Are you sure to delete Conditon: " . Target_%idx%_Name
IfMsgBox,OK
{
Loop{
idx++
TargetMove(idx,idx-1)
if(idx>=Target_Count){
break
}
}
Target_Count--
}
}
TargetMove(from,to){
global
Target_%to%_Name:=Target_%from%_Name
Target_%to%_IsAnd:=Target_%from%_IsAnd
Target_%to%_Count:=Target_%from%_Count
Loop,% Target_%from%_Count
{
Target_%to%_%A_Index%_Type:=Target_%from%_%A_Index%_Type
Target_%to%_%A_Index%_Value:=Target_%from%_%A_Index%_Value
}
}
TargetSwap(a,b){
TargetMove(a,"tmp")
TargetMove(b,a)
TargetMove("tmp",b)
}
TargetRename:
Gui,Submit,NoHide
idx:=0
flag:=0
Loop,% Gesture_Count{
idx++
jdx:=0
Loop,% Gesture_%idx%_Count{
jdx++
if(Gesture_%idx%_%jdx%_Target==Target_%Target_Editing%_Name){
flag:=1
break
}
}
if(flag){
break
}
}
if(flag){
MsgBox,3,Change Condition Name,This condition is in use,`nChange all the instance names of this condition?
IfMsgBox,Yes
{
idx:=0
Loop,% Gesture_Count{
idx++
jdx:=0
Loop,% Gesture_%idx%_Count{
jdx++
if(Gesture_%idx%_%jdx%_Target==Target_%Target_Editing%_Name){
Gesture_%idx%_%jdx%_Target:=ETargetName
}
}
}
ShowGestures()
ShowGesture(Gesture_Editing)
}
else IfMsgBox,Cancel
return
}
Target_%Target_Editing%_Name=%ETargetName%
ShowTargets()
ShowTarget(Target_Editing)
return
ETargetNameChange:
Gui,Submit,NoHide
if(Target_Editing && !RegExMatch(ETargetName,"^(|WClass|CClass|Title|Exe|Custom|Include|And|G|Default)$|[^\w]")){
Loop,%Target_Count%{
if(Target_%A_Index%_Name=ETargetName){
GuiControl,Disable,BTargetRename
return
}
}
GuiControl,Enable,BTargetRename
}else{
GuiControl,Disable,BTargetRename
}
return
; Show All Targets
ShowTargets(){
global
local str,str2
Menu,TargetList,Add
Menu,TargetList,DeleteAll
Loop,%Target_Count%{
Join(str,Target_%A_Index%_Name)
if(Target_%A_Index%_Name!="Disable"){
Join(str2,Target_%A_Index%_Name)
}
Menu,TargetList,Add,% Target_%A_Index%_Name,TargetListMenuSelect
}
GuiControl,,LBTarget,`n%str%
GuiControl,,DDLTarget,`nDefault`n%Str2%
GuiControl,Choose,DDLTarget,1
}
; Select Target
LBTargetSelect:
Gui,Submit,NoHide
ShowTarget(LBTarget)
ClearRule()
return
ShowTarget(idx){
local v
Target_Editing:=idx
GuiControl,,ETargetName,% Target_%idx%_Name
Gui,ListView,LVRule
GuiControl,-Redraw,LVRule
LV_Delete()
Loop,% Target_%idx%_Count {
LV_Add("",Target_%idx%_%A_Index%_Type,Target_%idx%_%A_Index%_Value)
}
GuiControl,+Redraw,LVRule
if(Target_%idx%_Name="Disable"){
GuiControl,Disable,BTargetDelete
GuiControl,Disable,BTargetRename
}else{
GuiControl,Enable,BTargetDelete
GuiControl,Enable,BTargetRename
}
GuiControl,Enable,BAddRule
GuiControl,Choose,DDLAnd,% Target_%idx%_IsAnd ? 2 : 1
GuiControlGet,v,FocusV
if(v!="LBTarget"){
GuiControl,Choose,LBTarget,%idx%
}
}
DDLAndChoose:
Gui,Submit,NoHide
Target_%Target_Editing%_IsAnd:=(DDLAnd=2)
return
RuleUp:
if(Rule_Editing>1){
RuleSwap(Target_Editing,Rule_Editing-1,Rule_Editing)
ShowTarget(Target_Editing)
ShowRule(Target_Editing,Rule_Editing-1)
}
return
RuleDown:
if(Rule_Editing<Target_%Target_Editing%_Count){
RuleSwap(Target_Editing,Rule_Editing,Rule_Editing+1)
ShowTarget(Target_Editing)
ShowRule(Target_Editing,Rule_Editing+1)
}
return
RuleDelete:
RuleDelete(Target_Editing,Rule_Editing)
ShowTarget(Target_Editing)
ShowRule(Target_Editing,(Rule_Editing>Target_%Target_Editing%_Count) ? Target_%Target_Editing%_Count : Rule_Editing)
return
RuleDelete(target,idx){
global
Loop{
idx++
RuleMove(target,idx,idx-1)
if(idx>=Target_%Target_Editing%_Count){
break
}
}
Target_%Target_Editing%_Count--
}
RuleSwap(target,a,b){
RuleMove(target,a,"tmp")
RuleMove(target,b,a)
RuleMove(target,"tmp",b)
}
RuleMove(target,from,to){
global
Target_%target%_%to%_Type:=Target_%target%_%from%_Type
Target_%target%_%to%_Value:=Target_%target%_%from%_Value
}
; Select Rule
LVRuleSelect:
if(A_EventInfo && Rule_Editing!=A_EventInfo){
ShowRule(Target_Editing,A_EventInfo)
}
return
ShowRule(target,idx){
local t,v
Rule_Editing:=idx
t:=Target_%target%_%idx%_Type
GuiControl,Choose,DDLRuleType,% RuleType_%t%
GuiControl,,ERuleValue,% Target_%target%_%idx%_Value
GuiControl,Enable,BUpdateRule
GuiControl,Enable,BRuleUp
GuiControl,Enable,BRuleDelete
GuiControl,Enable,BRuleDown
if(Target_Editing=target){
Gui,ListView,LVRule
LV_Modify(idx,"Select")
}
}
ClearRule(){
global
Rule_Editing=0
GuiControl,Choose,DDLRuleType,1
GuiControl,,ERuleValue,
GuiControl,Disable,BUpdateRule
GuiControl,Disable,BRuleUp
GuiControl,Disable,BRuleDelete
GuiControl,Disable,BRuleDown
}
BAddRulePress:
Gui,Submit,NoHide
AddRule(Target_Editing,DDLRuleType,ERuleValue)
return
AddRule(tgt,type,val){
local idx
idx:=++Target_%tgt%_Count
UpdateRule(tgt,idx,type,val)
}
BUpdateRulePress:
Gui,Submit,NoHide
UpdateRule(Target_Editing,Rule_Editing,DDLRuleType,ERuleValue)
return
UpdateRule(tgt,idx,type,val){
global
Target_%tgt%_%idx%_Type:=RuleType_%type%
Target_%tgt%_%idx%_Value:=val
if(Target_Editing=tgt){
ShowTarget(tgt)
ShowRule(tgt,idx)
}
}
; Rule Picker Button
BRulePicker:
Gui,Submit,NoHide
if(DDLRuleType<5){
SetTimer,RulePickerTimer,100
Hotkey,RButton up,RulePickerHotkey,On
}else if(DDLRuleType=5){
Menu,CustomExpressions,Show
}else if(DDLRuleType=6){
Menu,TargetList,Show
}
return
RulePickerTimer:
Tooltip,Right-Click on Target Window
return
RulePickerHotkey:
CoordMode,Mouse,Screen
MouseGetPos,MG_X,MG_Y,MG_HWND,MG_HCTL,3
SendMessage,0x84,0,% MG_Y<<16|MG_X,,ahk_id %MG_HCTL%
If ErrorLevel=4294967295
MouseGetPos,,,,MG_HCTL,2
if(DDLRuleType=1){
WinGetClass,ERuleValue,ahk_id %MG_HWND%
}else if(DDLRuleType=2){
WinGetClass,ERuleValue,ahk_id %MG_HCTL%
}else if(DDLRuleType=3){
WinGet,ERuleValue,ProcessName,ahk_id %MG_HWND%
}else{
WinGetTitle,ERuleValue,ahk_id %MG_HWND%
}
GuiControl,,ERuleValue,%ERuleValue%
SetTimer,RulePickerTimer,Off
Hotkey,RButton up,Off
Tooltip
return
AddCustomTemplate(submenu,title="",value=""){
local c
Menu,CustomExpressions%submenu%,Add,%title%,CustomExpressionsMenuSelect
if(CustomExpressions%submenu%_Count){
c:=++CustomExpressions%submenu%_Count
}else{
c:=CustomExpressions%submenu%_Count:=1
}
CustomExpressions%submenu%_%c%:=value
}
AddCustomTemplateSub(submenu,title,name){
local nn
nn=%submenu%_%name%
Menu,CustomExpressions%nn%,Add
Menu,CustomExpressions%nn%,DeleteAll
Menu,CustomExpressions%submenu%,Add,%title%,:CustomExpressions%nn%
return nn
}
CustomExpressionsMenuSelect:
if(IsLabel(%A_ThisMenu%_%A_ThisMenuItemPos%)){
GoSub,% %A_ThisMenu%_%A_ThisMenuItemPos%
}else{
SetRuleValue(%A_ThisMenu%_%A_ThisMenuItemPos%)
}
return
SetRuleValue(val){
GuiControl,,ERuleValue,%val%
}
TargetListMenuSelect:
GuiControl,,ERuleValue,%A_ThisMenuItem%
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; Gesture Routines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
GestureNew:
Gesture_Count++
Gesture_%Gesture_Count%_Name=Gesture_%Gesture_Count%
Gesture_%Gesture_Count%_Count=0
ShowGestures()
ShowGesture(Gesture_Count)
return
GestureUp:
if(Gesture_Editing>1){
GestureSwap(Gesture_Editing-1,Gesture_Editing)
ShowGestures()
ShowGesture(Gesture_Editing-1)
}
return
GestureDown:
if(Gesture_Editing<Gesture_Count){
GestureSwap(Gesture_Editing,Gesture_Editing+1)
ShowGestures()
ShowGesture(Gesture_Editing+1)
}
return
GestureDelete:
GestureDelete(Gesture_Editing)
ShowGestures()
ShowGesture((Gesture_Editing>Gesture_Count) ? Gesture_Count : Gesture_Editing)
return
GestureDelete(idx){
global
Msgbox,1,Delete Confirm,% "Are you sure to delete Gesture/Action: " . Gesture_%idx%_Name
IfMsgBox,OK
{
Loop{
idx++
GestureMove(idx,idx-1)
if(idx>=Gesture_Count){
break
}
}
Gesture_Count--
}
}
GestureMove(from,to){
global
Gesture_%to%_Name:=Gesture_%from%_Name
Gesture_%to%_Patterns:=Gesture_%from%_Patterns
Gesture_%to%_Count:=Gesture_%from%_Count
Loop,% Gesture_%from%_Count
{
Gesture_%to%_%A_Index%_Target:=Gesture_%from%_%A_Index%_Target
Gesture_%to%_%A_Index%_Action:=Gesture_%from%_%A_Index%_Action
}
}
GestureSwap(a,b){
GestureMove(a,"tmp")
GestureMove(b,a)
GestureMove("tmp",b)
}
GestureRename1:
Gui,Submit,NoHide
Gesture_%Gesture_Editing%_Name=%EGestureName1%
ShowGestures()
ShowGesture(Gesture_Editing)
return
GestureRename2:
Gui,Submit,NoHide
Gesture_%Gesture_Editing%_Name=%EGestureName2%
ShowGestures()
ShowGesture(Gesture_Editing)
return
ShowGestures(){
global
local str
Loop,%Gesture_Count%{
Join(str,Gesture_%A_Index%_Name)