-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcapsez.ahk
4085 lines (3550 loc) · 99.4 KB
/
capsez.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
;CapsLock增强脚本,例子 {{{1
;by Ez
;v190721 添加在tc里面中键点击打开目录
;v190904 更新暂停等热键,直接把AutoHotkey.exe改名为capsez.exe
;v190916 添加几种模式的开关,解决BUG10任务栏无法切换
;v190927 添加快捷键在TC中打开资源管理器中选中的文件,添加在tc中双击右键返回上一级。自动获取TC路径
;v191214 添加媒体播放相关快捷键和右键拖动窗口,解决一点小问题和小细节
;v200108 修复在资管或桌面没选文件的问题。再修复一些细节
;v200401 添加不同程序中对应不同的小菜单,增强对话框,tab组合键等
;v210405 添加侧边键增强等等细节。
;v210601 继续添加对浏览器和播放器和侧边键鼠标的使用增强。
;v210801 添加对IrfanView等程序的快捷键增强,改进调用启动器popsel的方式,其他小细节等
;v211125 添加开启或关闭随系统自动启动,以及其他很小细节的优化
;v220401 小细节优化
;v220626 添加tc中数字键单击和双击效果,添加鼠标长按模式,添加everything中筛选器等,添加alt空格截图的开关,tc中alt+E为F4,中键改为在对侧面板新开标签,
;v220629 修复启动的时候卡顿,以及卡键问题
;v220710 优化tc中数字键双击和长按操作,优化微信接收文件等
;建议对“例子”位置进行自行修改
;管理员权限代码,放在文件开头 {{{1
Loop, %0%
{
param := %A_Index% ; Fetch the contents of the variable whose name is contained in A_Index.
params .= A_Space . param
}
ShellExecute := A_IsUnicode ? "shell32\ShellExecute":"shell32\ShellExecuteA"
if not A_IsAdmin
{
If A_IsCompiled
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_ScriptFullPath, str, params , str, A_WorkingDir, int, 1)
Else
DllCall(ShellExecute, uint, 0, str, "RunAs", str, A_AhkPath, str, """" . A_ScriptFullPath . """" . A_Space . params, str, A_WorkingDir, int, 1)
ExitApp
}
;文件头 {{{1
;Directives
#WinActivateForce
#InstallKeybdHook
#InstallMouseHook
#Persistent ;让脚本持久运行(关闭或ExitApp)
#MaxMem 4 ;max memory per var use
#NoEnv
#SingleInstance Force
#MaxHotkeysPerInterval 10000 ;Avoid warning when mouse wheel turned very fast
SetCapsLockState AlwaysOff
;SendMode InputThenPlay
;KeyHistory
SetBatchLines -1 ;让脚本无休眠地执行(换句话说,也就是让脚本全速运行)
SetKeyDelay -1 ;设置每次Send和ControlSend发送键击后自动的延时,使用-1表示无延时
Process Priority,,High ;线程,主,高级别
SendMode Input
DetectHiddenWindows, on
SetWinDelay,0
SetControlDelay,0
;************** group定义^ ************** {{{1
;GroupAdd, group_browser,ahk_class St.HDBaseWindow
GroupAdd, group_browser,ahk_class IEFrame ;IE
GroupAdd, group_browser,ahk_class ApplicationFrameWindow ;Edge
GroupAdd, group_browser,ahk_class MozillaWindowClass ;Firefox
GroupAdd, group_browser,ahk_class QQBrowser_WidgetWin_1
GroupAdd, group_browser,ahk_exe chrome.exe ;Chrome
GroupAdd, group_browser,ahk_exe msedge.exe
GroupAdd, group_browser,ahk_exe 115chrome.exe
;115的播放器
GroupAdd, group_browser,YywPlayerOperateFrame ahk_class XMLWnd
GroupAdd, group_disableCtrlSpace, ahk_exe excel.exe
GroupAdd, group_disableCtrlSpace, ahk_exe pycharm.exe
GroupAdd, group_disableCtrlSpace, ahk_exe SQLiteStudio.exe
GroupAdd,GroupDiagOpenAndSave,新建 ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,选择 ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,保存 ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,另存 ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,打开 ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,上传 ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,导入 ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,插入 ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,浏览 ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,Open ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,Save ahk_class #32770
GroupAdd,GroupDiagOpenAndSave,Select ahk_class #32770
;GroupAdd, group_disableCtrlSpace, ahk_exe gvim.exe
;GroupAdd, group_disableCtrlSpace, ahk_class NotebookFrame(注:ahk_class后面是AHK检测出的mathematica的class名)
;************** group定义$ **************
;设定5分钟重启一次脚本,防止卡键 1000*60*15
GV_ReloadTimer := % 1000*60*5
GV_ToggleReload := 1
Gosub,AutoReloadInit
Gosub,CreatTrayMenu
;Esc键的作用,默认WinClose,作为alt+f4关闭程序,可选CapsLock,作为切换大小写
;GV_EscKeyAs := "WinClose"
;GV_EscKeyAs := "Escape"
;GV_EscKeyAs := "CapsLock"
GV_EscKeyAs := "Backspace"
;启动器选择,可选为popsel和qsel
;GV_PopSel_QSel := "popsel"
GV_PopSel_QSel := "qsel"
;是否启用光标下滚轮
GV_ToggleWheelOnCursor := 0
;tab系列组合键,适合左键右鼠,启用后直接按tab会感觉有一点延迟,默认开启,开关为ctrl+win+alt+花号
GV_ToggleTabKeys := 1
;启用空格系列快捷键,启用会影响打字,在tc中会不能按住连选文件,默认关闭,开关为ctrl+win+alt+空格
GV_ToggleSpaceKeys := 0
;在浏览器中启用空格系列快捷键
GV_GroupBrowserToggleSpaceKeys := 1
;在浏览器中切换滚轮模式
;视频中滚轮为左右快进,主要是用来看视频网站,开关默认为左边alt加空格或者双击侧边键1
GV_GroupBrowserToggleWheelModeLeftRight := 0
;页面中滚轮为翻页,几行和一页间切换
GV_GroupBrowserToggleWheelModeUpDown := 0
;在浏览器中切换侧边键作为中键模式
GV_GroupBrowserToggleMButtonMode := 0
;在Totalcmd中使用数字键,单击快速打开,双击跳转
GV_TotalcmdToggleJumpByNumber := 1
;单键模式,开关按键为caps+/
GV_ToggleKeyMode := 0
;截图文件临时变量
global SSFileName
;截图的时候同时进剪贴板
global GV_ScreenShot2Clip := 1
;64位的Win7下,在输入框中是148003967
GV_CursorInputBox_64Win710 := 148003967
;正常鼠标指针
GV_CursorNormal_64Win710 := 124973738
;超链接鼠标指针
GV_CursorClick_64Win710 := 1197314685
GV_CursorInputBox := GV_CursorInputBox_64Win710
GV_CursorClick := GV_CursorClick_64Win710
GV_CursorNormal := GV_CursorNormal_64Win710
;处于编辑状态
GV_Edit_Mode := 0
gv_url_tdx_f10 := "http://data.eastmoney.com/notices/stock/"
gv_url_html := ".html"
global COMMANDER_PATH := % A_ScriptDir
if A_Is64bitOS AND FileExist(A_ScriptDir . "\" . "TOTALCMD64.EXE") {
COMMANDER_NAME := "TOTALCMD64.EXE"
} else{
COMMANDER_NAME := "TOTALCMD.EXE"
}
global COMMANDER_EXE := COMMANDER_PATH . "\" . COMMANDER_NAME
EnvSet,COMMANDER_PATH, %COMMANDER_PATH%
EnvSet,COMMANDER_EXE, %COMMANDER_EXE%
;GV_ToolsPath := % GF_GetSysVar("ToolsPath")
GV_TempPath := % GF_GetSysVar("TEMP")
;绿软根目录SoftDir,默认在tc目录的上一层,这里是脚本内的环境变量,所有从ahk中启动的程序都会继承这个变量,
;如果电脑相对固定,则可以考虑在右键菜单中选添加系统的环境变量固定下来
;用EnvUpdate 会导致卡顿
SOFTDIR := % GF_GetSysVar("SoftDir")
if !SOFTDIR
{
SOFTDIR := RegExReplace(A_ScriptDir,"\\[^\\]+\\?$")
EnvSet,SoftDir, % SOFTDIR
}
;默认双击快捷键间隔175微秒
GV_KeyTimer := 175
GV_MouseTimer := 400
GV_KeyClickAction1 :=
GV_KeyClickAction2 :=
GV_KeyClickAction3 :=
;长按的按钮,0为默认不管,1左键2右键3中键
GV_MouseButton := 0
GV_LongClickAction :=
TC_Msg := 1075
CM_OpenDrives := 2122
CM_OpenDesktop := 2121
CM_OpenPrinters := 2126
CM_OpenNetwork := 2125
CM_OpenControls := 2123
CM_OpenRecycled := 2127
CM_CopySrcPathToClip := 2029
CM_CopyFullNamesToClip := 2018
CM_ConfigSaveDirHistory := 582
ScreenShotPath := "C:\"
;Tim中座标位置
Tim_Start_X := 100
Tim_Start_Y := 100
Tim_Bar_Height := 60
;QQ中座标位置
QQ_Start_X := 100
QQ_Start_Y := 30
QQ_Bar_Height := 45
WX_Start_X := 180
WX_Start_Y := 100
WX_Bar_Height := 62
TG_Start_X := 100
TG_Start_Y := 110
TG_Bar_Height := 62
;用ramdisk的时候,有时候不能自动的建立Temp目录
;FileDelete,% GV_TempPath
;FileCreateDir, % GV_TempPath
;run nircmd execmd mkdir "%GV_TempPath%"
;FileCreateDir, % GV_TempPath . "\ChromeCache"
;************** 在光标下方滚轮 ************** {{{1
;Autoexecute code
MinLinesPerNotch := 1
MaxLinesPerNotch := 5
AccelerationThreshold := 100
AccelerationType := "L" ;Change to "P" for parabolic acceleration
StutterThreshold := 10
;************** 在光标下方滚轮开始^ ************** {{{2
;Function definitions
;See above for details on parameters
FocuslessScroll(MinLinesPerNotch, MaxLinesPerNotch, AccelerationThreshold, AccelerationType, StutterThreshold)
{
SetBatchLines, -1 ;Run as fast as possible
CoordMode, Mouse, Screen ;All coords relative to screen
;Stutter filter: Prevent stutter caused by cheap mice by ignoring successive WheelUp/WheelDown events that occur to close together.
If(A_TimeSincePriorHotkey < StutterThreshold) ;Quickest succession time in ms
If(A_PriorHotkey = "WheelUp" Or A_PriorHotkey ="WheelDown")
Return
MouseGetPos, m_x, m_y,, ControlClass2, 2
ControlClass1 := DllCall( "WindowFromPoint", "int64", (m_y << 32) | (m_x & 0xFFFFFFFF), "Ptr") ;32-bit and 64-bit support
lParam := (m_y << 16) | (m_x & 0x0000FFFF)
wParam := (120 << 16) ;Wheel delta is 120, as defined by MicroSoft
;Detect WheelDown event
If(A_ThisHotkey = "WheelDown" Or A_ThisHotkey = "^WheelDown" Or A_ThisHotkey = "+WheelDown" Or A_ThisHotkey = "*WheelDown")
wParam := -wParam ;If scrolling down, invert scroll direction
;Detect modifer keys held down (only Shift and Control work)
If(GetKeyState("Shift","p"))
wParam := wParam | 0x4
If(GetKeyState("Ctrl","p"))
wParam := wParam | 0x8
;Adjust lines per notch according to scrolling speed
Lines := LinesPerNotch(MinLinesPerNotch, MaxLinesPerNotch, AccelerationThreshold, AccelerationType)
If(ControlClass1 != ControlClass2)
{
Loop %Lines%
{
SendMessage, 0x20A, wParam, lParam,, ahk_id %ControlClass1%
SendMessage, 0x20A, wParam, lParam,, ahk_id %ControlClass2%
}
}
Else
{
SendMessage, 0x20A, wParam * Lines, lParam,, ahk_id %ControlClass1%
}
}
;All parameters are the same as the parameters of FocuslessScroll()
;Return value: Returns the number of lines to be scrolled calculated from the current scroll speed.
LinesPerNotch(MinLinesPerNotch, MaxLinesPerNotch, AccelerationThreshold, AccelerationType)
{
T := A_TimeSincePriorHotkey
If((T > AccelerationThreshold) Or (T = -1)) ;T = -1 if this is the first hotkey ever run
{
Lines := MinLinesPerNotch
}
Else
{
If(AccelerationType = "P")
{
A := (MaxLinesPerNotch-MinLinesPerNotch)/(AccelerationThreshold**2)
B := -2 * (MaxLinesPerNotch - MinLinesPerNotch)/AccelerationThreshold
C := MaxLinesPerNotch
Lines := Round(A*(T**2) + B*T + C)
}
Else
{
B := (MinLinesPerNotch-MaxLinesPerNotch)/AccelerationThreshold
C := MaxLinesPerNotch
Lines := Round(B*T + C)
}
}
Return Lines
}
;在任务栏上滚轮调整音量 {{{2
#If MouseIsOver("ahk_class Shell_TrayWnd") or MouseIsOver("ahk_class Shell_SecondaryTrayWnd")
WheelUp::GoSub,Sub_volUp
WheelDown::GoSub,Sub_volDown
;中键静音
MButton::GoSub,Sub_volMute
;启动svv
;~LButton::
;GV_LongClickAction := "GoSub,Sub_sv"
;GV_MouseButton := 1
;GoSub,Sub_ButtonLongPress
;return
#if
Sub_volDown:
SetTimer,SliderOff,2000
SoundSet,-2
Gosub,DisplaySlider
Return
Sub_volUp:
SetTimer,SliderOff,2000
SoundSet,+2
Gosub,DisplaySlider
Return
Sub_volMute:
SetTimer,SliderOff,2000
SoundSet, +1, , mute
SoundGet, master_mute, , mute
if master_mute = Off
Gosub,DisplaySlider
else if master_mute = On
Progress,0,0, ,音量大小
return
SliderOff:
Progress,Off
Return
DisplaySlider:
SoundGet,Volume
Volume:=Round(Volume)
Progress,%Volume%,%Volume%, ,音量大小
Return
Sub_sv:
Run, SndVol.exe
return
#IfWinActive ahk_exe SndVol.exe
RButton::WinClose A
#IfWinActive
Sub_svv:
Run, soundvolumeview.exe
return
#IfWinActive ahk_exe soundvolumeview.exe
MButton::SendInput, ^{6 10}
; 5%
k::SendInput, ^4
j::SendInput, ^3
WheelUp::SendInput, ^4
WheelDown::SendInput, ^3
; 1%
!k::SendInput, ^2
!j::SendInput, ^1
!WheelUp::SendInput, ^2
!WheelDown::SendInput, ^1
; 10%
^k::SendInput, ^4
^j::SendInput, ^3
^WheelUp::SendInput, ^4
^WheelDown::SendInput, ^3
; Toggle mute
m::SendInput, {F9}
Esc::SendInput, !fx
RButton::
GV_MouseTimer := 400
GV_KeyClickAction1 := "Send,{RButton}"
GV_KeyClickAction2 := "Send,!fx"
GoSub,Sub_MouseClick123
return
#IfWinActive
;Win10里面已经不需要光标下滚轮这个功能
#If (GV_ToggleWheelOnCursor=1) and (A_OSVersion in WIN_2003,WIN_XP,WIN_7)
WheelUp::FocuslessScroll(MinLinesPerNotch, MaxLinesPerNotch, AccelerationThreshold, AccelerationType, StutterThreshold)
WheelDown::FocuslessScroll(MinLinesPerNotch, MaxLinesPerNotch, AccelerationThreshold, AccelerationType, StutterThreshold)
^WheelUp::Send,^{WheelUp}
^WheelDown::Send,^{WheelDown}
!WheelUp::Send,!{WheelUp}
!WheelDown::Send,!{WheelDown}
#if
;************** 在光标下方滚轮结束 ************** {{{2
;************** 定时重启脚本部分,别动位置 ************** {{{1
AutoReloadInit:
SetTimer, SelfReload, % GV_ReloadTimer
return
SelfReload:
if (GV_ToggleReload && !GV_GroupBrowserToggleMButtonMode && !GV_GroupBrowserToggleWheelModeLeftRight && !GV_GroupBrowserToggleWheelModeUpDown)
{
;Send,{space up}
Send,{capslock up}
Send,{LWin Up}
Send,{RWin Up}
Send,{Shift Up}
Send,{LShift Up}
Send,{RShift Up}
Send,{Alt Up}
Send,{LAlt Up}
Send,{RAlt Up}
Send,{Control Up}
Send,{LControl Up}
Send,{RControl Up}
Send,{Volume_Down Up}
Send,{Volume_Up Up}
;Send,{Volume_Mute Up}
reload
}
return
ForceSelfReload:
;Send,{space up}
Send,{capslock up}
Send,{LWin Up}
Send,{RWin Up}
Send,{Shift Up}
Send,{LShift Up}
Send,{RShift Up}
Send,{Alt Up}
Send,{LAlt Up}
Send,{RAlt Up}
Send,{Control Up}
Send,{LControl Up}
Send,{RControl Up}
Send,{Volume_Down Up}
Send,{Volume_Up Up}
sleep 100
reload
return
;************** caps+鼠标滚轮调整窗口透明度^ ************** {{{1
;caps+鼠标滚轮调整窗口透明度(设置30-255的透明度,低于30基本上就看不见了,如需要可自行修改)
;~LShift & WheelUp::
CapsLock & WheelUp::
;透明度调整,增加。
WinGet, Transparent, Transparent,A
If (Transparent="")
Transparent=255
Transparent_New:=Transparent+20
If (Transparent_New > 254)
Transparent_New =255
WinSet,Transparent,%Transparent_New%,A
tooltip 原透明度: %Transparent_New% `n新透明度: %Transparent%
SetTimer, RemoveToolTip_transparent_Lwin, 1500
return
CapsLock & WheelDown::
;透明度调整,减少。
WinGet, Transparent, Transparent,A
If (Transparent="")
Transparent=255
Transparent_New:=Transparent-20
If (Transparent_New < 30)
Transparent_New = 30
WinSet,Transparent,%Transparent_New%,A
tooltip 原透明度: %Transparent_New% `n新透明度: %Transparent%
SetTimer, RemoveToolTip_transparent_Lwin, 1500
return
;设置CapsLock 加侧边键 直接恢复透明度到255。没有侧边键的就算了,毕竟滚轮滚一下也快得很
;CapsLock & XButton1::
;WinGet, Transparent, Transparent,A
;WinSet,Transparent,255,A
;tooltip 恢复透明度
;SetTimer, RemoveToolTip_transparent_Lwin, 1500
;return
RemoveToolTip_transparent_Lwin:
tooltip
SetTimer, RemoveToolTip_transparent_Lwin, Off
return
;************caps+鼠标滚轮调整窗口透明度$***********
;************** 按住Caps拖动鼠标^ ************** {{{1
;按住caps加左键拖动窗口
Capslock & LButton::
;Escape & LButton::
CoordMode, Mouse ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY,,, ahk_id %EWD_MouseWin%
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin%
if EWD_WinState = 0 ; Only if the window isn't maximized
SetTimer, EWD_WatchMouse, 10 ; Track the mouse as the user drags it.
return
EWD_WatchMouse:
GetKeyState, EWD_LButtonState, LButton, P
if EWD_LButtonState = U ; Button has been released, so drag is complete.
{
SetTimer, EWD_WatchMouse, off
return
}
;GetKeyState, EWD_EscapeState, Escape, P
;if EWD_EscapeState = D ; Escape has been pressed, so drag is cancelled.
;{
; SetTimer, EWD_WatchMouse, off
; WinMove, ahk_id %EWD_MouseWin%,, %EWD_OriginalPosX%, %EWD_OriginalPosY%
; return
;}
; Otherwise, reposition the window to match the change in mouse coordinates
; caused by the user having dragged the mouse:
CoordMode, Mouse
MouseGetPos, EWD_MouseX, EWD_MouseY
WinGetPos, EWD_WinX, EWD_WinY,,, ahk_id %EWD_MouseWin%
SetWinDelay, -1 ; Makes the below move faster/smoother.
WinMove, ahk_id %EWD_MouseWin%,, EWD_WinX + EWD_MouseX - EWD_MouseStartX, EWD_WinY + EWD_MouseY - EWD_MouseStartY
EWD_MouseStartX := EWD_MouseX ; Update for the next timer-call to this subroutine.
EWD_MouseStartY := EWD_MouseY
return
;按住caps加右键放大和缩小窗口
Capslock & RButton::
;Escape & RButton::
CoordMode, Mouse, Screen ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseStartX, EWD_MouseStartY, EWD_MouseWin
WinGetPos, EWD_OriginalPosX, EWD_OriginalPosY, EWD_WinWidth, EWD_WinHeight, ahk_id %EWD_MouseWin%
EWD_StartPosX := EWD_WinWidth - EWD_MouseStartX
EWD_StartPosY := EWD_WinHeight - EWD_MouseStartY
if ((EWD_MouseStartX - EWD_OriginalPosX)/EWD_WinWidth)<0.5 && ((EWD_MouseStartY - EWD_OriginalPosY)/EWD_WinHeight)<0.5
LeftUpCorner = 1
else
LeftUpCorner = 0
WinGet, EWD_WinState, MinMax, ahk_id %EWD_MouseWin%
if EWD_WinState = 0 ; Only if the window isn't maximized
SetTimer, EWD_ResizeWindow, 10 ; Track the mouse as the user drags it.
Return
EWD_ResizeWindow:
If Not GetKeyState("RButton", "P"){
SetTimer, EWD_ResizeWindow, off
Return
}
CoordMode, Mouse, Screen ; Switch to screen/absolute coordinates.
MouseGetPos, EWD_MouseX, EWD_MouseY
SetWinDelay, -1 ; Makes the below move faster/smoother.
if LeftUpCorner
WinMove, ahk_id %EWD_MouseWin%,, EWD_OriginalPosX-(EWD_MouseStartX-EWD_MouseX), EWD_OriginalPosY-(EWD_MouseStartY-EWD_MouseY), EWD_WinWidth+(EWD_MouseStartX-EWD_MouseX),EWD_WinHeight+(EWD_MouseStartY-EWD_MouseY)
else
WinMove, ahk_id %EWD_MouseWin%,, EWD_OriginalPosX, EWD_OriginalPosY, EWD_StartPosX + EWD_MouseX, EWD_StartPosY + EWD_MouseY
Return
;************** 按住Caps拖动窗口$ **************
;按住Win加左键放大和缩小窗口
Capslock & MButton::GoSub,Sub_MaxRestore
;LWin & LButton::GoSub,Sub_MaxRestore
;Win加右键给了popsel作为启动器,关键是滥用置顶并不好,所以给难受的中键
LWin & MButton::Winset, Alwaysontop, toggle, A
;对于置顶最好用快捷键来的更准确一点
#F1::Winset, Alwaysontop, toggle, A
;从默认Ctrl+W是关闭标签上修改一点成关闭程序。
#w::WinClose A
;按住Win加滚轮来调整音量大小
LWin & WheelUp::GoSub,Sub_volUp
LWin & WheelDown::GoSub,Sub_volDown
;Escape & LButton::WinClose A
;************** 自定义方法^ ************** {{{1
MouseIsOver(WinTitle) {
MouseGetPos,,, Win
return WinExist(WinTitle . " ahk_id " . Win)
}
;fp,全路径文件名 1路径,2全文件名,3仅文件名,4扩展名,5添加64字样
GetFileInfo(fp,act){
;D:\Tools\Office\EverEdit\eeie.exe
;InStr(Haystack, Needle [, CaseSensitive = false, StartingPos = 1, Occurrence = 1]):
;SubStr(String, StartingPos [, Length])
dot := InStr(fp,".",false,0,1)
slash := InStr(fp,"\",false,0,1)
if(act==1)
return % substr(fp,1,slash)
else if(act==2)
return % substr(fp,slash+1)
else {
;当文件名没有后缀名
if(dot==0){
if(act==3)
return % substr(fp,slash+1)
else if(act==4)
return ""
else if(act==5){
if(A_Is64bitOS)
return % fp . "64"
else
return % fp
}
}
else{
if(act==3)
return % substr(fp,slash+1,dot-slash-1)
else if(act==4)
return % substr(fp,dot+1)
else if(act==5){
if(A_Is64bitOS)
return % substr(fp,1,dot-1) . "64" . substr(fp,dot)
else
return % fp
}
}
}
}
AscSend(str){
SetFormat, Integer, H
for k,v in StrSplit(str)
out.="{U+ " Ord(v) "}"
Sendinput % out
}
EzTip(tip,s){
s:=(s>0) ? s*1000 : 2000
ToolTip % tip
sleep % s
ToolTip
}
;适合单行直接调用
CoordWinClick(x,y){
CoordMode, Mouse, Window
click %x%, %y%
}
;适合单行直接调用
CoordWinDbClick(x,y){
CoordMode, Mouse, Window
click %x%, %y%, 2
}
;在调用的过程前面统一加上一句 CoordMode, Mouse, Window 较好,下同
ClickSleep(x,y,s){
click %x%, %y%
Sleep, % 100*s
}
ControlClickSleep(ctl,s){
ControlClick, %ctl%
Sleep, % 100*s
}
MyWinWaitActive(title){
WinWait, %title%,
IfWinNotActive, %title%, , WinActivate, %title%,
WinWaitActive, %title%,
}
GetCursorShape(){ ;获取光标特征码 by nnrxin
VarSetCapacity( PCURSORINFO, 20, 0) ;为鼠标信息 结构 设置出20字节空间
NumPut(20, PCURSORINFO, 0, "UInt") ;*声明出 结构 的大小cbSize = 20字节
DllCall("GetCursorInfo", "Ptr", &PCURSORINFO) ;获取 结构-光标信息
if ( NumGet( PCURSORINFO, 4, "UInt")="0" ) ;当光标隐藏时,直接输出特征码为0
return, 0
VarSetCapacity( ICONINFO, 20, 0) ;创建 结构-图标信息
DllCall("GetIconInfo", "Ptr", NumGet(PCURSORINFO, 8), "Ptr", &ICONINFO) ;获取 结构-图标信息
VarSetCapacity( lpvMaskBits, 128, 0) ;创造 数组-掩图信息(128字节)
DllCall("GetBitmapBits", "Ptr", NumGet( ICONINFO, 12), "UInt", 128, "UInt", &lpvMaskBits) ;读取 数组-掩图信息
loop, 128{ ;掩图码
MaskCode += NumGet( lpvMaskBits, A_Index, "UChar") ;累加拼合
}
if (NumGet( ICONINFO, 16, "UInt")<>"0"){ ;颜色图不为空时(彩色图标时)
VarSetCapacity( lpvColorBits, 4096, 0) ;创造 数组-色图信息(4096字节)
DllCall("GetBitmapBits", "Ptr", NumGet( ICONINFO, 16), "UInt", 4096, "UInt", &lpvColorBits) ;读取 数组-色图信息
loop, 256{ ;色图码
ColorCode += NumGet( lpvColorBits, A_Index*16-3, "UChar") ;累加拼合
}
} else
ColorCode := "0"
DllCall("DeleteObject", "Ptr", NumGet( ICONINFO, 12)) ; *清理掩图
DllCall("DeleteObject", "Ptr", NumGet( ICONINFO, 16)) ; *清理色图
VarSetCapacity( PCURSORINFO, 0) ;清空 结构-光标信息
VarSetCapacity( ICONINFO, 0) ;清空 结构-图标信息
VarSetCapacity( lpvMaskBits, 0) ;清空 数组-掩图
VarSetCapacity( lpvColorBits, 0) ;清空 数组-色图
return, % MaskCode//2 . ColorCode ;输出特征码
}
Sub_MouseClick123:
if winc_presses > 0 ; SetTimer 已经启动, 所以我们记录键击.
{
winc_presses += 1
return
}
; 否则, 这是新开始系列中的首次按下. 把次数设为 1 并启动
; 计时器:
winc_presses = 1
SetTimer, KeyWinC, % GV_MouseTimer ; 在 400 毫秒内等待更多的键击.
return
Sub_KeyClick123:
if winc_presses > 0 ; SetTimer 已经启动, 所以我们记录键击.
{
winc_presses += 1
return
}
; 否则, 这是新开始系列中的首次按下. 把次数设为 1 并启动
; 计时器:
winc_presses = 1
SetTimer, KeyWinC, % GV_KeyTimer ; 在 400 毫秒内等待更多的键击.
return
KeyWinC:
SetTimer, KeyWinC, off
if winc_presses = 1 ; 此键按下了一次.
{
if GV_MouseButton = 0
{
fun_KeyClickAction123(GV_KeyClickAction1)
}
else {
MouseGetPos, x0, y0
if GV_MouseButton = 1
KeyWait, LButton, T0.4
else if GV_MouseButton = 2
KeyWait, RButton, T0.4
else if GV_MouseButton = 3
KeyWait, MButton, T0.4
MouseGetPos, x1, y1
If (ErrorLevel && (x0 = x1 && y0 = y1))
{
fun_KeyClickAction123(GV_LongClickAction)
;重置为0
GV_MouseButton = 0
}
else {
fun_KeyClickAction123(GV_KeyClickAction1)
}
}
}
else if winc_presses = 2 ; 此键按下了两次.
{
fun_KeyClickAction123(GV_KeyClickAction2)
}
else if winc_presses > 2
{
fun_KeyClickAction123(GV_KeyClickAction3)
;MsgBox, Three or more clicks detected.
}
; 不论触发了上面的哪个动作, 都对 count 进行重置
; 为下一个系列的按下做准备:
winc_presses = 0
return
fun_KeyClickAction123(act){
If RegExMatch(act,"i)^(run,)",m) {
run,% substr(act,strlen(m1)+1)
}
else If RegExMatch(act,"i)^(send,)",m) {
Send,% substr(act,strlen(m1)+1)
}
else If RegExMatch(act,"i)^(SendInput,)",m) {
SendInput,% substr(act,strlen(m1)+1)
}
else If RegExMatch(act,"i)^(GoSub,)",m) {
GoSub,% substr(act,strlen(m1)+1)
}
else If RegExMatch(act,"i)^(GoFun,)",m) {
funString := % substr(act,strlen(m1)+1)
funName := substr(funString,1,InStr(funString,"(")-1)
funPara := substr(funString,InStr(funString,"(")+1,InStr(funString,")")-InStr(funString,"(")-1)
RetVal := funName.(funPara)
}
}
Sub_ButtonLongPress:
If ButtonLongPress {
ButtonLongPress += 1
Return
}
ButtonLongPress = 1
;SetTimer, ButtonLongPress, -250
SetTimer, ButtonLongPress, % GV_MouseTimer
Return
ButtonLongPress:
IfEqual, ButtonLongPress, 1
{
MouseGetPos, x0, y0
if GV_MouseButton = 1
KeyWait, LButton, T0.4
else if GV_MouseButton = 2
KeyWait, RButton, T0.4
else if GV_MouseButton = 3
KeyWait, MButton, T0.4
MouseGetPos, x1, y1
If (ErrorLevel && (x0 = x1 && y0 = y1))
fun_KeyClickAction123(GV_LongClickAction)
}
ButtonLongPress = 0
Return
;%A_YYYY%-%A_MM%-%A_DD%-%A_MSec%
;msgbox % fun_GetFormatTime("yyyy-MM-dd-HH-mm-ss")
fun_GetFormatTime(f,t="")
{
;FormatTime, TimeString, 200504, 'Month Name': MMMM`n'Day Name': dddd
;FormatTime, TimeString, ,'Month Name': MMMM`n'Day Name': dddd
FormatTime, TimeString, %t% ,%f%
return %TimeString%
}
GF_GetSysVar(sys_var_name)
{
EnvGet, sv,% sys_var_name
return % sv
}
Sub_ClipAppend:
;SendInput,^{Home}^+{End}^c
Send,^c
ToolTip 已经添加到 %GV_TempPath%\ClipAppend.txt
FileAppend, %ClipBoard%.`n, %GV_TempPath%\ClipAppend.txt
Sleep 1000
ToolTip
return
Sub_MaxRestore:
WinGet, Status_minmax ,MinMax,A
If (Status_minmax=1){
WinRestore A
}
else{
WinMaximize A
}
return
Sub_MaxAllWindows:
WinGet, Window_List, List ; Gather a list of running programs
Loop, %Window_List%
{
wid := Window_List%A_Index%
WinGetTitle, wid_Title, ahk_id %wid%
WinGet, Style, Style, ahk_id %wid%
;(WS_CAPTION 0xC00000| WS_SYSMENU 0x80000| WS_MAXIMIZEBOX 0x10000) | WS_SIZEBOX 0x40000
If (!(Style & 0xC90000) or !(Style & 0x40000) or (Style & WS_DISABLED) or !(wid_Title)) ; skip unimportant windows ; ! wid_Title or
Continue
;MsgBox, % (Style & 0x40000)
WinGet, es, ExStyle, ahk_id %wid%
Parent := Decimal_to_Hex( DllCall( "GetParent", "uint", wid ) )
WinGet, Style_parent, Style, ahk_id %Parent%
Owner := Decimal_to_Hex( DllCall( "GetWindow", "uint", wid , "uint", "4" ) ) ; GW_OWNER = 4
WinGet, Style_Owner, Style, ahk_id %Owner%
If (((es & WS_EX_TOOLWINDOW) and !(Parent)) ; filters out program manager, etc
or ( !(es & WS_EX_APPWINDOW)
and (((Parent) and ((Style_parent & WS_DISABLED) =0)) ; These 2 lines filter out windows that have a parent or owner window that is NOT disabled -
or ((Owner) and ((Style_Owner & WS_DISABLED) =0))))) ; NOTE - some windows result in blank value so must test for zero instead of using NOT operator!
continue
WinGet, Status_minmax ,MinMax,ahk_id %wid%
If (Status_minmax!=1) {
WinMaximize,ahk_id %wid%
}
;MsgBox, 4, , Visiting All Windows`n%a_index% of %Window_List%`n`n%wid_Title%`nContinue?
;IfMsgBox, NO, break
}
return
Sub_WindowNoCaption:
WinGetPos, xTB, yTB,lengthTB,hightTB, ahk_class Shell_TrayWnd
;msgbox %xTB%
;msgbox %yTB%
;msgbox %lengthTB%
;msgbox %hightTB%
bd := 8 ;win8Border = 4
lW := A_ScreenWidth
hW := A_ScreenHeight
if(xTB == 0){ ;左边和上、下面的情况
if(yTB == 0){ ;任务栏在上和左
if(lengthTB == A_ScreenWidth){ ;在上
xW := 0
yW := hightTB
lW := A_ScreenWidth
hW := A_ScreenHeight - hightTB
}
else{ ;在左
xW := lengthTB
yW := 0
lW := A_ScreenWidth - lengthTB
hW := A_ScreenHeight
}
}
else{ ;在下
xW := 0
yW := 0
lW := A_ScreenWidth
hW := A_ScreenHeight - hightTB
}
}
else{ ;在右
xW := 0
yW := 0
lW := A_ScreenWidth - lengthTB
hW := A_ScreenHeight
}
WinSet, Style, ^0xC00000, A
return
Decimal_to_Hex(var)
{
SetFormat, integer, hex
var += 0
SetFormat, integer, d
return var
}
;打开剪贴板中多个链接
OpenClipURLS:
Loop, parse, clipboard, `n, `r ; 在 `r 之前指定 `n, 这样可以同时支持对 Windows 和 Unix 文件的解析.
{
cu := A_LoopField
if(RegExMatch(A_LoopField,"^http")){
sleep 200
run, "%A_LoopField%"
}
else if(RegExMatch(A_LoopField,"(^[a-zA-Z]:\\)|(^file:\/\/\/[a-zA-Z]:\/)")){
sleep 200
run,"%COMMANDER_EXE%" /A /T /O /S /L="%A_LoopField%"
}
}
return
;map tc :tabnew<cr>"+P
;map <F1> :tabnew<CR>
Sub_CopyAllVim:
SendInput,^{Home}^+{End}^c
sleep 500
if not WinExist("ahk_class Vim")
run %A_ScriptDir%\TOOLS\vim\gvim.exe, %A_ScriptDir%\TOOLS\vim
WinActivate
sleep 500
SendInput,{F1}^v
return
Sub_CopyVim:
SendInput,^c
sleep 500