-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathEverything.ahk
139 lines (105 loc) · 3.1 KB
/
Everything.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
/*
调用 Everthing 进行搜索
*/
;提取自 RunAny - 一劳永逸的快速启动 @hui-Zz
;主要改动: 1.精简方法名 2.调用 __New 时直接获取Dll信息
;需要保证:1.根目录或指定目录下存在 Everthing的DLL 2.Everthing程序正在运行
;[修改于AHK论坛,IPC方式和everything进行通讯]
;~ protect(Everything)
class Everything{
key:="",MatchWholeWord:=false,DLL:=false
;----------------------------------------------------------------------
;获取EverthingDll
getDll(DLLPath:=""){
if(DLLPath="")
DLLPath:=A_ScriptDir
DLL:=false
if(FileExist(DLLPath "\Everything.dll")){
DLL:=DllCall("LoadLibrary", str, "Everything.dll") ? "Everything.dll" : "Everything64.dll"
}
else if(FileExist(DLLPath "\Everything64.dll")){
DLL:=DllCall("LoadLibrary", str, "Everything64.dll") ? "Everything64.dll" : "Everything.dll"
}
return DLL
}
;----------------------------------------------------------------------
__New(DLLPath:=""){
this.assertEverythingExist()
Dll:=this.getDll(DLLPath)
if Not(Dll){
throwWithSt("Not Found Everthing.DLL/Everthing64.DLL.")
}
this.Dll:=Dll
this.hModule := DllCall("LoadLibrary", str, this.DLL)
return this
}
__Delete(){
DllCall("FreeLibrary", "UInt", this.hModule)
return
}
;----------------------------------------------------------------------
afEverythingExist(){
if Not(this.isEverythingExist()){
throwWithSt("process ""Everything.exe"" is not Exist.")
}
return
}
;----------------------------------------------------------------------
isEverythingExist(){
Process, Exist , % "Everything.exe"
return ErrorLevel
}
;----------------------------------------------------------------------
getSearchResultList(){
theLen:=this.Count()
Str:=this.GetFullPath(0)
StrList:=[]
loop,%theLen%{
StrList.push(this.GetFullPath(A_Index-1))
}
return StrList
}
;----------------------------------------------------------------------
;设置关键词
SetKey(aValue){
this.assertEverythingExist()
this.key := aValue
DllCall(this.DLL "\Everything_SetSearch",str,this.key)
return
}
;----------------------------------------------------------------------
;设置全字匹配
SetMatchWholeWord(aValue){
this.MatchWholeWord := aValue
DllCall(this.DLL "\Everything_SetMatchWholeWord",int,aValue)
return
}
;执行搜索动作 (执行后直接返回匹配数)
Search(aValue=1){
this.assertEverythingExist()
DllCall(this.DLL "\Everything_Query",int,aValue)
return
}
;返回匹配总数
Count(){
return DllCall(this.DLL "\Everything_GetTotResults")
}
;返回文件名
GetFileName(aValue){
return StrGet(DllCall(this.DLL "\Everything_GetResultFileName",int,aValue))
}
;返回文件全路径
GetFullPath(aValue,cValue=128){
VarSetCapacity(bValue,cValue*2)
DllCall(this.DLL "\Everything_GetResultFullPathName",int,aValue,str,bValue,int,cValue)
return bValue
}
;获取 Everything 版本
GetVersionString(){
fmajor := DllCall(this.DLL "\Everything_GetMajorVersion")
fminor:=DllCall(this.DLL "\Everything_GetMinorVersion")
frevision:=DllCall(this.DLL "\Everything_GetRevision")
return Format("{}.{}.{}", fmajor, fminor, frevision)
}
}