-
-
Notifications
You must be signed in to change notification settings - Fork 87
/
RunAny.ahk
10037 lines (9967 loc) · 363 KB
/
RunAny.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
/*
╔══════════════════════════════════════════════════
║【RunAny】一劳永逸的快速启动工具 v5.8.2 @2022.10.22
║ 国内Gitee文档:https://hui-zz.gitee.io/RunAny
║ Github文档:https://hui-zz.github.io/RunAny
║ Github地址:https://github.com/hui-Zz/RunAny
║ 直接运行本脚本需要AutoHotKey版本:1.1.31 以上
║ by hui-Zz 建议:hui0.0713@gmail.com
║ 讨论QQ群:246308937
╚══════════════════════════════════════════════════
*/
#NoEnv ;~;不检查空变量为环境变量
#Persistent ;~;让脚本持久运行
#WinActivateForce ;~;强制激活窗口
#SingleInstance,Force ;~;运行替换旧实例
ListLines,Off ;~;不显示最近执行的脚本行
AutoTrim,On ;~;自动去除变量中前导和尾随空格制表符
SendMode,Input ;~;使用更速度和可靠方式发送键鼠点击
CoordMode,Menu ;~;相对于整个屏幕
SetBatchLines,-1 ;~;脚本全速执行
SetWorkingDir,%A_ScriptDir% ;~;脚本当前工作目录
global StartTick:=A_TickCount ;~;评估初始化时间
global RunAnyZz:="RunAny" ;~;名称
global PluginsDir:="RunPlugins" ;~;插件目录
global RunAnyConfig:="RunAnyConfig.ini" ;~;配置文件
global RunAny_ObjReg:="RunAny_ObjReg.ini" ;~;插件注册配置文件
global RunAny_update_version:="5.8.2" ;~;版本号
global RunAny_update_time:="2022.10.22" ;~;更新日期
global iniPath:=A_ScriptDir "\RunAny.ini" ;~;菜单1
global iniPath2:=A_ScriptDir "\RunAny2.ini" ;~;菜单2
Gosub,Config_Set ;~;01.配置初始化
Gosub,Menu_Var_Set ;~;02.自定义变量
Gosub,Icon_Set ;~;03.图标初始化
Gosub,Run_Exist ;~;04.调用环境判断
;══════════════════════════════════════════════════════════════════
;~;[05.初始化菜单显示热键]
HotKeyList:=["MenuHotKey","MenuHotKey2","MenuNoGetHotKey","EvHotKey","OneHotKey"]
RunHotKeyList:=HotKeyList.Clone()
HotKeyList.Push("TreeHotKey1","TreeHotKey2","TreeIniHotKey1","TreeIniHotKey2"
,"RunATrayHotKey","RunASetHotKey","RunAReloadHotKey","RunASuspendHotKey","RunAExitHotKey"
,"PluginsManageHotKey","RunCtrlManageHotKey","PluginsAlonePauseHotKey","PluginsAloneSuspendHotKey","PluginsAloneCloseHotKey")
HotKeyTextList:=["RunAny菜单显示热键","RunAny菜单2热键","RunAny菜单热键(不获取选中内容)","一键Everything热键","一键搜索热键"]
HotKeyTextList.Push("修改菜单管理(1)","修改菜单管理(2)","修改菜单文件(1)","修改菜单文件(2)")
HotKeyTextList.Push("RunAny托盘菜单","设置RunAny","重启RunAny","停用RunAny","退出RunAny"
,"插件管理","启动管理","独立插件脚本一键暂停","独立插件脚本挂起热键","独立插件脚本一键关闭")
RunList:=["Menu_Show1","Menu_Show2","Menu_NoGet_Show","Ev_Show","One_Show","Menu_Edit1","Menu_Edit2","Menu_Ini","Menu_Ini2"]
RunList.Push("Menu_Tray","Settings_Gui","Menu_Reload","Menu_Suspend","Menu_Exit"
,"Plugins_Gui","RunCtrl_Manage_Gui","Plugins_Alone_Pause","Plugins_Alone_Suspend","Plugins_Alone_Close")
Hotkey, IfWinNotActive, ahk_group DisableGUI
For ki, kv in HotKeyList
{
StringReplace,keyV,kv,Hot
%keyV%:=Var_Read(keyV)
StringReplace,winkeyV,kv,Hot,Win
%winkeyV%:=Var_Read(winkeyV,0)
if(ki=1 && !%keyV%){
%keyV%:="``"
}
}
errorKeyStr:=""
For ki, kv in HotKeyList
{
StringReplace,keyV,kv,Hot
StringReplace,winkeyV,kv,Hot,Win
if(%keyV%){
if(!MENU2FLAG){
if ki in 2,7,9
{
continue
}
}
%kv%:=%winkeyV% ? "#" . %keyV% : %keyV%
try{
if(IsLabel(RunList[ki]))
Hotkey,% %kv%,% RunList[ki],On
}catch{
errorKeyStr.=kv "`n"
}
}
}
if(errorKeyStr){
Gosub,Settings_Gui
if(ki!=1 && ki!=2)
SendInput,^{Tab}
MsgBox,16,RunAny热键配置不正确,% "热键错误:`n" errorKeyStr "`n请设置正确热键后重启RunAny"
return
}
if(A_AhkVersion < 1.1.31){
MsgBox, 16, AutoHotKey版本过低!, 由于你的AHK版本没有高于1.1.31,会影响RunAny功能的使用!`n
(
1. 不支持StrSplit()函数的MaxParts`n2. 不支持动态Hotstring创建`n3. 不支持Switch Case的语法
)
}
;══════════════════════════════════════════════════════════════════
Gosub,Menu_Tray_Add ;~;06.托盘菜单
Gosub,Icon_FileExt_Set ;~;07.后缀图标初始化
t1:=A_TickCount-StartTick
if(!iniFlag){
Gosub,Plugins_Read ;~;08.插件脚本读取
Gosub,AutoClose_Plugins ;~;09.关闭插件脚本
Gosub,AutoRun_Plugins ;~;10.运行插件脚本
Gosub,Plugins_Object_Register ;~;11.插件对象注册
Gosub,RunCtrl_Read ;~;12.启动规则读取
}
;══════════════════════════════════════════════════════════════════
;~;[13.创建初始菜单]
t2:=t3:=A_TickCount-StartTick
Menu_Tray_Tip("初始化+运行插件:" Round(t2/1000,3) "s`n","开始创建无图标菜单...")
global MenuObj:=Object() ;~程序全路径
global MenuObjKey:=Object() ;~程序热键
global MenuObjKeyName:=Object() ;~程序热键关联菜单项名称
global MenuObjKeyList:=Object() ;~程序热键关联菜单项列表
global MenuObjExt:=Object() ;~后缀对应的菜单
global MenuObjWindow:=Object() ;~软件窗口对应的菜单
global MenuHotStrList:=Object() ;~热字符串对象数组
global MenuTreeKey:=Object() ;~菜单树分类热键
global MenuObjIconList:=Object() ;~菜单项对应图标对象
global MenuObjIconNoList:=Object() ;~菜单项对应图标位置对象
global MenuExeArray:=Object() ;~EXE程序对象数组
global MenuExeIconArray:=Object() ;~EXE程序优先加载图标对象数组
global MenuObjTreeLevel:=Object() ;~菜单对应级别
global MenuObjPublic:=[] ;~后缀公共菜单
global MenuShowFlag:=false ;~菜单功能是否可以显示
global MenuIconFlag:=false ;~菜单图标是否加载完成
global MenuObjName:=Object() ;~程序菜单项名称
global MenuBar:="" ;~菜单分列标记
global MenuCount:=MENU2FLAG ? 2 : 1
MenuObj.SetCapacity(10240)
MenuExeArray.SetCapacity(1024)
MenuExeIconArray.SetCapacity(3072)
Loop,%MenuCount%
{
M%A_Index%:=RunAnyZz . A_Index
MenuSendStrList%A_Index%:=Object() ;菜单中短语项列表
MenuWebList%A_Index%:=Object() ;菜单中网址%s搜索项列表
MenuGetZzList%A_Index%:=Object() ;菜单中GetZz搜索项列表
MenuExeList%A_Index%:=Object() ;菜单中的exe列表
MenuObjList%A_Index%:=Object() ;菜单分类运行项列表
MenuObjText%A_Index%:=[] ;选中文字菜单
MenuObjFile%A_Index%:=[] ;选中文件菜单
MenuObjTree%A_Index%:=Object() ;分类目录程序全数据
MenuObjTree%A_Index%[M%A_Index%]:=Object()
;菜单级别:初始为根菜单RunAny
menuRoot%A_Index%:=[M%A_Index%]
}
;══════════════════════════════════════════════════════════════════
global NoPathFlag:=false ;是否拿到无路径搜索结果
global MenuObjEv:=Object() ;Everything搜索结果程序全路径
global MenuObjSame:=Object() ;Everything搜索结果重名程序全路径
global MenuObjSearch:=Object() ;Everything搜索无路径菜单项
global MenuObjCache:=Object() ;Everything搜索无路径应用缓存
global MenuObjNew:=Object() ;Everything搜索新增加
global MenuObjEvPathEmptyReason:=Object() ;Everything无路径应用搜索不到的原因
EvCommandStr:="" ;Everything搜索字符
;~;[14.获取无路径应用的运行全路径缓存]
if(EvDemandSearch){
EvCommandStr:=EverythingNoPathSearchStr()
Loop, parse, evFullPathIniVar, `n, `r
{
varList:=StrSplit(A_LoopField,"=",,2)
outVarStr:=varList[1]
objFileNameNoExeExt:=RegExReplace(outVarStr,"iS)\.exe$","")
MenuObj[objFileNameNoExeExt]:=varList[2]
MenuObjCache[outVarStr]:=varList[2]
;检查缓存中的无路径应用被删除或移动
if(Trim(varList[2]," `t`r`n")!="" && !FileExist(varList[2])){
MenuObjCache[outVarStr]:="" ;缓存失效则置空
if(RegExMatch(outVarStr, RegexEscapeNoPointStr)){
outVarStr:=StrListEscapeReplace(outVarStr, RegexEscapeNoPointList, "\")
}
outVarStr:=StrReplace(outVarStr,".","\.")
MenuObjNew.push("^" outVarStr "$")
}
;无路径应用被删除自动清除对应的缓存
if(!MenuObjSearch.HasKey(outVarStr)){
IniDelete, %RunAnyEvFullPathIni%, FullPath, %outVarStr%
}
}
;发现有新增的无路径菜单项
if(Trim(evFullPathIniVar," `t`r`n")!=""){
NoPathFlag:=true
for k,v in MenuObjSearch
{
;发现有新的无路径应用
if(!MenuObjCache.HasKey(k)){
MenuObjCache[k]:=""
if(RegExMatch(k, RegexEscapeNoPointStr)){
k:=StrListEscapeReplace(k, RegexEscapeNoPointList, "\")
}
k:=StrReplace(k,".","\.")
MenuObjNew.push("^" k "$")
}else{
MenuObjSearch[k]:=MenuObjCache[k]
}
}
if(MenuObjNew.Length()>0){
NoPathFlag:=false
EvCommandStr:=StrListJoin("|",MenuObjNew)
EvCommandStr:="regex:""" EvCommandStr """"
}
}
}
MenuObjEv:=MenuObj.Clone()
;~;[15.判断有无路径应用则需要使用Everything]
if(!NoPathFlag && !EvNo){
if(!EvDemandSearch || (EvDemandSearch && EvCommandStr!="")){
t3:=A_TickCount-StartTick
if(EverythingIsRun()){
Menu_Tray_Tip("","开始调用Everything搜索菜单内应用全路径...")
RegRead,EvTotResults,HKEY_CURRENT_USER\SOFTWARE\RunAny,EvTotResults
if(EvTotResults>0){
EverythingQuery(EvCommandStr)
NoPathFlag:=true
for k,v in MenuObjSearch
{
IniWrite, %v%, %RunAnyEvFullPathIni%, FullPath, %k%
}
}else{
Gosub,EverythingCheck
Loop, 30
{
RegRead,EvTotResults,HKEY_CURRENT_USER\SOFTWARE\RunAny,EvTotResults
if(EvTotResults>0){
EverythingQuery(EvCommandStr)
NoPathFlag:=true
for k,v in MenuObjSearch
{
IniWrite, %v%, %RunAnyEvFullPathIni%, FullPath, %k%
}
break
}
Sleep, 100
}
RegRead,EvTotResults,HKEY_CURRENT_USER\SOFTWARE\RunAny,EvTotResults
if(!EvTotResults){
SetTimer,EverythingCheckResults,100
}
}
}
}
}
;══════════════════════════════════════════════════════════════════
t4:=A_TickCount-StartTick
t32:=t3-t2 ? Round((t3-t2)/1000,3) "+" : ""
Menu_Tray_Tip("调用Everything搜索应用全路径:" t32 Round((t4-t3)/1000,3) "s`n","开始加载完整菜单功能...")
Menu_Read(iniVar1,menuRoot1,"",1)
;~;[16.如果有第2菜单则开始加载]
if(MENU2FLAG){
Menu_Tray_Tip("","开始创建菜单2内容...")
Menu_Read(iniVar2,menuRoot2,"",2)
}
MenuShowFlag:=true
t5:=A_TickCount-StartTick
Menu_Tray_Tip("菜单创建:" Round((t5-t4)/1000,3) "s`n")
;~;[17.初始菜单加载后操作]
if(SendStrEcKey!="")
SendStrDcKey:=SendStrDecrypt(SendStrEcKey,RunAnyZz ConfigDate)
t6:=t7:=A_TickCount-StartTick
;~;[18.规则启动程序]
if(RunCtrlListBoxVar!=""){
Gosub,Rule_Effect
t7:=A_TickCount-StartTick
Menu_Tray_Tip("规则启动:" Round((t7-t6)/1000,3) "s`n")
}
;~;[19.对菜单内容项进行过滤调整]
Loop,%MenuCount%
{
M_Index:=A_Index
menuDefaultRoot%A_Index%:=[M%A_Index% " "]
Menu_Read(iniVar%A_Index%,menuDefaultRoot%A_Index%," ",A_Index)
menuWebRoot%A_Index%:=[M%A_Index% " "]
Menu_Read(iniVar%A_Index%,menuWebRoot%A_Index%," ",A_Index)
menuFileRoot%A_Index%:=[M%A_Index% " "]
Menu_Read(iniVar%A_Index%,menuFileRoot%A_Index%," ",A_Index)
Menu_Item_List_Filter(A_Index,"MenuSendStrList",HideSend)
Menu_Item_List_Filter(A_Index,"MenuWebList",HideWeb)
Menu_Item_List_Filter(A_Index,"MenuGetZzList",HideGetZz)
;带%s的网址菜单分类下增加批量搜索功能项
For mn,items in MenuWebList%A_Index%
{
if(!RegExMatch(mn,"S)[^\s]+\s$")){
Menu,%mn%,add
Menu,%mn%,add,%RUNANY_SELF_MENU_ITEM1%%mn%,Web_Run
Menu,%mn%,Icon,%RUNANY_SELF_MENU_ITEM1%%mn%,% UrlIconS[1],% UrlIconS[2],%MenuIconSize%
}
}
;设置后缀公共菜单
MenuObjExt["public"]:=MenuObjPublic
;选中文本菜单过滤分类
if(MenuObjText%A_Index%.MaxIndex()>0){
Menu_Tree_List_Filter(A_Index,"MenuObjText",2)
rootName:=menuWebRoot%A_Index%[1]
;开启选中文字菜单后,主菜单里面不带%getZz%或%s的都不再显示
for k,v in MenuObjTree%A_Index%[rootName]
{
if(v!="" && Get_Menu_Item_Mode(v,true)<10){
if(!InStr(v,"%getZz%") && !InStr(v,"%s")){
try Menu,%rootName%,Delete,% Get_Obj_Name(v)
}else{
MenuObjTextRootFlag%M_Index%:=true
}
}
}
}
;选中文件菜单过滤分类
if(MenuObjFile%A_Index%.MaxIndex()>0){
Menu_Tree_List_Filter(A_Index,"MenuObjFile",3)
rootName:=menuFileRoot%A_Index%[1]
;开启选中文件菜单后,主菜单里面不带%getZz%或%s的都不再显示
for k,v in MenuObjTree%A_Index%[rootName]
{
if(v!="" && !InStr(v,"%getZz%") && !InStr(v,"%s")
&& Get_Menu_Item_Mode(v,true)!=1 && Get_Menu_Item_Mode(v,true)<10){
try Menu,%rootName%,Delete,% Get_Obj_Name(v)
}
}
}
;~;[20.最近运行项]
if(RecentMax>0){
For mci, mcItem in MenuCommonList
{
if(A_Index>RecentMax)
break
obj:=RegExReplace(mcItem,"^&\d+ ")
MenuObj[mcItem]:=MenuObj[obj]
Menu,% menuDefaultRoot%M_Index%[1],Add,%mcItem%,Menu_Run
Menu,% menuWebRoot%M_Index%[1],Add,%mcItem%,Menu_Run
Menu,% menuFileRoot%M_Index%[1],Add,%mcItem%,Menu_Run
fullpath:=Get_Obj_Path(MenuObj[mcItem])
SplitPath,fullpath, , , ext
if(ext="exe"){
Menu_Item_Icon(menuDefaultRoot%M_Index%[1],mcItem,fullpath)
Menu_Item_Icon(menuWebRoot%M_Index%[1],mcItem,fullpath)
Menu_Item_Icon(menuFileRoot%M_Index%[1],mcItem,fullpath)
}else{
recentItemMode:=Get_Menu_Item_Mode(MenuObj[mcItem])
Menu_Add(menuDefaultRoot%M_Index%[1],mcItem,MenuObj[mcItem],recentItemMode,"")
Menu_Add(menuWebRoot%M_Index%[1],mcItem,MenuObj[mcItem],recentItemMode,"")
Menu_Add(menuFileRoot%M_Index%[1],mcItem,MenuObj[mcItem],recentItemMode,"")
}
}
}
}
t8:=A_TickCount-StartTick
Menu_Tray_Tip("菜单加载:" Round((t8-t7)/1000,3) "s`n")
;~;[21.内部关联后缀打开方式]
Gosub,Open_Ext_Set
Menu_Tray_Tip("","菜单已经可以正常使用`n开始为菜单中exe程序加载图标...")
;~;[22.菜单中EXE程序加载图标,有ico图标更快]
For k, v in MenuExeIconArray
{
if(DisableExeIcon){
Menu_Item_Icon(v["menuName"],v["menuItem"],EXEIconS[1],EXEIconS[2])
}else{
Menu_Item_Icon(v["menuName"],v["menuItem"],v["itemFile"])
}
}
For k, v in MenuExeArray
{
if(DisableExeIcon){
Menu_Item_Icon(v["menuName"],v["menuItem"],EXEIconS[1],EXEIconS[2])
}else{
Menu_Item_Icon(v["menuName"],v["menuItem"],v["itemFile"])
}
}
;-------------------------------------------------------------------------------------------
;~;[23.菜单已经加载完毕,托盘图标变化]
t9:=A_TickCount-StartTick
Menu_Tray_Tip("菜单加载exe图标:" Round((t9-t8)/1000,3) "s`n","总加载时间:" Round(t9/1000,3) "s")
Menu,Tray,Icon,% AnyIconS[1],% AnyIconS[2]
MenuIconFlag:=true
;#如果是第一次运行#
if(iniFlag){
iniFlag:=false
TrayTip,,RunAny菜单初始化完成`n右击任务栏图标设置,5,1
Gosub,Menu_About
Gosub,Menu_Show1
}
;~;[24.检查无路径应用缓存是否有新的版本]
if(NoPathFlag && !EvNo && Trim(evFullPathIniVar," `t`r`n")!="" && rule_check_is_run("Everything.exe")){
Gosub,RunAEvFullPathSync
}
;~;[25.记录ini文件修改时间]
FileGetTime,MTimeIniPath, %iniPath%, M ; 获取修改时间.
RegRead, MTimeIniPathReg, HKEY_CURRENT_USER\Software\RunAny, %iniPath%
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\RunAny, %iniPath%, %MTimeIniPath%
IniChangeFlag:=MTimeIniPathReg=MTimeIniPath
if(MENU2FLAG){
FileGetTime,MTimeIniPath2, %iniPath2%, M ; 获取修改时间.
RegRead, MTimeIniPath2Reg, HKEY_CURRENT_USER\Software\RunAny, %iniPath2%
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\RunAny, %iniPath2%, %MTimeIniPath2%
IniChangeFlag:=IniChangeFlag && (MTimeIniPath2Reg=MTimeIniPath2)
}
if(rule_check_is_run(PluginsPathList["RunAny_SearchBar.ahk"])
&& (!IniChangeFlag || !FileExist(RunAEvFullPathIniDirPath "\RunAnyMenuObj.ini")
|| !FileExist(RunAEvFullPathIniDirPath "\RunAnyMenuObjExt.ini")
|| !FileExist(RunAEvFullPathIniDirPath "\RunAnyMenuObjIcon.ini"))){
Gosub,RunAny_SearchBar
Run,% A_AhkPath A_Space """" PluginsPathList["RunAny_SearchBar.ahk"] """"
}
;如果有需要继续执行的操作
RegRead, ReloadGosub, HKEY_CURRENT_USER\Software\RunAny, ReloadGosub
if(ReloadGosub){
RegWrite, REG_SZ, HKEY_CURRENT_USER\SOFTWARE\RunAny, ReloadGosub, 0
Gosub,%ReloadGosub%
}
;提前加载菜单树图标缓存
global TreeImageListID := IL_Create(11)
Icon_Image_Set(TreeImageListID)
Icon_Tree_Image_Set(TreeImageListID)
;~;[26.自动备份配置文件]
if(RunABackupRule && RunABackupDirPath!=A_ScriptDir){
RunABackupFormatStr:=Get_Transform_Val(RunABackupFormat)
RunABackup(RunABackupDirPath "\", RunAnyZz ".ini*", iniVar1, iniPath, RunAnyZz ".ini" RunABackupFormatStr)
RunABackup(RunABackupDirPath "\" RunAnyZz "2.ini\", RunAnyZz "2.ini*", iniVar2, iniPath2, RunAnyZz "2.ini" RunABackupFormatStr)
FileRead, iniVarBak, %RunAnyConfig%
RunABackup(RunABackupDirPath "\" RunAnyConfig "\", RunAnyConfig "*", iniVarBak, RunAnyConfig, RunAnyConfig RunABackupFormatStr)
}
if(AutoReloadMTime>0){
SetTimer,AutoReloadMTime,%AutoReloadMTime%
}
;如果需要自动关闭everything
if(EvAutoClose && EvPathRun){
Run,%EvPathRun% -exit
}
return
;■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
;~;[菜单项过滤不同内容类型]
Menu_Item_List_Filter(M_Index,MenuTypeList,HideFlag,MenuType:=1){
if(!HideFlag)
return
if(MenuType=1){
rootName:=menuDefaultRoot%M_Index%[1]
rootReg:="S)[^\s]+\s$"
}else if(MenuType=2){
rootName:=menuWebRoot%M_Index%[1]
rootReg:="S)[^\s]+\s{2}$"
}else if(MenuType=3){
rootName:=menuFileRoot%M_Index%[1]
rootReg:="S)[^\s]+\s{3}$"
}
For mn,items in %MenuTypeList%%M_Index%
{
if(mn=rootName || RegExMatch(mn,rootReg)){
Loop, Parse, items, `n
{
if(A_LoopField="")
continue
try Menu,%mn%,Delete,%A_LoopField%
}
if(InStr(mn,RunAnyZz))
continue
if(%MenuTypeList%%M_Index%[mn]=MenuObjList%M_Index%[mn]){
try Menu,%mn%,Delete
}
}
}
}
;~[菜单节点分类过滤]
Menu_Tree_List_Filter(M_Index,MenuTypeList,MenuType){
if(MenuType=2){
TREE_TYPE:=" "
rootReg:="S)[^\s]+\s{2}$"
}else if(MenuType=3){
TREE_TYPE:=" "
rootReg:="S)[^\s]+\s{3}$"
}
For mn,items in MenuObjTree%M_Index%
{
if(!RegExMatch(mn,rootReg))
continue
delFlag:=true
For k,v in %MenuTypeList%%M_Index%
{
if(mn=v TREE_TYPE || mn=M%M_Index% TREE_TYPE){
delFlag:=false
break
}
}
if(delFlag){
try Menu,%mn%,Delete
}
}
}
;[修改RunAny.ini文件自动重启]
AutoReloadMTime:
RegRead, MTimeIniPathReg, HKEY_CURRENT_USER\Software\RunAny, %iniPath%
FileGetTime,MTimeIniPath, %iniPath%, M ; 获取修改时间.
if(MTimeIniPathReg!=MTimeIniPath){
Gosub,Menu_Reload
}
if(MENU2FLAG){
RegRead, MTimeIniPath2Reg, HKEY_CURRENT_USER\Software\RunAny, %iniPath2%
FileGetTime,MTimeIniPath2, %iniPath2%, M ; 获取修改时间.
if(MTimeIniPath2!=MTimeIniPath2Reg){
Gosub,Menu_Reload
}
}
return
;[RunAny自动备份配置文件]
RunABackup(RunABackupDir,RunABackupFile,RunABackupFileContent,RunABackupFileCopy,RunABackupFileTarget){
ConfigBackupNum:=0
ConfigBackupFlag:=true
Loop,%RunABackupDir%%RunABackupFile%
{
FileRead, iniVarBak, %A_LoopFileFullPath%
if(RunABackupFileContent=iniVarBak){
ConfigBackupFlag:=false
}
ConfigBackupNum++
}
if(ConfigBackupFlag){
FileCopy, %RunABackupFileCopy%, %RunABackupDir%%RunABackupFileTarget%, 1
}
if(ConfigBackupNum>RunABackupMax){
RunABackupClear(RunABackupDir,RunABackupFile)
}
}
RunABackupClear(RunABackupDir,RunABackupFile){
if(RunABackupMax>0){
oldFile:=A_Now
Loop,%RunABackupDir%%RunABackupFile%
{
if(oldFile>A_LoopFileTimeCreated){
oldFile:=A_LoopFileTimeCreated
oldPath:=A_LoopFileLongPath
}
}
if(RegExMatch(oldPath, "iS).*?\.bak$")){
FileDelete, %oldPath%
}
}
}
;~;[无路径应用缓存同步更新]
RunAEvFullPathSync:
MenuObjUpdateList:=Object(),MenuObjEv:=Object(),MenuObjSearch:=Object()
if(EverythingQuery(EvCommandStr)){
for k,v in MenuObjCache
{
if(MenuObjSearch[k] && v!=MenuObjSearch[k]){
IniWrite, % MenuObjSearch[k], %RunAnyEvFullPathIni%, FullPath, %k%
MenuObjUpdateList.Push(k)
}else if(MenuObjCache[k]="" && !MenuObjEvPathEmptyReason[k]){
MenuObjEvPathEmptyReason[k]:="在EV中没有搜索到"
RunAEvFullPathSyncFlag:=true
}
}
if(MenuObjUpdateList.Length()>0){
Gosub,RunAny_SearchBar
ShowTrayTip("以下无路径应用缓存更新:",StrListJoin("、",MenuObjUpdateList),10,17)
Gosub,Menu_Reload
}
}
return
;══════════════════════════════════════════════════════════════════
;~;【多种启动菜单热键】
#If MenuDoubleCtrlKey=1
Ctrl::Gosub,DoubleClickKey
#If
#If MenuDoubleAltKey=1
Alt::Gosub,DoubleClickKey
#If
#If MenuDoubleLWinKey=1
LWin::Gosub,DoubleClickKey
#If
#If MenuDoubleRWinKey=1
RWin::Gosub,DoubleClickKey
#If
#If MenuCtrlRightKey=1
~Ctrl & RButton::Gosub,Menu_Show1
#If
#If MenuShiftRightKey=1
~Shift & RButton::Gosub,Menu_Show1
#If
#If MenuXButton1Key=1
XButton1::Gosub,Menu_Show1
#If
#If MenuXButton2Key=1
XButton2::Gosub,Menu_Show1
#If
#If MenuMButtonKey=1 && !WinActive("ahk_group DisableGUI")
~MButton::Gosub,Menu_Show1
#If
DoubleClickKey:
KeyWait,%A_ThisHotkey%
KeyWait,%A_ThisHotkey%,d,t0.2
if !Errorlevel
Gosub,Menu_Show1
else
SendInput,{%A_ThisHotkey%}
return
return
;══════════════════════════════════════════════════════════════════
;~;【——🏗创建菜单——】
;══════════════════════════════════════════════════════════════════
Menu_Read(iniReadVar,menuRootFn,TREE_TYPE,TREE_NO){
MenuObjName:=Object() ;~程序菜单项名称
MenuBar:="" ;~菜单分列标记
MenuObjParam:=Object() ;~程序参数
menuLevel:=1
Loop, parse, iniReadVar, `n, `r
{
try{
Z_LoopField=%A_LoopField%
if(InStr(Z_LoopField,";")=1 || Z_LoopField=""){
continue
}
TREE_TYPE_FLAG:=(TREE_TYPE="" || TREE_TYPE=" ")
;[生成节点树层级结构]
if(InStr(Z_LoopField,"-")=1){
menuItem:=RegExReplace(Z_LoopField,"S)^-+")
treeLevel:=RegExReplace(Z_LoopField,"S)(^-+).*","$1")
menuLevel:=StrLen(treeLevel)
if(InStr(menuItem,"|")){
menuItems:=StrSplit(menuItem,"|",,2)
menuItem:=menuItems[1]
;[读取菜单关联后缀][不重复]
if(TREE_TYPE=""){
Loop, parse,% menuItems[2],%A_Space%
{
;选中文件后显示的公共后缀菜单
if(A_LoopField="public"){
MenuObjPublic.Push(treeLevel . menuItem)
}else if(A_LoopField="text"){
MenuObjText%TREE_NO%.Push(menuItem)
}else if(A_LoopField="file"){
MenuObjFile%TREE_NO%.Push(menuItem)
}else if(RegExMatch(A_LoopField,"iS).+\.(exe|class)$")){
global MenuObjWindowFlag:=true
windowItem:=RegExReplace(A_LoopField,"iS)\.class$")
if(!IsObject(MenuObjWindow[(windowItem)]))
MenuObjWindow[(windowItem)]:=Object()
MenuObjWindow[(windowItem)].Push(menuItem)
}else{
MenuObjExt[(A_LoopField)]:=menuItem
}
}
}
}
if(menuItem!=""){
menuItemType:=menuItem . TREE_TYPE
Menu,%menuItemType%,add
try Menu,% menuRootFn[menuLevel],add,%menuItemType%,:%menuItemType%,%MenuBar%
Menu_Item_Icon(menuRootFn[menuLevel],menuItemType,TreeIconS[1],TreeIconS[2],treeLevel . menuItemType)
Menu,%menuItemType%,Delete, 1&
menuLevel+=1 ;比初始根菜单加一级
menuRootFn[menuLevel]:=menuItemType ;从这之后内容项都添加到该级别菜单中
;记录全局菜单数据
if(!IsObject(MenuObjTree%TREE_NO%[menuItemType]))
MenuObjTree%TREE_NO%[menuItemType]:=Object()
MenuObjTreeLevel[menuItemType]:=treeLevel
;[分割Tab获取菜单自定义热键][不重复]
if(TREE_TYPE_FLAG && InStr(menuItem,"`t")){
menuKeyStr:=RegExReplace(menuItem, "S)\t+", A_Tab)
menuKeys:=StrSplit(menuKeyStr,"`t")
if(menuKeys[2]){
MenuTreeKey[menuKeys[2]]:=menuItemType
Hotkey,% menuKeys[2],Menu_Key_Show,On
}
}
}else if(menuRootFn[menuLevel]){ ;[添加分隔符]
menuRootFnLevel:=menuRootFn[menuLevel]
Menu,%menuRootFnLevel%,Add
MenuObjTree%TREE_NO%[menuRootFnLevel].Push(Z_LoopField)
}
MenuBar:=""
continue
}
if(Z_LoopField="|" || Z_LoopField="||"){
MenuBar:=(Z_LoopField="||") ? "+BarBreak" : "+Break"
continue
}
if(menuRootFn[menuLevel]="")
continue
itemMode:=Get_Menu_Item_Mode(Z_LoopField,true)
if(TREE_TYPE="" && itemMode=60 && RegExMatch(Z_LoopField,"iS).*?%s[^%]*$")){
MsgBox,48,请修改菜单项 `%s不能识别,% "菜单项:" Get_Obj_Transform_Name(Z_LoopField)
. "`n里面的`%s 仅支持在纯网址模式,`n在参数中请替换使用%getZz%表示选中文字"
}
;短语、网址、脚本插件函数除外的菜单项直接转换%%为系统变量值
transformValFlag:=false
if(itemMode!=2 && itemMode!=3 && itemMode!=8){
Z_LoopField:=StrReplace(Z_LoopField,"%getZz%",Chr(3))
Z_LoopField:=StrReplace(Z_LoopField,"%Clipboard%",Chr(4))
Z_LoopField:=StrReplace(Z_LoopField,"%ClipboardAll%",Chr(5))
Z_LoopField:=Get_Transform_Val(Z_LoopField)
Z_LoopField:=StrReplace(Z_LoopField,Chr(3),"%getZz%")
Z_LoopField:=StrReplace(Z_LoopField,Chr(4),"%Clipboard%")
Z_LoopField:=StrReplace(Z_LoopField,Chr(5),"%ClipboardAll%")
transformValFlag:=true
}
itemMode:=Get_Menu_Item_Mode(Z_LoopField,true)
;~添加到分类目录程序全数据
if(!IsObject(MenuObjTree%TREE_NO%[(menuRootFn[menuLevel])]))
MenuObjTree%TREE_NO%[(menuRootFn[menuLevel])]:=Object()
MenuObjTree%TREE_NO%[(menuRootFn[menuLevel])].Push(Z_LoopField)
flagEXE:=false ;~添加exe菜单项目
flagSys:=false ;~添加系统项目文件
IconFail:=false ;~是否显示无效项图标
;[生成有前缀备注的应用]
if(InStr(Z_LoopField,"|")){
menuDiy:=StrSplit(Z_LoopField,"|",,2)
menuItemDiy:=menuDiy[1]
appName:=RegExReplace(menuDiy[2],"iS)(.*?\.[a-zA-Z0-9-_]+)($| .*)","$1") ;去掉参数,取应用名
appName:=RegExReplace(appName,"iS)\.exe$") ;去掉exe后缀,取应用名
;[分割Tab获取应用自定义热键]
menuKeyStr:=RegExReplace(menuDiy[1], "S)\t+", A_Tab)
menuKeys:=StrSplit(menuKeyStr,"`t",,2)
if(MenuObjName.HasKey(menuItemDiy) || MenuObjParam.HasKey(menuItemDiy)){
if(menuKeys[2]){
menuItemDiy:=menuKeys[1] "重名" A_Tab menuKeys[2]
}else{
menuItemDiy.="重名"
}
}
itemContent:=MenuObjEv[appName]
if(itemContent){
SplitPath, itemContent,,, FileExt ; 获取文件扩展名.
appParm:=RegExReplace(menuDiy[2],"iS).*?\." FileExt "($| .*)","$1") ;去掉应用名,取参数
;非exe后缀的菜单项名与无路径exe的名称相同,则自动在菜单项名末尾添加后缀标记
if(FileExt!="exe" && appName!=menuItemDiy && MenuObjEv[menuItemDiy]){
menuItemDiy.="." FileExt
}
MenuObjParam[menuItemDiy]:=itemContent . appParm
itemParam:=itemContent . appParm
flagEXE:=true
}else{
itemContent:=menuDiy[2]
itemParam:=menuDiy[2]
if(transformValFlag && RegExMatch(itemContent,"iS).*?\.(exe|lnk|bat|cmd|vbs|ps1|ahk) .*"))
itemContent:=RegExReplace(itemContent,"iS)(.*?\.(exe|lnk|bat|cmd|vbs|ps1|ahk)) .*","$1") ;只去参数
SplitPath, itemContent,,, FileExt ; 获取文件扩展名.
;~;如果是有效全路径或系统程序则保留显示
if(RegExMatch(itemContent,"iS)^(\\\\|.:\\).*?\.(exe|lnk|bat|cmd|vbs|ps1|ahk)$") && FileExist(itemContent)){
flagEXE:=true
}else if(FileExist(A_WinDir "\" itemContent) || FileExist(A_WinDir "\system32\" itemContent)){
flagEXE:=true
if(FileExt!="exe"){
flagSys:=true
flagSysPath:=FileExist(A_WinDir "\" itemContent) ? A_WinDir "\" itemContent : ""
if(flagSysPath="" && FileExist(A_WinDir "\system32\" itemContent))
flagSysPath:=A_WinDir "\system32\" itemContent
}
}
;~;如果是有效程序、不隐藏失效、不是exe程序则添加该菜单项功能
if(FileExt!="exe"){
MenuObj[menuItemDiy]:=menuDiy[2]
}else if(flagEXE || !HideFail){
MenuObjParam[menuItemDiy]:=menuDiy[2]
}
}
if(FileExt="exe"){
if(flagEXE){
MenuExeArrayPush(menuRootFn[menuLevel],menuItemDiy,itemContent,menuDiy[2],TREE_NO)
}else{
IconFail:=true
}
if(!HideFail)
flagEXE:=true
;添加菜单项
if(flagEXE){
Menu,% menuRootFn[menuLevel],add,% menuItemDiy,Menu_Run,%MenuBar%
if(IconFail)
Menu_Item_Icon(menuRootFn[menuLevel],menuItemDiy,"SHELL32.dll","124")
}else{
MenuObjTree_Delete_NoFind(MenuObjTree%TREE_NO%,menuRootFn[menuLevel],menuItemDiy)
}
}else if FileExt in lnk,bat,cmd,vbs,ps1,ahk
{
Menu_Add(menuRootFn[menuLevel],menuItemDiy,itemContent,itemMode,TREE_NO)
}else if(flagSys){
Menu_Add(menuRootFn[menuLevel],menuItemDiy,flagSysPath="" ? itemContent : flagSysPath,itemMode,TREE_NO)
}else{
Menu_Add(menuRootFn[menuLevel],menuItemDiy,itemParam,itemMode,TREE_NO)
}
;[设置热键启动方式][不重复]
if(TREE_TYPE_FLAG && InStr(menuDiy[1],"`t") && menuKeys[2]){
; MenuObj[menuKeys[1]]:=itemParam
MenuObjKey[menuKeys[2]]:=itemParam
MenuObjKeyName[menuKeys[2]]:=menuKeys[1]
MenuObjKeyList[menuDiy[1]]:=menuKeys[2]
if(!InStr(menuDiy[2],"%getZz%") && RegExMatch(menuDiy[2],"iS).+?\[.+?\]%?\(.*?\)")){
Hotkey,% menuKeys[2],Menu_Key_NoGet_Run,On
}else if(itemMode=4 || itemMode=5){ ;热键映射不去获取当前选中内容
Hotkey,% menuKeys[2],Menu_Key_NoGet_Run,On
}else{
Hotkey,% menuKeys[2],Menu_Key_Run,On
}
}
;[设置热字符串启动方式][不重复]
if(TREE_TYPE="" && RegExMatch(menuKeys[1],"S):[*?a-zA-Z0-9]+?:[^:]*")){
hotStrName:=menuKeys[1]
if(RegExMatch(hotStrName,"S).*_:\d{1,2}$"))
hotStrName:=RegExReplace(hotStrName,"S)(.*)_:\d{1,2}$","$1")
hotstr:=RegExReplace(hotStrName,"S)^[^:]*?(:[*?a-zA-Z0-9]+?:[^:]*)","$1")
hotStrName:=RegExReplace(hotStrName,"S)^([^:]*?):[*?a-zA-Z0-9]+?:[^:]*","$1")
if(hotstr){
MenuObjKey[hotstr]:=itemParam
MenuObjKeyName[hotstr]:=menuKeys[1]
if(RegExMatch(hotstr,"S):[^:]*?X[^:]*?:[^:]*")){
;热字符串运行不传递选中内容:不带%getZz%的运行项、不带%getZz%或%s的网址
if(itemMode=6 && !InStr(menuDiy[2],"%getZz%") && !InStr(menuDiy[2],"%s")){
Hotstring(hotstr,"Menu_Key_NoGet_Run","On")
}else if(!InStr(menuDiy[2],"%getZz%")){
Hotstring(hotstr,"Menu_Key_NoGet_Run","On")
}else{
Hotstring(hotstr,"Menu_Key_Run","On")
}
if(!HideHotStr)
Menu_HotStr_Hint_Read(hotstr,hotStrName,itemParam)
}else{
Hotstring(hotstr,itemParam,"On")
}
}
}
MenuBar:=""
continue
}
;[生成完全路径的应用]
if(RegExMatch(Z_LoopField,"iS)^(\\\\|.:\\).*?\.exe($| .*)")){
appParm:=RegExReplace(Z_LoopField,"iS).*?\.exe($| .*)","$1") ;去掉应用名,取参数
Z_LoopField:=RegExReplace(Z_LoopField,"iS)(.*?\.exe)($| .*)","$1")
SplitPath,Z_LoopField,fileName,,,nameNotExt
menuAppName:=appParm!="" ? nameNotExt A_Space : nameNotExt
MenuObjParam[menuAppName]:=Z_LoopField . appParm
if(FileExist(Z_LoopField)){
MenuExeArrayPush(menuRootFn[menuLevel],menuAppName,Z_LoopField,Z_LoopField . appParm,TREE_NO)
flagEXE:=true
}else{
IconFail:=true
}
if(!HideFail)
flagEXE:=true
;添加菜单项
if(flagEXE){
Menu,% menuRootFn[menuLevel],add,% menuAppName,Menu_Run,%MenuBar%
if(IconFail){
Menu_Item_Icon(menuRootFn[menuLevel],menuAppName,"SHELL32.dll","124")
}
}else{
MenuObjTree_Delete_NoFind(MenuObjTree%TREE_NO%,menuRootFn[menuLevel],menuAppName)
}
MenuBar:=""
continue
}
;[生成通过Everything取到的无路径应用]
if(RegExMatch(Z_LoopField,"iS)\.exe($| .*)")){
appParm:=RegExReplace(Z_LoopField,"iS).*?\.exe($| .*)","$1") ;去掉应用名,取参数
Z_LoopField:=RegExReplace(Z_LoopField,"iS)(.*?\.exe)($| .*)","$1")
appName:=RegExReplace(Z_LoopField,"iS)\.exe$")
menuAppName:=appParm!="" ? appName A_Space A_Space : appName
if(MenuObjEv[appName]){
flagEXE:=true
MenuObj[menuAppName]:=MenuObjEv[appName]
MenuObjParam[menuAppName]:=MenuObjEv[appName] . appParm
}else if(FileExist(A_WinDir "\" Z_LoopField) || FileExist(A_WinDir "\system32\" Z_LoopField)){
flagEXE:=true
MenuObj[menuAppName]:=Z_LoopField
MenuObjParam[menuAppName]:=Z_LoopField . appParm
}else if(!HideFail){
MenuObj[menuAppName]:=Z_LoopField
MenuObjParam[menuAppName]:=Z_LoopField . appParm
}
if(flagEXE){
MenuExeArrayPush(menuRootFn[menuLevel],menuAppName,MenuObj[menuAppName],MenuObj[menuAppName] . appParm,TREE_NO)
}else{
IconFail:=true
}
if(!HideFail)
flagEXE:=true
;添加菜单项
if(flagEXE){
Menu,% menuRootFn[menuLevel],add,% menuAppName,Menu_Run,%MenuBar%
if(IconFail)
Menu_Item_Icon(menuRootFn[menuLevel],menuAppName,"SHELL32.dll","124")
}else{
MenuObjTree_Delete_NoFind(MenuObjTree%TREE_NO%,menuRootFn[menuLevel],menuAppName)
}
}else{
if(!MenuObjEv[Z_LoopField])
MenuObj[Z_LoopField]:=Z_LoopField
else
MenuObj[Z_LoopField]:=MenuObjEv[Z_LoopField]
Menu_Add(menuRootFn[menuLevel],Z_LoopField,MenuObj[Z_LoopField],itemMode,TREE_NO)
}
MenuBar:=""
} catch e {
MsgBox,16,构建菜单出错,% "菜单名:" menuRootFn[menuLevel] "`n菜单项:" A_LoopField
. "`n出错命令:" e.What "`n错误代码行:" e.Line "`n错误信息:" e.extra "`n" e.message
}
}
For key, value in MenuObjParam
{
MenuObj[key]:=value
}
if(!HideMenuTray){
Menu,% menuRootFn[1],add,%RUNANY_SELF_MENU_ITEM2%,:Tray,%MenuBar%
Menu,% menuRootFn[1],Icon,%RUNANY_SELF_MENU_ITEM2%,% AnyIconS[1],% AnyIconS[2],%MenuIconSize%
}
Menu,% menuRootFn[1],add,
}
;[统一集合菜单中软件运行项]
MenuExeArrayPush(menuName,menuItem,itemFile,itemAny,TREE_NO){
MenuObjEXE:=Object() ;~软件对象
MenuObjEXE["menuName"]:=menuName
MenuObjEXE["menuItem"]:=menuItem
MenuObjEXE["itemFile"]:=itemFile
;~ MenuObjEXE["itemAny"]:=itemAny
if(RegExMatch(menuName,"S)[^\s]+$")){
MenuExeArray.Push(MenuObjEXE)
}else{
MenuExeIconArray.Push(MenuObjEXE)
if(!InStr(itemAny,"%getZz%"))
MenuExeList%TREE_NO%[menuName].=menuItem "`n"
}
}
;[读取热字串用作提示文字]
Menu_HotStr_Hint_Read(hotstr,hotStrName,itemParam){
menuHotStrShow:=RegExReplace(hotstr,"^:[^:]*?X[^:]*?:")
menuHotStrLen:=StrLen(menuHotStrShow)
HotStrHintLenVal:=HotStrHintLen>1 ? HotStrHintLen : 1
if(menuHotStrLen=0)
return
if(menuHotStrLen=1){
menuHotStrHint:=menuHotStrShow
}else if(menuHotStrLen<=HotStrHintLenVal){ ;总长度小于4在减1长度时提示
menuHotStrHint:=SubStr(menuHotStrShow, 1, menuHotStrLen-1)
}else{
loop, % menuHotStrLen - HotStrHintLenVal
{
MenuObjHotStr:=Object() ;热字符对象
menuHotStrHint:=SubStr(menuHotStrShow, 1, A_Index + HotStrHintLenVal-1)
MenuObjHotStr["hotStrAny"]:=itemParam
MenuObjHotStr["hotStrHint"]:=menuHotStrHint
MenuObjHotStr["hotStrShow"]:=menuHotStrShow
MenuObjHotStr["hotStrName"]:=hotStrName
MenuHotStrList.Push(MenuObjHotStr)
Hotstring(":*Xb0:" . menuHotStrHint,"Menu_HotStr_Hint_Run","On")
}
return
}
MenuObjHotStr:=Object() ;热字符对象
MenuObjHotStr["hotStrAny"]:=itemParam
MenuObjHotStr["hotStrHint"]:=menuHotStrHint
MenuObjHotStr["hotStrShow"]:=menuHotStrShow
MenuObjHotStr["hotStrName"]:=hotStrName
MenuHotStrList.Push(MenuObjHotStr)
Hotstring(":*Xb0:" . menuHotStrHint,"Menu_HotStr_Hint_Run","On")
}
Menu_HotStr_Hint_Run:
runHotStrHint:=RegExReplace(A_ThisHotkey,"^:[^:]*?Xb0:")
HintTip:=["","","",""]
for k , v in MenuHotStrList
{
if(v["hotStrHint"]=runHotStrHint){
hotStrName:=v["hotStrName"]!=""?v["hotStrName"]:""
;将获取到的热字符串中的变量进行转化,比如显示实时时间
hotStrFixed:=RegExReplace(v["hotStrAny"],"S);+$")
hotStrFlexible:=Get_Transform_Val(hotStrFixed)
if(HotStrShowLen<=0){
hotStrAny:=""
}else if(StrLen(v["hotStrAny"])>HotStrShowLen){
hotStrAny:=SubStr(hotStrFlexible, 1, HotStrShowLen) . "..."
}else{
hotStrAny:=hotStrFlexible
}
HintTip[1] .= runHotStrHint "`n",HintTip[2] .= v["hotStrShow"] " `n",HintTip[3] .= hotStrName " `n",HintTip[4] .= hotStrAny " `n"
}
}
HintTip[2]:=RTrim(HintTip[2],"`n"),HintTip[3]:=RTrim(HintTip[3],"`n"),HintTip[4]:=RTrim(HintTip[4],"`n")
CreateHotStrGui(HintTip,HotStrGuiW,HotStrGuiH)
GetCaret(CaretX, CaretY, CaretW, CaretH, Flag)
If(Flag=0)
CaretX := CaretX+HotStrShowX, CaretY := CaretY+HotStrShowY-HotStrGuiH
Else
CaretX := CaretX+HotStrShowX+CaretW, CaretY := CaretY+HotStrShowY-HotStrGuiH
CaretX := CaretX+HotStrGuiW>A_ScreenWidth?A_ScreenWidth-5-HotStrGuiW:CaretX,CaretY := CaretY<5?5:CaretY
try Gui, HotStrGui:Show, x%CaretX% y%CaretY% NoActivate
SetTimer, Hide_HotStrGui, %HotStrShowTime%
Return
Hide_HotStrGui: ;隐藏GUI
SetTimer, Hide_HotStrGui, Off
Gui, HotStrGui:Hide
Return
return