-
Notifications
You must be signed in to change notification settings - Fork 7
/
app_handling.ahk
352 lines (279 loc) · 8.68 KB
/
app_handling.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
#Include WinTitles.ahk
#If WinActive("ahk_class SDL_app")
j::Space
k::PgUp
#If
;-------------------------------------------------
; CapsLock sublime text
CapsLock & s::
runSublimeText(){
if !WinExist(ahk_sublime) {
Run "C:\all\Sublime Text\sublime_text.exe"
WinWait % ahk_sublime
}
Sleep 499
WinActivate % ahk_sublime
}
;-------------------------------------------------
; CapsLock Telegram
;
; it seems that i cannot open telegram window when it is in task bar, so
; i just chose to reopen it every time. telegram is single instance, so all
; looks good so far :^)
;
; SendInput is used so that i select the first chat :^)
;
CapsLock & t::
startAndResizeTelegram()
{
if !WinExist(WinTitles.Telegram) {
Run "C:\all\Telegram\Telegram.exe"
Winwait % WinTitles.Telegram
Sleep 499
WinActivate % WinTitles.Telegram
; select the most important chat
Sleep 499
SendInput {PgDn}
Sleep 90
SendInput {PgUp}
Sleep 90
SendInput {PgUp}
Sleep 90
SendInput {PgUp}
Sleep 90
SendInput {Enter}
Sleep 499
; ; move the window to its proper position
; NOTE: THIS DOES NOT WORK. SOMETIMES TELEGRAM JUST WONT FUCKING RESIZE.
; RUUUUUUDE!
getTaskbarDimensions(tw, th)
w := A_ScreenWidth/2.5
h := A_ScreenHeight - th
x := A_ScreenWidth - w
y := 0
WinMove, % WinTitles.Telegram, , x, y, w, h
; another method of moving telegram to its desired position.
; this also bugges sometimes
; save initial mouse pos
; CoordMode Mouse, Screen
; MouseGetPos, initial_x, initial_y
; SetDefaultMouseSpeed 40
; CoordMode Mouse, Window
; ; move mouse to starting position of resize process
; MouseMove, 100, 16
; SendInput {LButton}
; SendInput {LButton}
; Sleep 90
; MouseMove, 100, 16
; ; do a windows right-snap (resize window to half the screen, right side)
; SendInput {LButton down}
; CoordMode Mouse, Screen ;; this coordMode trickery has to be done for each movement.
; MouseMove, A_ScreenWidth, A_ScreenHeight/2
; CoordMode Mouse, Window
; SendInput {LButton up}
; Sleep 90
; ; set the desired window size
; MouseMove, -1, 200
; SendInput {LButton down}
; CoordMode Mouse, Screen
; MouseMove, A_ScreenWidth - A_ScreenWidth/3, 200
; CoordMode Mouse, Window
; SendInput {LButton up}
; ; ; de-snap the window, so that the size is remembered.
; ; ; windows is retarded and does not remember the size/position for snapped windows.
; ; MouseMove, 200, 16
; ; SendInput {LButton down}
; ; MouseMove, -10, 0,,R
; ; SendInput {LButton up}
; ; Sleep 90
; ; SendInput {LButton down}
; ; MouseMove, 10, 0,,R
; ; SendInput {LButton up}
; ; Sleep 90
; ; move the mouse back to the original position
; CoordMode Mouse, Screen
; MouseMove, initial_x, initial_y
}
else {
WinActivate % WinTitles.Telegram
}
}
; ------------------------------------------------
; Firefox and Chrome: mouse-scroll over the "tab area" to switch tabs forward and backward, instead of clicking/using
; ctrl+tab or ctrl+shift+tab
;
; ; "~"" is used so that i can scroll in the normal page
; #If WinActive(ahk_firefox) || WinActive(ahk_chrome)
; ~WheelUp::
; MouseGetPos, , y
; if (y > -1 && y <= 40) {
; Send ^+{Tab}
; }
; Return
; ~WheelDown::
; MouseGetPos, , y
; if (y > -1 && y <= 40) {
; Send ^{Tab}
; }
; Return
; #If
;-------------------------------------------------
; get taskbar dimensions, assuming bottom position
getTaskbarDimensions(ByRef tw, ByRef th) {
WinGetPos, x, y, tw, th, ahk_class Shell_TrayWnd
}
;-------------------------------------------------
; Sublime Text: CapsLock & w to toggle word wrap
#If WinActive(ahk_sublime)
CapsLock & w::
SendInput ^+P
Sleep 500
SendInput wwp
Sleep 500
SendInput {Enter}
Return
#If
;-------------------------------------------------
; Intellij Idea/goland: CapsLock & w to toggle word wrap
#If WinActive(WinTitles.IntellijIdea) || WinActive(WinTitles.Goland)
CapsLock & w::
SendInput ^+A
Sleep 500
SendInput active editor soft wrap
Sleep 500
SendInput {Enter}
Sleep 500
SendInput {Esc}
Return
#If
;-------------------------------------------------
; 2018.09.07: no need for this as sublime text is licensed now!
; hide the Sublime Text message for unregistered copy
; #IfWinExist This is an unregistered copy ahk_exe sublime_text.exe
; hideSublimeRegister() {
; sublime_window := WinExist("This is an unregistered copy " . ahk_sublime)
; if (sublime_window) {
; WinActivate
; SendInput {Esc}
; }
; }
;-------------------------------------------------
; hide the TeamViewer message for sponsored session
; and also close the TeamViewer window afterwards
hideTeamviewerSponsoredsession() {
if WinExist(WinTitles.TeamViewerSponsoredSession) {
SetControlDelay 0
ControlClick, OK
; Looping a few times here, because TeamViewer sometimes shows multiple windows after dismissing the first
loop, 5
{
; It seems that simply Winclose, WinTitles.TeamViewer doesnt work.
; I have to actually search for the window and then WinClose the automatically filled variable.
; Weird...
if WinExist(WinTitles.TeamViewer)
{
WinClose
}
Sleep, 300
}
}
}
;-------------------------------------------------
; use just F4 to close some windows
#If false
|| WinActive(WinTitles.Telegram)
; || WinActive(ahk_chrome)
; || WinActive(ahk_firefox)
|| WinActive(WinTitles.Vlc)
|| WinActive(WinTitles.ModernPhotos*)
|| WinActive(WinTitles.ModernSkype*)
|| WinActive(WinTitles.TeamViewer)
|| WinActive(WinTitles.CorsairCUE)
|| WinActive(WinTitles.Skype)
|| WinActive(WinTitles.BattleNet)
|| WinActive(WinTitles.ACDSee)
F4:: SendInput !{F4}
#If
;-------------------------------------------------
; disable End in AcdSee
#If WinActive(WinTitles.ACDSee)
End::Return
#If
; ------------------------------------------------
; ------------------------------------------------
; ------------------------------------------------
; ------------------------------------------------
; ------------------------------------------------
; ------------------------------------------------
; #If WinActive(ahk_tf2)
; ;-------------------------------------------------
; ; tf2: press reload and autoclick
; CapsLock & R::
; ; CallMethodWithTimer("pressR", 500)
; CallMethodWithTimer("clickLMouse", 50)
; Return
; ; ; stop autoclicking (for example if scoped -> stop scope and autoclicking)
; ; ~RButton::
; ; if (WinActive(ahk_tf2)
; ; && IsToggleOn("pressR")
; ; && IsToggleOn("clickLMouse")) {
; ; CallMethodWithTimer("pressR", 1)
; ; CallMethodWithTimer("clickLMouse", 1)
; ; }
; Return
; #If
; ; pressR() {
; ; if (WinActive(ahk_tf2)) {
; ; SendInput {r}
; ; }
; ; }
; clickLMouse(){
; if (WinActive(ahk_tf2)) {
; SendInput {LButton}
; }
; }
CapsLock & v::
openInMpv() {
ClipSaved := ClipboardAll ; Backup Clipboard
clipboard := ""
Send ^l
Sleep 100
Send ^a
Sleep 100
Send ^c
ClipWait 1
Tippy("Opening mpv with: " Clipboard)
Run % "C:\all\mpv.net\mpvnet.exe " Clipboard
Clipboard := ClipSaved ; Restore Clipboard
}
;-----------------------
; Microshitsoft Teams is fucking retarded
;
; Replace "Fancy Paste" with Plain text Copy-Pasta
#If WinActive(WinTitles.MsTeams)
^V::
disableFancyPasteOnText(){
if DllCall("IsClipboardFormatAvailable", "uint", 1)
{
Send ^+v
}
else
{
Send ^v
}
}
#If
;-------------------------------------------------
; Fix Vivaldi Gestures
;
; The problem with Vivaldi is that on "3 finger swipe" left and right touchpad gestures,
; Vivaldi executes the Browser_Forward and Browser_Back actions both on key up and on key down.
; Therefore the solution is simple: don't send key down events to Vivaldi
; Browser_Back via 3 finger swipe to right
sc16A::Return
sc16A Up::SendInput !{Left} ; This sends Alt+Left
sc06A::Return
sc06A Up::SendInput !{Left} ; This sends Alt+Left
; Browser_Forward via 3 finger swipe to left
sc069::Return
sc069 Up::SendInput !{Right} ; This sends Alt+Right