-
Notifications
You must be signed in to change notification settings - Fork 0
/
公共.ahk
217 lines (201 loc) · 4.65 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
SetKeyDelay 30
; windows+shift+alt+c 关闭标签或窗口
#!+c:: ;约从Chrome 53开始,alt+shift+control+c容易被Chrome先捕获,AutoHotKey后捕获UP事件,造成shift粘滞的现象。
{
try
{
ProcessName:=WinGetProcessName("A")
}
catch as e
{
TrayTip "无法操作", e.Message, 1
return
}
winTitle:=WinGetTitle("A")
pid:=WinGetPID("A")
if(A_IsAdmin==0 && IsProcessElevated(pid))
{
TrayTip "无法操作", "目标窗口具有管理员权限,而本脚本不具有管理员权限", 1
return
}
;一个等号是不区分大小写的比较 https://autohotkey.com/docs/Variables.htm#operators
if (ProcessName="devenv.exe") ;在编程环境中是单步跳过
SendInput "{F10}"
else if (winTitle="F12" && ProcessName="iexplore.exe")
SendInput "{F10}"
else if (InStr(winTitle, "Developer Tool")==1 && ProcessName="chrome.exe")
SendInput "{F10}"
else if (ProcessName="chrome.exe" || ProcessName="iexplore.exe" || ProcessName="vivaldi.exe" || ProcessName="firefox.exe")
SendInput "^w"
else if(ProcessName="Lingoes64.exe"|| ProcessName="Lingoes.exe")
SendInput "{Esc}"
else if (ProcessName="dopus.exe")
SendInput "^w"
else if (ProcessName="BCompare.exe")
SendInput "^w"
; 向ShellExperienceHost.exe发送WinClose会触发关机对话框。
else if(ProcessName = "ShellExperienceHost.exe")
SendInput "{Esc}"
; explorer如果没有窗口,发送winclose会变成关机,容易误操作。
else if (ProcessName="explorer.exe")
SendInput "^w"
else if (ProcessName="eclipse.exe")
SendInput "{F10}"
else if (ProcessName="vmplayer.exe")
{
TrayTip "为防止误操作,不关闭VMWare窗口"
}
else
WinClose "A"
}
;alt+Windows+h 上一标签页
!#h::
{
try
{
ProcessName:=WinGetProcessName("A")
}
catch as e
{
TrayTip "无法操作", e.Message, 1
return
}
if (ProcessName="dopus.exe")
SendInput "^{left}"
else
SendInput "^+{tab}"
}
;control+alt+Windows+h 历史记录中的上一页
^!#h:: SendInput "!{left}"
;alt+Windows+l 下一标签页
!#l::
{
try
{
ProcessName:=WinGetProcessName("A")
}
catch as e
{
TrayTip "无法操作", e.Message, 1
return
}
pid:=WinGetPID("A")
if(A_IsAdmin==false && IsProcessElevated(pid))
{
TrayTip "无法操作", "目标窗口具有管理员权限,而本脚本不具有管理员权限", 1
return
}
winTitle:=WinGetTitle("A")
if (ProcessName="devenv.exe") ;在编程环境中是单步进入
SendInput "{F11}"
else if (ProcessName="eclipse.exe")
SendInput "{F11}"
else if(ProcessName="dopus.exe")
SendInput "^{right}"
else
SendInput "^{tab}"
}
;control+alt+Windows+l 历史记录中的下一页
^!#l:: SendInput "!{right}"
;windows+contrl+y 复制/获取副本命令
^#y UP::
{
path:=WinGetProcessPath("A")
if (EndsWith(path,"BCompare.exe"))
{
SendInput "^n"
}
else if (a_cursor="IBeam")
{
SendInput "^c"
}
else if(EndsWith(path, "chrome.exe") || EndsWith(path, "vivaldi.exe")) ;chrome里复制当前标签
{
A_Clipboard:=""
SendInput("{F6}")
sleep 100
SendEvent "^c"
if(!clipwait(1) || A_Clipboard == "")
{
TrayTip "快捷键错误", "F6没有获取到标签页地址", 1
SendInput("!d")
SendEvent "^c"
if(!clipwait(1) || A_Clipboard == "")
{
TrayTip "快捷键错误", "alt+d没有获取到标签页地址", 1
return
}
}
SendInput "^t"
sleep 100
if(InStr(A_Clipboard, "?")==0)
{
A_Clipboard:= A_Clipboard "?nodup=true"
}
else
A_Clipboard:= A_Clipboard "&nodup=true"
SendText A_Clipboard
SendInput "{enter}"
}
else if(EndsWith(path,"explorer.exe"))
{
sleep 50
SendInput "^n"
}
else
run path
}
^!F11::
{
If WinActive("ahk_exe chrome.exe")
{
send "^I"
return
}
If WinActive("ahk_exe firefox.exe")
{
send "^I"
return
}
If WinActive("ahk_exe devenv.exe")
{
send "^l"
return
}
If WinActive("ahk_exe iexplore.exe")
{
send "{F12}"
return
}
}
; 如果longText以value结尾,则返回1;否则返回0。
EndsWith(longText, value)
{
if(InStr(longText, value)=0)
return 0
return InStr(longText, value)-1+StrLen(value)=StrLen(longText)
}
;1:elevated
;0:not elevated
;-1:error (probably elevated)
; From https://autohotkey.com/boards/viewtopic.php?p=197426#p197426
IsProcessElevated(vPID)
{
;PROCESS_QUERY_LIMITED_INFORMATION := 0x1000
if !(hProc := DllCall("kernel32\OpenProcess", "UInt", 0x1000, "Int", 0, "UInt",vPID, "Ptr"))
return -1
;TOKEN_QUERY := 0x8
hToken:=0
if !(DllCall("advapi32\OpenProcessToken", "Ptr",hProc, "UInt",0x8, "PtrP", &hToken))
{
DllCall("kernel32\CloseHandle", "Ptr",hProc)
return -1
}
;TokenElevation := 20
vIsElevated:=0
vSize:=0
vRet := (DllCall("advapi32\GetTokenInformation", "Ptr",hToken, "Int",20, "UIntP", &vIsElevated, "UInt",4, "UIntP", &vSize))
DllCall("kernel32\CloseHandle", "Ptr",hToken)
DllCall("kernel32\CloseHandle", "Ptr",hProc)
return vRet ? vIsElevated : -1
}