-
Notifications
You must be signed in to change notification settings - Fork 28
/
运行.ahk
1768 lines (1592 loc) · 52.4 KB
/
运行.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
; 在一个脚本已经运行时,如果再次打开它,
; 将跳过对话框,并自动地运行(替换原来打开的脚本)。
#SingleInstance force
#NoTrayIcon
; 探测“隐藏"的窗口
DetectHiddenWindows, On
; 设置脚本的执行速度
SetBatchLines -1
ComObjError(0)
AutoTrim, On
SetWinDelay, 0
; 匹配模式 窗口标题包含有指定文字时符合匹配 。
SetTitleMatchMode 2
; 设置鼠标的坐标模式为相对于整个屏幕的坐标模式
CoordMode, Mouse, Screen
; 开机时脚本启动后等待至15s
While (15000 - A_TickCount) > 0
sleep, 100
; 管理员权限
If(!A_IsAdmin)
{
Loop %0%
params .= " " (InStr(%A_Index%, " ") ? """" %A_Index% """" : %A_Index%)
uacrep := DllCall("shell32\ShellExecute", uint, 0, str, "RunAs", str, A_AhkPath, str, """" A_ScriptFullPath """" params, str, A_WorkingDir, int, 1)
If(uacrep = 42) ; UAC Prompt confirmed, application may Run as admin
{
Tooltip, 成功启用管理员权限
Auto_FirstRun := 1
exitapp
}
Else
MsgBox, 没有启用管理员权限
}
; 退出脚本时,执行ExitSub,关闭自动启动的脚本、恢复窗口等等操作。
OnExit, ExitSub
;========变量读取和设置开始========
global run_iniFile := A_ScriptDir "\settings\setting.ini"
IfNotExist, %run_iniFile%
FileCopy, %A_ScriptDir%\Backups\setting.ini, %run_iniFile%
global visable
if QtTabBar()
qt := 1
IniRead, IniR_Tmp_Str, %run_iniFile%, 功能开关
Gosub, _GetAllKeys
; 在脚本的开头,利用 Reload 变通实现批量 #Include
; 自动生成 AutoIncludeAll.ahk
If Auto_Include
Gosub, _AutoInclude
FileReadLine, AppVersion, %A_ScriptDir%\version.txt, 1
AppVersion := Trim(AppVersion)
AppTitle = 拖拽移动文件到目标文件夹(自动重命名)
FloderMenu_iniFile = %A_ScriptDir%\settings\FloderMenu.ini
SaveDeskIcons_inifile = %A_ScriptDir%\settings\SaveDeskIcons.ini
update_txtFile = %A_ScriptDir%\settings\tmp\CurrentVersion.txt
ScriptManager_Path = %A_ScriptDir%\脚本管理器
global Candy_ProFile_Ini := A_ScriptDir . "\settings\candy\[candy].ini"
SplitPath, Candy_ProFile_Ini, , Candy_Profile_Dir, , Candy_ProFile_Ini_NameNoext
global Windy_Profile_Ini := A_ScriptDir . "\settings\Windy\Windy.ini"
SplitPath, Windy_Profile_Ini, , Windy_Profile_Dir, , Windy_Profile_Ini_NameNoext
global 7PlusMenu_ProFile_Ini := A_ScriptDir . "\settings\7PlusMenu.ini"
;---------Alt+滚轮调节音量随机颜色---------
Random, ColorNum, 0, 6
;BarColor := SubStr("6BD536FFFFFFC7882DFFCD00D962FFFF55554FDCFF", ColorNum*6+1, 6)
BarColor := SubStr("FFFF000CFF0C0C750CD962FFFF55554FDCFF1187FF", ColorNum*6+1, 6)
StringLeft, ColorLeft, BarColor, 2
StringRight, ColorRight, BarColor, 2
BarColor := SubStr(BarColor, 3, 2)
BarColor := ColorRight . BarColor . ColorLeft
; -------------------
; START CONFIGURATION
; -------------------
; The percentage by which to raise or lower the volume each time
vol_Step = 8
; How long to display the volume level bar graphs (in milliseconds)
vol_DisplayTime = 1000
; Transparency of window (0-255)
vol_TransValue = 255
; Bar's background colour
vol_CW = EEEEEE
vol_Width = 200 ; width of bar
vol_Thick = 20 ; thickness of bar
; Bar's screen position
vol_PosX := A_ScreenWidth - vol_Width - 90
vol_PosY := A_ScreenHeight - vol_Thick - 72
; --------------------
; END OF CONFIGURATION
; --------------------
vol_BarOptionsMaster = 1:B1 ZH%vol_Thick% ZX8 ZY4 W%vol_Width% X%vol_PosX% Y%vol_PosY% CW%vol_CW%
;---------Alt+滚轮调节音量随机颜色---------
; 托盘菜单中打开帮助文件和spy时需指定路径,判断托盘图标指定进程名
; 将Autohotkey.exe的完整路径分割,贮存Autohotkey.exe所在目录的路径为"Ahk_Dir"
Splitpath, A_AhkPath, Ahk_FileName, Ahk_Dir
; 检测系统版本
; 版本号>6 Vista7为真(1)
RegRead, Vista7, HKLM, SOFTWARE\Microsoft\Windows NT\CurrentVersion, CurrentVersion
global Vista7 := (Vista7 >= 6)
;---------水平垂直最大化---------
VarSetCapacity(work_area, 16)
DllCall("SystemParametersInfo"
, "uint", 0x30 ; SPI_GETWORKAREA
, "uint", 0
, "uint", &work_area ; 结构左0 上4 右8 下12 NumGet(work_area, 8)
, "uint", 0 )
; 获取工作区域宽
work_area_w := NumGet(work_area, 8, "int") - NumGet(work_area, 0, "int")
; 获取工作区域高, 不计算任务栏高度
work_area_h := NumGet(work_area, 12, "int") - NumGet(work_area, 4, "int")
;----------------------------------水平垂直最大化----------------------------
x_x2 := work_area_w - 634
y_y2 := work_area_h - 108
; 最近关闭的资源管理器窗口
global CloseWindowList_Arr := []
global ClosetextfileList_Arr := []
global folder_Arr := []
global textfile_Arr := []
IniRead, IniR_Tmp_Str, %run_iniFile%, CloseWindowList
CloseWindowList_Arr := StrSplit(IniR_Tmp_Str, "`n", , 16)
ClosetextfileList_Arr.RemoveAt(16)
Array_Sort(CloseWindowList_Arr)
IniRead, IniR_Tmp_Str, %run_iniFile%, ClosetextfileList
ClosetextfileList_Arr := StrSplit(IniR_Tmp_Str, "`n")
Array_Sort(ClosetextfileList_Arr)
; Candy,Windy
global szMenuIdx := {} ; 菜单用1
global szMenuContent := {} ; 菜单用2
global szMenuWhichFile := {} ; 菜单用3
;=========变量设置结束=========
;=========读取配置文件开始=========
IniRead, stableProgram, %run_iniFile%, 固定的程序, stableProgram
IniRead, historyData, %run_iniFile%, 固定的程序, historyData
IniRead, 询问, %run_iniFile%, 截图, 询问
IniRead, filetp, %run_iniFile%, 截图, filetp
IniRead, screenshot_path, %run_iniFile%, 截图, 截图保存目录
IniRead, TargetFolder, %run_iniFile%, 路径设置, TargetFolder
IniRead, foo_components_path, %run_iniFile%, 路径设置, foo_components_path
if ClipPlugin_git
IniRead, Ahk_Help_Html_Path, %run_iniFile%, 路径设置, Ahk_Help_Html_Path
if !FileExist(screenshot_path)
FileCreateDir % screenshot_path
IniRead, IniR_Tmp_Str, %run_iniFile%, 缩为标题栏
Gosub, _GetAllKeys
IniRead, IniR_Tmp_Str, %run_iniFile%, 自动显示隐藏窗口
Gosub, _GetAllKeys
IniRead, IniR_Tmp_Str, %run_iniFile%, 常规
Gosub, _GetAllKeys
IniRead, IniR_Tmp_Str, %run_iniFile%, 功能模式选择
Gosub, _GetAllKeys
IniRead, IniR_Tmp_Str, %run_iniFile%, 自动激活
Gosub, _GetAllKeys
IniRead, IniR_Tmp_Str, %run_iniFile%, 时间
Gosub, _GetAllKeys
; 读取自定义的程序
IniRead, IniR_Tmp_Str, %run_iniFile%, otherProgram
Gosub, _GetAllKeys
If TargetFolder
{
IfnotExist, %TargetFolder%
{
TargetFolder =
IniWrite, %TargetFolder%, %run_iniFile%, 路径设置, TargetFolder
}
}
IniRead, LastClosewindow, %run_iniFile%, 路径设置, LastClosewindow
If LastClosewindow
{
IfnotExist, %LastClosewindow%
{
LastClosewindow=
IniWrite, %LastClosewindow%, %run_iniFile%, 路径设置, LastClosewindow
}
}
;----------窗口缩略图----------
If Auto_MiniMizeOn
{
IniRead, IniR_Tmp_Str, %run_iniFile%, 窗口缩略图
Gosub, _GetAllKeys
MiniMizeNum = 50
ffw := fw-5 ; 缩略图窗口里的图片宽
fx2 := A_ScreenWidth - fw
fy2 := A_ScreenHeight - fh - 35
If shuipingxia
fy := fy2 ; 水平排列时定义Y值
If shuzhiyou
fx := fx2 ; 竖直在右边排列时定义X值
iconx := fw - 48
icony := fh - 48
}
;----------窗口缩略图----------
IniRead, IniR_Tmp_Str, %run_iniFile%, FastFolders
Gosub, _GetAllKeys
IniRead IniR_Tmp_Str, %run_iniFile%, AudioPlayer
loop, parse, IniR_Tmp_Str, `n
{
Tmp_Key := RegExReplace(A_LoopField, "=.*?$")
Tmp_Val := RegExReplace(A_LoopField, "^.*?=")
%Tmp_key% = %Tmp_Val%
if FileExist(%Tmp_key%)
menu, audioplayer, add, %Tmp_key%, DPlayer
}
Tmp_Key := Tmp_Val := IniR_Tmp_Str := ""
;=========读取配置文件结束=========
;=========托盘菜单绘制=========
;----------创建AHK脚本管理器的托盘菜单----------
Menu scripts_unopen, Add, 启动脚本, nul
Menu scripts_unopen, ToggleEnable, 启动脚本
Menu scripts_unopen, Default, 启动脚本
Menu scripts_unopen, Add
Menu scripts_unclose, Add, 关闭脚本, nul
Menu scripts_unclose, ToggleEnable, 关闭脚本
Menu scripts_unclose, Default, 关闭脚本
Menu scripts_unclose, Add
Menu scripts_edit, Add, 编辑脚本, nul
Menu scripts_edit, ToggleEnable, 编辑脚本
Menu scripts_edit, Default, 编辑脚本
Menu scripts_edit, Add
Menu scripts_reload, Add, 重载脚本, nul
Menu scripts_reload, ToggleEnable, 重载脚本
Menu scripts_reload, Default, 重载脚本
Menu scripts_reload, Add
; AHK脚本管理器初始计数值
scriptCount = 0
; 遍历"脚本管理器"目录下所有ahk文件
Loop, %ScriptManager_Path%\*.ahk
{
StringRePlace menuName, A_LoopFileName, .ahk
scriptCount += 1
scripts%scriptCount%0 := A_LoopFileName
IfWinExist %A_LoopFileName% - AutoHotkey ; 已经打开
{
Menu, scripts_unclose, add, %menuName%, tsk_close
scripts%scriptCount%1 = 1
}
Else
{
Menu, scripts_unopen, add, %menuName%, tsk_open
scripts%scriptCount%1 = 0
}
Menu, scripts_edit, add, %menuName%, tsk_edit
Menu, scripts_reload, add, %menuName%, tsk_reload
}
; 打开"脚本管理器"目录中的子脚本, 以"!"开头的脚本不会自动打开.
GoSub tsk_openAll
; 测试启动时间
;ElapsedTime := A_TickCount - StartTime
;msgbox % ElapsedTime
;----------托盘菜单----------
; 菜单出错不提示,影响脚本中所有菜单,例如candy提取不到图标不会报错
Menu, Tray, UseErrorLevel
Menu, Tray, Icon, %A_ScriptDir%\pic\run.ico
Menu, Tray, add, 打开(&O), TM_Open
Menu, Tray, add, 帮助(&H), TM_Help
Menu, Tray, add, &Windows Spy, TM_Spy
Menu, Tray, Add
Menu, Tray, Add, Ahk 脚本管理器, nul
Menu, Tray, disable, Ahk 脚本管理器
Menu, Tray, Add
Menu, Tray, Add, 启动所有脚本(&A)`t, tsk_openAll
Menu, Tray, Add, 启动脚本(&Q)`t, :scripts_unopen
Menu, Tray, Add, 关闭所有脚本(&L)`t, tsk_closeAll
Menu, Tray, Add, 关闭脚本(&C)`t, :scripts_unclose
Menu, Tray, Add
Menu, Tray, Add, 编辑脚本(&I)`t, :scripts_edit
Menu, Tray, Add, 重载脚本(&D)`t, :scripts_reload
Menu, Tray, Add
Menu, Tray, Add, 运行 - Ahk, nul
Menu, Tray, disable, 运行 - Ahk
Menu, Tray, Add
Menu, Tray, Add, 重启脚本(&R)`tCtrl+R, 重启脚本
Menu, Tray, Add, 编辑脚本(&E), 编辑脚本
Menu, Tray, Add
Menu, Tray, add, 挂起所有热键(&S)`tAlt+Pause, 挂起所有热键
Menu, Tray, add, 暂停脚本(&P)`tPause, 暂停脚本
Menu, Tray, Add, 选项(&T)`tCtrl+P, 选项
Menu, Tray, Add, 退出(&X)`t, TM_Exit
Menu, Tray, Add
Menu, Tray, Add, 显示/隐藏`tWin+X, TM_show
Menu, Tray, Default, 显示/隐藏`tWin+X
Menu, Tray, Add
Menu, Tray, NoStandard
Menu, Tray, Click, 1
Menu, Tray, Tip, 运行 - Ahk(For Win_7)`n众多实用Ahk脚本的合集。
;----------托盘菜单----------
;=========托盘菜单绘制=========
;=========主界面的"绘制"=========
ComboBoxShowItems := stableProgram . historyData
;master_mute:=VA_GetMute()
SoundGet, master_mute, , mute
If(master_mute = "on")
; color = red
volimage = %A_ScriptDir%\pic\m_vol.ico
Else
; color = green
volimage = %A_ScriptDir%\pic\vol.ico
menu, audioplayer, Check, %DefaultPlayer%
Process, Exist, %DefaultPlayer%.exe
If ErrorLevel = 0
Image = %A_ScriptDir%\pic\MusicPlayer\%DefaultPlayer%.bmp
Else
Image = %A_ScriptDir%\pic\MusicPlayer\h_%DefaultPlayer%.bmp
; 图形界面的"绘制"
; 窗口 +无最小化按钮(任务栏无按钮)
Gui, +HwndHGUI +ToolWindow
Gui, Add, Text, x1 y10 w90 h20 +Center, 目标/运行:
Gui, Add, ComBoBox, x90 y10 w330 h300 +Hwndh_MG_ComBoBox vDir, % ComBoBoxShowItems
ControlGet, h_MG_Edit, hWnd, , Edit1, ahk_id %HGUI%
DllCall("Shlwapi.dll\SHAutoComplete", "Ptr", h_MG_Edit, "UInt", 0x1|0x10000000) ; 只对编辑控件有效
global h_MG_ComBoBox
global objListIDs:= Object()
global del_ico := 0 ; 0= text "X", 1= icon
global single_ico := 0
fn := Func("List_Func").Bind(h_MG_ComBoBox)
GuiControl, +g, % h_MG_ComBoBox, % fn
Gui, Add, Button, x425 y10 gMG_selectfile, &.
Gui, Add, Button, x445 y10 gMG_selectfolder, 选择(&S)
Gui, Add, Button, x500 y10 default gMG_openbutton, 打开(&O)
Gui, Add, Button, x555 y10 gMG_about, 关于(&A)
Gui, Add, Button, x445 y35 gMG_addfavorites, 加入收藏
Gui, Add, Button, x515 y35 gMG_showfavorites, >
Gui, Add, Button, x555 y35 gMG_liebiao, 列表(&L)
Gui, Add, Picture, x90 y35 w16 h16 gMG_OpenAudioPlayer vpicture, %image%
AddGraphicButton(1, "x108", "y32", "h21", "w40", "GB1", A_ScriptDir . "\pic\MusicControl\prev.bmp", A_ScriptDir . "\pic\MusicControl\h_prev.bmp" , A_ScriptDir . "\pic\MusicControl\d_prev.bmp")
AddGraphicButton(1, "x147", "y32", "h21", "w40", "GB2", A_ScriptDir . "\pic\MusicControl\pause.bmp", A_ScriptDir . "\pic\MusicControl\h_pause.bmp" , A_ScriptDir . "\pic\MusicControl\d_pause.bmp")
AddGraphicButton(1, "x186", "y32", "h21", "w40", "GB3", A_ScriptDir . "\pic\MusicControl\next.bmp", A_ScriptDir . "\pic\MusicControl\h_next.bmp" , A_ScriptDir . "\pic\MusicControl\d_next.bmp")
AddGraphicButton(1, "x225", "y32", "h21", "w40", "GB4", A_ScriptDir . "\pic\MusicControl\close.bmp", A_ScriptDir . "\pic\MusicControl\h_close.bmp" , A_ScriptDir . "\pic\MusicControl\d_close.bmp")
Gui, Add, Picture, x285 y35 w16 h16 gMG_mute vvol, %volimage%
Gui, Add, Slider, x300 y35 w100 h20 vVSlider Range0-100 gMG_SetVolume
Gui, Add, Text, x10 y30 cblue, 光驱
Gui, Add, Text, x10 y45 cblue, USB
Gui, Add, Text, x40 y30 cgreen vopenCD gMG_OpenCD, 开
Gui, Add, Text, x40 y45 cgreen gMG_弹出U盘, 弹出
Gui, Add, Text, x60 y30 cgreen gMG_OpenCD, 关
Gui, Add, Text, x10 y64 cgreen gMG_changyong, 常用
Gui, Add, Text, x100 y64 cgreen gMG_Desktoplnk, 桌面
Gui, Add, Text, x200 y64 cgreen vfhc gMG_foo_httpcontrol_click, Foo_HttpControl
Gui, Add, Text, x340 y64 cgreen gMG_IEfavorites, IE收藏夹
;----------音量----------
SoundGet, vol_Master
;vol_Master := VA_GetMasterVolume()
;RSound := Round(vol_Master)
Guicontrol, , VSlider, %vol_Master%
Process, Exist, %DefaultPlayer%.exe
If ErrorLevel = 0
GuiControl, Disable, fhc
Else
{
If (DefaultPlayer="Foobar2000")
{
If WinExist("foo_httpcontrol")
GuiControl, Enable, fhc
}
}
Menu, addf, Add, 开机启动, runwithsys
Menu, addf, Add, 智能浏览器, smartchooserbrowser
Menu, addf, Add, 自动激活窗口(临时), _TrayEvent
Menu, addf, Add, 启动时记忆桌面图标, AutoSaveDeskIcons
Menu, addf, Add, 记忆桌面图标, SaveDesktopIconsPositions
Menu, addf, Add, 恢复桌面图标, RestoreDesktopIconsPositions
if Auto_DisplayMainWindow
{
Gui, Show, x%x_x% y%y_y% w624 h78, %AppTitle% - %TargetFolder%
visable = 1
}
else
{
Gui, Show, hide x%x_x% y%y_y% w624 h78, %AppTitle% - %TargetFolder%
visable = 0
}
;=========图形界面的"绘制"=========
;=========图形界面的"绘制"2=========
If Auto_runwithsys
{
Menu, addf, Check, 开机启动
}
Else
{
Menu, addf, UnCheck, 开机启动
}
If Auto_smartchooserbrowser
{
Menu, addf, Check, 智能浏览器
writeahkurl()
}
Else
{
Menu, addf, UnCheck, 智能浏览器
}
If (Auto_SaveDeskIcons=1)
{
Menu, addf, Check, 启动时记忆桌面图标
Timer_SDIP := 1
SetTimer, SaveDesktopIconsPositions, 30000
Menu, addf, Disable, 恢复桌面图标
}
Else
{
Menu, addf, UnCheck, 启动时记忆桌面图标
IfNotExist, %SaveDeskIcons_inifile%
Menu, addf, Disable, 恢复桌面图标
}
; 检测鼠标,图片按钮的鼠标效果
OnMessage(0x200, "MouseMove")
OnMessage(0x201, "MouseLdown")
OnMessage(0x202, "MouseLUp")
;OnMessage(0x202, "MouseLeave")
;OnMessage(0x2A3, "MouseLeave")
; 检测主程序窗口右键点击弹出菜单
OnMessage(0x205, "RBUTTONUP")
; 监视U盘插入
OnMessage(0x0219, "WM_DEVICECHANGE")
; 监视ShellExtension.dll传递的消息
if Auto_7plusMenu
{
OnMessage(55555, "TriggerFromContextMenu")
DllCall("ChangeWindowMessageFilter", "UInt", 55555, "UInt", 1)
}
if Auto_tsk_UpdateMenu
OnMessage(0x404, "AHK_NOTIFYICON")
;鼠标点击,原窗口缩略图拖拽移动的代码现已不用
;OnMessage(0x201, "WM_LBUTTONDOWN")
; 拖拽文件窗口执行函数
GuiDropFiles.config(HGUI, "GuiDropFiles_Begin", "GuiDropFiles_End")
; 拖拽到 ComboBox 或 Edit1 控件上时不复制文件
;=========图形界面的"绘制"2=========
;----------不显示托盘图标则重启脚本----------
if Auto_Trayicon && WinExist("ahk_class Shell_TrayWnd")
{
Menu, Tray, Icon
Script_pid := DllCall("GetCurrentProcessId")
Tray_Icons := {}
Tray_Icons := TrayIcon_GetInfo(Ahk_FileName)
for index, Icon in Tray_Icons
{
trayicons_pid .= Icon.Pid ","
}
If trayicons_pid not contains %Script_pid%
{
Menu, Tray, NoIcon
sleep, 300
Menu, Tray, Icon
Tray_Icons := {}
trayicons_pid := ""
Tray_Icons := TrayIcon_GetInfo(Ahk_FileName)
for index, Icon in Tray_Icons
{
trayicons_pid .= Icon.Pid ","
}
}
If trayicons_pid not contains %Script_pid%
{
if Auto_Trayicon_showmsgbox
{
msgbox, 4, 错误, 未检测到脚本的托盘图标,点"是"重启脚本,点"否"继续运行脚本。`n默认(超时)自动重启脚本。,6
IfMsgBox Yes
Auto_reload = 1
else IfMsgBox timeout
Auto_reload = 1
}
else
Auto_reload = 1
连续重启次数 := CF_IniRead(run_iniFile, "时间", "连续重启次数", 0)
if 连续重启次数 > 5
{
IniWrite, 0, % run_iniFile, 时间, 连续重启次数
IniWrite, 0, % run_iniFile, 功能开关, Auto_Trayicon
Msgbox 脚本多次运行都不能检测到托盘图标,脚本下次启动将不再检测托盘图标。
}
else
{
连续重启次数 += 1
IniWrite, % 连续重启次数, % run_iniFile, 时间, 连续重启次数
}
if(Auto_reload = 1)
{
sleep, 2000
Reload
Return
}
}
}
if Auto_FuncsIcon
{
if (FuncsIcon_Num = 2)
{
IniRead, IniR_Tmp_Str, %run_iniFile%, 101
Gosub, _GetAllKeys
TrayIcon_Add(hGui, "OnTrayIcon", Ti_101_icon, Ti_101_tooltip)
IniRead, IniR_Tmp_Str, %run_iniFile%, 102
Gosub, _GetAllKeys
TrayIcon_Add(hGui, "OnTrayIcon", Ti_102_icon, Ti_102_tooltip)
}
else
{
IniRead, IniR_Tmp_Str, %run_iniFile%, 101
Gosub, _GetAllKeys
TrayIcon_Add(hGui, "OnTrayIcon", Ti_101_icon, Ti_101_tooltip)
}
IniR_Tmp_Str := ""
}
;----------不显示托盘图标则重启脚本----------
;=========窗口分组=========
; 分组 ccc: 应用于定位文件,复制路径,智能重命名等
; 分组 Prew_Group: 空格预览, Md5, 记事本打开(F6), 复制路径
; 分组 ExplorerGroup: 中键新窗口打开文件夹, SetFocusToFileView(), IsRenaming()
; 分组 DesktopGroup: InFileList(), IsRenaming()
; 分组 DesktopTaskbarGroup: 窗口缩略图
; 分组 GameWindows: Alt+鼠标移动窗口
IniRead IniR_Tmp_Str, %run_iniFile%, 分组
loop, parse, IniR_Tmp_Str, `n
{
Tmp_Key := RegExReplace(A_LoopField, "=.*?$")
Tmp_Val := RegExReplace(A_LoopField, "^.*?=")
Tmp_Array := StrSplit(Tmp_Val, ";")
for k, v in Tmp_Array
GroupAdd, %Tmp_Key%, ahk_class %v%
}
IniR_Tmp_Str := Tmp_Array := Tmp_Key := Tmp_Val := ""
; 分组 AppMainWindow: 主界面网址补齐、runhistory 因为 #ifwinactive 后不能接变量
GroupAdd, AppMainWindow, %AppTitle%
;=========窗口分组=========
;=========功能加载开始=========
;----------Folder Menu----------
f_Icons = %A_ScriptDir%\pic\foldermenu.ico
IfNotExist, %FloderMenu_iniFile% ; If config file doesn't exist
{
f_ErrorMsg = %f_ErrorMsg% 配置文件不存在.`n使用默认配置文件.`n
FileCopy, %A_ScriptDir%\Backups\FloderMenu.Ini, %FloderMenu_iniFile%
}
f_ReadConfig()
f_SetConfig()
gui_hh = 0
gui_ww = 0
;----------Folder Menu----------
;----------计算文件MD5模式选择----------
If md5type=1
hModule_Md5 := DllCall("LoadLibrary", "str", A_ScriptDir "\Dll\MD5Lib.dll")
;----------计算文件MD5模式选择----------
;----------7plus右键菜单----------
if Auto_7plusMenu
{
FileCreateDir %A_Temp%\7plus
FileDelete, %A_Temp%\7plus\hwnd.txt
FileAppend, %hGui%, %A_Temp%\7plus\hwnd.txt
}
;----------7plus右键菜单----------
;----------监视窗口创建关闭消息:7plus右键菜单之重新打开关闭的窗口 Windo菜单----------
if Auto_LogClosewindows
{
DllCall("RegisterShellHookWindow", "uint", hGui)
OnMessage(DllCall("RegisterWindowMessageW", "str", "SHELLHOOK"), "ShellWM")
}
;----------监视窗口创建关闭消息:7plus右键菜单之重新打开关闭的窗口 Windo菜单----------
;----------地址栏等ClassNN:edit1添加“粘贴并打开”的右键菜单----------
If Auto_PasteAndOpen
{
hMenu:=
hwndNow:=
; constants
MFS_ENABLED = 0
MFS_CHECKED = 8
MFS_DEFAULT = 0x1000
MFS_DISABLED = 2
MFS_GRAYED = 1
MFS_HILITE = 0x80
; 监控右键菜单,并添加“粘贴并打开”菜单项目
; 右键 粘贴并打开
HookProcAdr := RegisterCallback("HookProcMenu", "F")
hWinEventHook := SetWinEventHook(0x4, 0x4, 0, HookProcAdr, 0, 0, 0) ;0x4 EVENT_SYSTEM_MENUSTART
}
;----------地址栏等ClassNN:edit1添加“粘贴并打开”的右键菜单----------
;----------监视关机对话框的选择----------
; 拦截关机
If Auto_ShutdownMonitor
{
ShutdownBlock := true
; HKEY_CURRENT_USER, Control Panel\Desktop, AutoEndTasks, 0
; AutoEndTasks 值为 1, 表示关机时自动结束任务
; AutoEndTasks 值为 0, Vista+ 关机时提示是否结束进程
RegWrite, REG_SZ, HKEY_CURRENT_USER, Control Panel\Desktop, AutoEndTasks, 0
; 调用阻止系统关机的API
Tmp_Val := DllCall("User32.dll\ShutdownBlockReasonCreate", "uint", hGui, "wstr", A_ScriptFullPath " 正在运行, 是否确定关机?")
if !Tmp_Val
CF_ToolTip("ShutdownBlockReasonCreate 创建失败!错误码: " A_LastError, 3000)
; 关机时第一个响应,若要使脚本成为最后一个要终止的进程,将 "0x4FF" 改为 "0x0FF".
Tmp_Val := DllCall("kernel32.dll\SetProcessShutdownParameters", UInt, 0x4FF, UInt, 0)
if !Tmp_Val
CF_ToolTip("SetProcessShutdownParameters 失败!", 3000)
; 监视关机对话框的选择
if !Auto_LogClosewindows
{
HookProcAdr2 := RegisterCallback("HookProc", "F")
hWinEventHook2 := SetWinEventHook(0x1, 0x17, 0, HookProcAdr2, 0, 0, 0)
if !hWinEventHook2
CF_ToolTip("注册监视关机失败", 3000)
}
OnMessage(0x11, "WM_QUERYENDSESSION")
;OnMessage(0x16, "WM_ENDSESSION")
}
;----------监视关机对话框的选择----------
; 运行条目添加删除图标
Gosub, Combo_WinEvent
;----------整点报时功能----------
If baoshionoff ; 整点报时
{
If baoshilx
SetTimer, JA_VoiceCheckTime, 1000
Else
SetTimer, JA_JowCheckTime, 1000
}
If renwu ; 定时任务
SetTimer, renwu, 30000
If renwu2 ; 闹钟
SetTimer, renwu2, 30000
;----------整点报时功能----------
Loop, %A_ScriptDir%\Script\计时器\*.ahk
{
setnum := 0
if !instr(A_LoopFileName, "!")
{
SplitPath, A_LoopFilePath,,,, OutNameNoExt
if Islabel(OutNameNoExt)
SetTimer, % OutNameNoExt, 60000
}
}
;----------鼠标提示(半成品)----------
If Auto_mousetip
SetTimer, aaa, 2000
;----------鼠标提示----------
; 每5秒检测foobar2000是否运行,显示不同的图标,检测系统音量,更改音量条
settimer, 检测, 2000
if !visable ; 主窗口不可见时, 停止检测播放器
{
settimer, 检测, off
OnMessage(0x200, "MouseMove", 0)
OnMessage(0x201, "MouseLdown", 0)
OnMessage(0x202, "MouseLUp", 0)
}
;----------开启鼠标自动激活功能----------
If(Auto_Raise=1)
{
Hotkey, ~RButton, , P1
hovering_off := 0
SetTimer, hovercheck, 100
}
; 当某些窗口存在时,鼠标悬停功能直接返回
Loop, parse, DisHover, `,
GroupAdd, ExistDisableHover, ahk_class %A_LoopField%
; 当某些窗口激活时,鼠标悬停功能直接返回
Loop, parse, ActDisHover, `,
GroupAdd, ActiveDisableHover, ahk_class %A_LoopField%
;----------开启鼠标自动激活功能----------
;----------内存优化----------
AppList := "QQ.exe|chrome.exe|foobar2000.exe"
SetTimer, FreeAppMem, 300000
;----------内存优化----------
;----------Pin2Desk----------
Gosub, cSigleMenu
;----------Pin2Desk----------
;=========功能加载结束=========
;=========热键设置=========
Hotkey, IfWinActive ; 容错
IniRead, hotkeycontent, %run_iniFile%, 快捷键
hotkeycontent := "[快捷键]" . "`n" . hotkeycontent
myhotkey := IniObj(hotkeycontent, OrderedArray()).快捷键
for k, v in myhotkey
{
IfInString, k, 前缀_
continue
Else IfInString, k, 特定窗口_
Hotkey, IfWinActive, %v%
Else IfInString, k, 排除窗口_
Hotkey, IfWinNotActive, %v%
Else If (v && !InStr(v, "@"))
{
if islabel(k)
hotkey, %v%, %k% ;,UseErrorLevel
}
}
Hotkey, IfWinActive
Hotkey, IfWinNotActive
If ErrorLevel
TrayTip, 发现错误, 执行快捷键时发生错误,请检查配置快捷键相关部分, , 3
If !Auto_MiniMizeOn
{
Hotkey, IfWinNotActive, ahk_group DesktopTaskbarGroup
Hotkey, % myhotkey.窗口缩略图, Off
Hotkey, IfWinNotActive
}
IniRead, hotkeycontent, %run_iniFile%, Plugins
hotkeycontent := "[Plugins]" . "`n" . hotkeycontent
Pluginshotkey := IniObj(hotkeycontent, OrderedArray()).Plugins
for k, v in Pluginshotkey
If v
hotkey, %v%, Plugins_Run ;,UseErrorLevel
FileGetTime, transT, %A_ScriptDir%\settings\translist.ini
translist := IniObj(A_ScriptDir "\settings\translist.ini").翻译
;;;;;;;;;; 剪贴板 ;;;;;;;;;;;;
; 复制时
; 复制1→复制2→复制3→复制1
; 粘贴时
; 1→3→2→1
; 2→1→3→2
; 3→2→1→3
if Auto_Clip
{
ClipNOK := clipkey_repeat := clipid := clipmonitor := 0
writecliphistory := 1
Array_Cliphistory := []
st := A_TickCount
SetTimer, shijianCheck, 50
if Auto_Cliphistory
{
global DB := new SQLiteDB
if !DB
Auto_Cliphistory := 0
else
{
global DBPATH := A_ScriptDir . "\Settings\cliphistory.db"
global PREV_FILE := A_ScriptDir . "\Settings\tmp\prev.html"
STORE := {}
if (!FileExist(DBPATH))
isnewdb := 1
else
isnewdb := 0
if (!DB.OpenDB(DBPATH))
MsgBox, 16, SQLite错误, % "消息:`t" . DB.ErrorMsg . "`n代码:`t" . DB.ErrorCode
sleep, 300
if (isnewdb == 1)
migrateHistory()
}
}
}
else
hotkey, $^V, off
;;;;;;;;;; 剪贴板 ;;;;;;;;;;;;
; 快捷键打开C,D,E,F盘(循环次数为系统盘符数)...
if islabel("ExploreDrive") && !InStr(myhotkey.前缀_快速打开磁盘, "@")
{
DriveGet, Tmp_Str, List
Loop % Strlen(Tmp_Str)
HotKey % myhotkey.前缀_快速打开磁盘 Chr(A_Index+66), ExploreDrive
}
if !InStr(myhotkey.前缀_小键盘移动窗口, "@") || !InStr(myhotkey.前缀_小键盘移动前一个窗口, "@")
{
;----------Winpad----------
WindowPadInit:
; Exclusion examples:
GroupAdd, GatherExclude, ahk_class SideBar_AppBarWindow
; These two come in pairs for the Vista sidebar gadgets:
GroupAdd, GatherExclude, ahk_class SideBar_HTMLHostWindow ; gadget content
GroupAdd, GatherExclude, ahk_class BasicWindow ; gadget shadow/outline
GroupAdd, GatherExclude, ahk_class Warcraft III
; Win+Numpad = Move active window
Prefix_Active := myhotkey.前缀_小键盘移动窗口
; Alt+Win+Numpad = Move previously active window
Prefix_Other := myhotkey.前缀_小键盘移动前一个窗口
; Note: Shift (+) should not be used, as +Numpad is hooked by the OS
; to do left/right/up/down/etc. (reverse Numlock) -- at least on Vista.
; Numlock 亮时 Shift+Numpad8 等同于 Shift+Up
; Numlock 灯不亮时,小键盘数字能控制上下左右,滚轮
/*
; 移除EasyKey
EasyKey = Insert ; Insert is near Numpad on my keyboard...
; 移除EasyKey
*/
; Note: Prefix_Other must not be a sub-string of Prefix_Active.
; (If you want it to be, first edit the line "If (InStr(A_ThisHotkey, Prefix_Other))")
; Width and Height Factors for Win+Numpad5 (center key.)
CenterWidthFactor = 1.0
CenterHeightFactor = 1.0
Hotkey, IfWinActive ; in case this is included in another script...
; Win+ numpad 1-9 Alt+Win+Numpad 1-9 移动改变窗口位置大小
Loop, 9
{ ; Register hotkeys.
Hotkey, %Prefix_Active%Numpad%A_Index%, DoMoveWindowInDirection
Hotkey, %Prefix_Other%Numpad%A_Index%, DoMoveWindowInDirection
; OPTIONAL
/*
; 移除EasyKey
If EasyKey
Hotkey, %EasyKey% & Numpad%A_Index%, DoMoveWindowInDirection
; 移除EasyKey
*/
}
; Win+ numpad 0 最大化窗口
Hotkey, %Prefix_Active%Numpad0, DoMaximizeToggle
Hotkey, %Prefix_Other%Numpad0, DoMaximizeToggle
;NumpadDot "."
Hotkey, %Prefix_Active%NumpadDot, MoveWindowToNextScreen
Hotkey, %Prefix_Other%NumpadDot, MoveWindowToNextScreen
;NumpadDiv "/" NumpadMult "*"
Hotkey, %Prefix_Active%NumpadDiv, GatherWindowsLeft
Hotkey, %Prefix_Active%NumpadMult, GatherWindowsRight
/*
;移除EasyKey
If (EasyKey) {
Hotkey, %EasyKey% & Numpad0, DoMaximizeToggle
Hotkey, %EasyKey% & NumpadDot, MoveWindowToNextScreen
Hotkey, %EasyKey% & NumpadDiv, GatherWindowsLeft
Hotkey, %EasyKey% & NumpadMult, GatherWindowsRight
Hotkey, *%EasyKey%, SendEasyKey ; let EasyKey's original function work (on release)
}
;移除EasyKey
*/
;----------Winpad----------
}
if !InStr(myhotkey.前缀_数字虚拟桌面切换, "@") || !InStr(myhotkey.前缀_功能键发送到虚拟桌面, "@")
;----------虚拟桌面----------
Loop, 4
{
Hotkey, % myhotkey.前缀_数字虚拟桌面切换 Chr(A_Index+48), ToggleVirtualDesktop
Hotkey, % myhotkey.前缀_功能键发送到虚拟桌面 "F" A_Index, SendActiveToDesktop
}
;----------虚拟桌面----------
;=========热键设置=========
;---------鼠标增强和空格预览的热键的开启-----------
if !Auto_mouseclick && !Auto_Raise
hotkey, ~LButton, off
if !Auto_midmouse
hotkey, $MButton, off
if !Auto_Spacepreview
{
Hotkey, ifWinActive, ahk_Group ccc
hotkey, $Space, off
Hotkey, ifWinActive
}
;---------鼠标增强和空格预览的热键的开启-----------
;----------网页控制电脑----------
; 电脑访问地址 127.0.0.1:8000 http://localhost:2525/
; 手机、电脑访问地址 电脑IP:2525
if Auto_AhkServer
{
StoredLogin := CF_IniRead(run_iniFile, "serverConfig", "StoredLogin", "admin")
StoredPass := CF_IniRead(run_iniFile, "serverConfig", "StoredPass", 1234)
LoginPass := CF_IniRead(run_iniFile, "serverConfig", "LoginPass", 0)
buttonSize := CF_IniRead(run_iniFile, "serverConfig", "buttonSize", "30px")
serverPort := CF_IniRead(run_iniFile, "serverConfig", "serverPort", "8000") ; 端口号 设置为 2525 默认 8000
textFontSize := CF_IniRead(run_iniFile, "serverConfig", "textFontSize", "16px")
pagePadding := CF_IniRead(run_iniFile, "serverConfig", "pagePadding", "50px")
mp3file := CF_IniRead(run_iniFile, "serverConfig", "mp3file")
excelfile := CF_IniRead(run_iniFile, "serverConfig", "excelfile")
txtfile := CF_IniRead(run_iniFile, "serverConfig", "txtfile")
loop, 5
{
stableitem%a_index% := CF_IniRead(run_iniFile, "serverConfig", "stableitem" . a_index)
}
mOn := 1
scheduleDelay := 0 ; time before a standby/hibernate command is executed
SHT := scheduleDelay//60000 ; standby/hibernate timer abstracted in minutes
gosub indexInit
}
;----------网页控制电脑----------
; 具有 msgbox 的代码放在脚边最后不影响其它部分
if (Auto_JCTF or Auto_Update) and 每隔几小时结果为真(6)
{
;----------农历节日----------
if Auto_JCTF
Gosub, JCTF
;----------农历节日----------
;---------启动检查更新-----------
If Auto_Update
{
URL := "http://www.baidu.com"
If InternetCheckConnection(URL)
{
WinHttp.URLGet("https://raw.githubusercontent.com/wyagd001/MyScript/master/version.txt",,, update_txtFile)
FileGetSize, sizeq, %update_txtFile%
If(sizeq<20) and (sizeq!=0)
{
FileReadLine, CurVer, %update_txtFile%, 1
If(Trim(CurVer) != AppVersion)
{
msgbox, 4, 升级通知, 当前版本为:%AppVersion%`n最新版本为:%CurVer%`n是否前往主页下载?
IfMsgBox Yes
Run, https://github.com/wyagd001/MyScript
}
}
FileDelete, %update_txtFile%
}
}
;---------启动检查更新-----------
}
;----------WinMouse----------
;----------按住 Capslock 使用鼠标改变窗口的大小和位置 ----------
;----------loop持续运行,放到loop后面的代码不会执行的----------
if Auto_Capslock
{
ScriptINI = %A_ScriptDir%\settings\WinMouse.ini ; Path to INI file
; Get monitor count and stats