-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBen.ahk
283 lines (249 loc) · 6.37 KB
/
Ben.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
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases
#Warn ; Enable every type of warning; show each warning in a message box
#SingleInstance Ignore ; Skips the dialog box and leaves the old instance running
SendMode Input ; Recommended for new scripts due to its superior speed and reliability
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory
#Include %A_ScriptDir% ; Change the working directory used by all subsequent occurrences of #Include and FileInstall. SetWorkingDir has no effect on #Include because #Include is processed before the script begins executing.
SetTitleMatchMode 2 ; A window's title can contain WinTitle anywhere inside it to be a match
programTitle = Bahk
EnvGet, LocalAppData, LocalAppData
GroupAdd, CtrlShiftZ, OneNote
GroupAdd, CtrlShiftZ, ahk_exe winword.exe
GroupAdd, CtrlShiftZ, ahk_exe excel.exe
GroupAdd, CtrlShiftZ, ahk_exe WindowsTerminal.exe
GroupAdd, NoEmoji, ahk_exe slack.exe
GroupAdd, NoEmoji, ahk_exe Discord.exe
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Script Startup
if not A_IsAdmin
{
Run, *RunAs "%A_ScriptFullPath%" /restart
ExitApp
}
startupLinkFile := A_Startup "\" programTitle ".lnk"
IfNotExist, % startupLinkFile
{
FileCreateShortcut, % A_ScriptFullPath, % startupLinkFile, % A_ScriptDir, , , % A_ScriptDir "\" programTitle ".ico"
}
Menu, Tray, Icon, Bahk.ico, , 1
TrayTip, % programTitle, Loaded
#Include Modules\Autofill.ahk
#Include Modules\CopyPaste.ahk
#Include Modules\Guid.ahk
#Include Modules\Emoji.ahk
#Include Modules\WindowManipulation.ahk
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Script Shortcuts
#^+e::Edit
#^+r::
Reload
Sleep, 1000
SoundPlay, *16
TrayTip, % programTitle, Failed to reload, , 16
return
#^+s::
Suspend, Toggle
if A_IsSuspended = 1
{
Menu, Tray, Icon, Bahk-Suspend.ico, , 1
TrayTip, % programTitle, Suspended
}
else
{
Menu, Tray, Icon, Bahk.ico, , 1
TrayTip, % programTitle, Resumed
}
return
#^+h::
SplitPath, A_AhkPath, , ahkLocation
Run, "%ahkLocation%\AutoHotkey.chm"
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; General Shortcuts
#h::return
#d::
Input chordKey, L1 M T1
if chordKey = f ; "file"
{
Input chordKey, L1 M T1
if chordKey = p ; "prefix"
{
FormatTime, dateString, %A_Now%, yyyyMMdd
}
else
{
FormatTime, dateString, %A_Now%, yyyy-MM-dd HH_mm_ss
}
}
else if chordKey = t ; "time"
{
FormatTime, dateString, %A_Now%, yyyy-MM-dd HH:mm:ss
}
else if chordKey = i ; "ISO 8601"
{
FormatTime, dateString, %A_NowUTC%, yyyy-MM-ddTHH:mm:ssZ
}
else
{
date = %A_Now%
if (chordKey = "=" || chordKey = "+" || chordKey = "-")
{
Input chordKey2, L1 M T1
if (chordKey2 >= 1 && chordKey2 <= 9)
{
date += chordKey2 * (chordKey = "-" ? -1 : 1), days
}
}
FormatTime, dateString, %date%, yyyy-MM-dd, dddd
}
Send, % dateString
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Programs
#m::Run, "%LocalAppData%\authy\Authy Desktop.exe"
#IfWinActive ahk_exe Authy Desktop.exe
$^1::
$^2::
$^3::
$^4::
$^5::
item := SubStr(A_ThisHotkey, 0) - 1
itemY := 115 + 74 * item
CoordMode, Mouse, Client
MouseGetPos, savedX, savedY
Click, 40, %itemY%
MouseMove, %savedX%, %savedY%, 0
return
Esc::
CoordMode, Mouse, Client
MouseGetPos, savedX, savedY
Click, 33, 56
MouseMove, %savedX%, %savedY%, 0
return
^c::
CoordMode, Mouse, Client
MouseGetPos, savedX, savedY
Click, 350, 528
MouseMove, %savedX%, %savedY%, 0
return
#If
#IfWinActive ahk_group CtrlShiftZ
^+z::Send, ^y
#If
#IfWinActive - Message (HTML) ahk_exe outlook.exe
!Up::!+Up
!Down::!+Down
#If
#IfWinActive OneNote
!Up::!+Up
!Down::!+Down
^+PgUp::Send, ^+a!+{Up}{Esc}
^+PgDn::Send, ^+a!+{Down}{Esc}
^+k::Send, {Home}+{End}+{Right}{Delete}
^=::^!+=
^-::^!+-
!+Down::
clipboardOrig := ClipboardAll
Send, {Esc}^a^c{Home}^v
Sleep, 500 ; clipboardOrig can be copied back before ^v happens
Clipboard := clipboardOrig
clipboardOrig = ; free memory in case clipboard was large
return
#If
#IfWinActive ahk_exe winword.exe
!Up::!+Up
!Down::!+Down
^+k::Send, {End}+{Home}{Delete}
^=::
Send, !wq
WinWait, Zoom
Send, !e{Up 10}{Enter}
return
^-::
Send, !wq
WinWait, Zoom
Send, !e{Down 10}{Enter}
return
^Numpad0::Send, !wj
^.::Send, !hu{Right}{Enter}{Esc}
#If
#IfWinActive ahk_exe Discord.exe
!F4::WinClose
#If
#IfWinActive Microsoft Store
XButton1::!Left
#If
#IfWinActive, ahk_exe slack.exe
^p::^k
#If
#IfWinActive ahk_exe Teams.exe
!Left::
CoordMode, Mouse, Client
MouseGetPos, savedX, savedY
MouseMove, 0, 0, 0
Send, {XButton1}
MouseMove, %savedX%, %savedY%, 0
return
!Right::
CoordMode, Mouse, Client
MouseGetPos, savedX, savedY
MouseMove, 0, 0, 0
Send, {XButton2}
MouseMove, %savedX%, %savedY%, 0
return
#If
#IfWinActive ahk_class ZPZoomToastNotifierWnd
MButton::WinClose, A
#If
#IfWinActive ahk_exe msedge.exe
^,::
; Sidebar must be turned off for these tab counts
Send, !+t+{Tab 2}
Sleep, 100
Send, {Home}{Right}{Space}+{F6}
return
$^1::
$^2::
$^3::
$^4::
$^5::
item := SubStr(A_ThisHotkey, 0) - 1
WinGetPos, , , clientW, clientH
if (clientW == 433 and clientH == 658)
{
itemY := 140 + 53 * item
CoordMode, Mouse, Client
MouseGetPos, savedX, savedY
Click, 272, %itemY%
MouseMove, %savedX%, %savedY%, 0
}
else
{
Send, % StrReplace(A_ThisHotkey, "$", "")
}
return
#If
; Win 11 taskbar fix
#1::
#2::
#3::
#4::
#5::
#6::
#7::
#8::
#9::
#0::
numberKey := SubStr(A_ThisHotkey, 0)
KeyWait, %numberKey%
if GetKeyState("LWin", "P")
{
Send, {Blind}%numberKey%
}
else
{
Send, {LWin down}%numberKey%
Sleep, 150
Send, {LWin up}
}
return