-
Notifications
You must be signed in to change notification settings - Fork 5
/
keyRemap.ahk
421 lines (367 loc) · 10.1 KB
/
keyRemap.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
; This file must be in Windows 1252 or UTF-BOM encoding, because of "»"
#include keyRemapFunc.ahk
;=================== Capslock Toggled on
#if GetKeyState("CapsLock", "T")
*1:: ; Capslock acts as Numlock for top row numbers
*2::
*3::
*4::
*5::
*6::
*7::
*8::
*9::
*0::
send % "{Blind}{Numpad" subStr(A_ThisHotkey,2) "}"
return
*-::
*=::
send % "{Blind}{Numpad" ({"*-": "Sub", "*=": "Add"}[A_ThisHotkey]) "}"
return
#if
;=================== CapsLock as Prefix
#if GetKeyState("CapsLock", "P")
r:: ; I forget +F10 ; No AppsKey in my laptop
m:: ; Hard to M-Click in trackpad
prefixUsed("CapsLock")
SendKeys({r: "{AppsKey}", m: "{MButton}"}[subStr(A_ThisHotkey,0)])
return
Space:: ; Play/Pause all visible video players
prefixUsed("CapsLock")
playAllVideoPlayers()
return
/*
n:: ; NetNotify
prefixUsed("CapsLock")
netNotify(True,,1000)
return
*/
1:: ; Caps+Num => #Num since #Num is replaced below
2::
3::
4::
5::
6::
7::
8::
9::
0::
prefixUsed("CapsLock")
if !prefixUsed("CapsLock_Num", False)
send {LWin down}
prefixUsed("CapsLock_Num")
send % A_ThisHotkey
setTimer, winUpWhenCapsReleased, 100
return
;=================== R/M Button as Prefix
RETURN
#if getKeyState("RButton","P")
LButton:: ; Switch to next window
sendWindowBack()
prefixUsed("RButton")
return
MButton:: winSizer.start("RButton") ; WinSizer (keyboard alternative below)
MButton Up::
if !winSizer.end()
send, #{Tab}
prefixUsed("RButton")
return
WheelUp:: ; Go to Prev/Next Desktops
WheelDown::
(A_ThisHotkey="WheelUp")? taskView.GoToDesktopPrev(): taskView.GoToDesktopNext()
prefixUsed("RButton")
sleep 200
tooltip
return
#if getKeyState("MButton","P") AND !isOver_mouse("ahk_group WG_TaskBar")
WheelUp:: ; Move window to desktop and go there
WheelDown::
if (A_ThisHotkey="WheelUp")
taskView.MoveWindowAndGoToDesktopPrev(WinExist("A"))
else
taskView.MoveWindowAndGoToDesktopNext(WinExist("A"))
prefixUsed("MButton")
sleep 200
return
#IfWinActive ahk_group WG_RightDrag
~*RButton up::
Critical
prefixUsed(subStr(A_ThisHotkey, 3, 7), False)
return
#If
*RButton up::
*MButton up::
Critical
sendPrefixKey(subStr(strReplace(A_ThisHotkey,"~"), 2, 7))
return
#If
;=================== Task View with Keyboard
RETURN
+#d::
^+#d::
if (A_ThisHotkey="+#d")
taskView.CreateNewDesktopsAfterCurrent()
else
taskView.CreateNewDesktopsBeforeCurrent()
return
+#Left:: ; Move window to desktop and go there
+#Right::
if (A_ThisHotkey="+#Left")
taskView.MoveWindowAndGoToDesktopPrev(WinExist("A"))
else
taskView.MoveWindowAndGoToDesktopNext(WinExist("A"))
return
!#Left:: ; Move window to desktop
!#Right::
if (A_ThisHotkey="!#Left")
taskView.MoveWindowToDesktopPrev(WinExist("A"))
else
taskView.MoveWindowToDesktopNext(WinExist("A"))
return
^+#Left:: ; Move Desktop
^+#Right::
if (A_ThisHotkey="^+#Left")
taskView.MoveCurrentDesktopLeft()
else
taskView.MoveCurrentDesktopRight()
return
#1:: ; Go to Desktop by number
#2::
#3::
#4::
#5::
#6::
#7::
#8::
#9::
#0::
taskView.GoToDesktopNumber(SubStr(A_ThisHotKey,0)=="0" ?10: SubStr(A_ThisHotKey,0), False)
return
+#1:: ; Move window to Desktop by number and go there
+#2::
+#3::
+#4::
+#5::
+#6::
+#7::
+#8::
+#9::
+#0::
taskView.MoveWindowAndGoToDesktopNumber( SubStr(A_ThisHotKey,0)=="0"? 10: SubStr(A_ThisHotKey,0), winExist("A"), False)
return
!#1:: ; Move window to Desktop by number
!#2::
!#3::
!#4::
!#5::
!#6::
!#7::
!#8::
!#9::
!#0::
taskView.MoveWindowToDesktopNumber(SubStr(A_ThisHotKey,0)=="0" ?10: SubStr(A_ThisHotKey,0), sendWindowBack(), False)
return
^+#1:: ; Move Desktop
^+#2::
^+#3::
^+#4::
^+#5::
^+#6::
^+#7::
^+#8::
^+#9::
^+#0::
taskView.MoveCurrentDesktopTo(SubStr(A_ThisHotKey,0)=="0" ?10: SubStr(A_ThisHotKey,0), False)
return
;=================== Over Taskbar
RETURN
#if winActive("ahk_group WG_TaskView") AND isOver_mouse("ahk_group WG_TaskBar")
LButton::send {Enter} ; When Task Switching
WheelUp::send ^+!{Tab}
WheelDown::send ^!{Tab}
MButton Up::send {Alt Up}{Esc}
#if isOver_mouse("ahk_group WG_TaskBar")
~MButton Up::send ^!{Tab} ; Alt tab over taskbar
;WheelUp::Volume_Up
;WheelDown::Volume_Down
WheelUp::changeVolume(1) ; Change volume scrolling over taskbar
WheelDown::changeVolume(-1)
^WheelUp::
^WheelDown::
changeVolumeBalance(inStr(A_ThisHotkey, "Up")? .1:-.1)
return
#if
/*
;=================== Groupy
RETURN
!CapsLock::Send #``
!+CapsLock::Send #^``
*/
;=================== Fences Pages
RETURN
#ifwinActive ahk_group WG_Desktop
WheelUp::
WheelDown::
if getKeyState("LButton","P")
send % "{LButton Up}!{" (A_ThisHotkey=="WheelUp"?"WheelDown":"WheelUp") "}"
else
send {%A_ThisHotkey%}
return
#if
;=================== WinSizer
RETURN
+^CapsLock::
prefixUsed("CapsLock")
winSizer.start("CapsLock")
return
~Ctrl Up::
~Shift Up::
winSizer.end()
return
;=================== Toggglekeys
RETURN
+~CapsLock::
~NumLock::
~ScrollLock::
~Insert::
Toast.show( {title:{text:str_Replace(A_ThisHotkey,[["~"],["+"]]) (GetKeyState(str_Replace(A_ThisHotkey,[["~"],["+"]]),"T")? " On":" Off")}, sound:True})
return
;=================== Trigger HotStrings (») [Check hotStrings.ahk for details]
RETURN
CapsLock::
keyWait %A_ThisHotkey%
if !prefixUsed("CapsLock", False)
SendKeys("»", 10) ;Used to trigger many hotstrings
return
;=================== Send `n/`t in cases where enter/tab is used for other purposes
/* (See HotStrings for alternate implementation)
#ifWinNotActive ahk_group WG_ShiftEnter
+Enter::Send `n
#ifWinNotActive ahk_group WG_ShiftSpace
+Space::Send % " " ;I prefer 4 spaces instead of tab in some situations instead of tab
#if
*/
;=================== X1 - Ditto & Launcher
RETURN
XButton2::
Keywait, %A_ThisHotkey%, T0.5
!ErrorLevel? activateProgram(PRG_RS_Clipboard) : runLauncher(False,True)
return
;=================== X2 - winAction & RunText
RETURN
XButton1::
Keywait, %A_ThisHotkey%, T0.25
!ErrorLevel? winAction.show() : runTextObj.showGUI()
return
;=================== Launcher
RETURN
LWin:: runlauncher(True) ; LWin => Launcher
#Space:: runLauncher(False,True) ; Open Launcher with pastable text
#ifWinActive ahk_group WG_Launcher
~Tab:: ; Paste previously selected text
~Space::
if keepSelectedText(False, A_ThisHotkey=="~Tab")
tooltip("Press TAB to paste :`n" subStr(keepSelectedText(""), 1, 150), {no:3, y:-50, x:0, mode:"Window"} )
return
#if
LWin & RWin:: return ; Allows LWin to be still used as prefix
;+^LWin:: send {Ctrl Up}{Shift Up}{LWin Up}{RWin} ; +^LWin => Win (^Esc already does this)
;=================== Programs/Functions
RETURN
^CapsLock:: caseMenu.show() ; caseMenu
#CapsLock:: activateProgram(PRG_RS_WindowSwitcher) ; WindowSwitch
+#CapsLock:: activateProgram(PRG_RS_TextEditor) ; Text editor
^#CapsLock:: ShellRun("calc1.exe") ; Calc
!CapsLock:: cmdInCurrentFolder() ; CMD - WT
^!CapsLock:: cmdInCurrentFolder(,, True) ; CMD - WT
+!CapsLock:: cmdInCurrentFolder(, "-p bash") ; WSL - WT
#!CapsLock:: cmdInCurrentFolder(, "-p powershell") ; Powershell - WT
;^!CapsLock:: runSSH() ; SSH
; CapsLock, +CapsLock, +^CapsLock are used elsewhere
#F1:: Send {F1} ; Convert #F1 => F1
Volume_Up:: ; Popup for volume
Volume_Down::
changeVolume({Volume_Up: 1, Volume_Down:-1}[A_ThisHotkey])
return
/*
Volume_Up:: ; fn+Arrow = Volume
Volume_Down::
Volume_Up Up::
Volume_Down Up::
Media_Play_Pause::
Media_Stop::
Suspend, Permit
if inStr(A_ThisHotkey, "Volume") {
if inStr(A_ThisHotkey, " Up")
send {Media_Play_Pause}
} else {
changeVolume({Media_Stop: 1, Media_Play_Pause:-1}[A_ThisHotkey])
}
return
^Media_Play_Pause::
^Media_Stop::
changeVolumeBalance({ Media_Play_Pause:-.1, Media_Stop:.1 }[subStr(A_ThisHotkey, 2)])
return
*/
#WheelUp::changeVolume(1) ; Volume controls
#WheelDown::changeVolume(-1)
#^WheelUp::
#^WheelDown::
prefixUsed("Win")
changeVolumeBalance(inStr(A_ThisHotkey, "Up")? .1:-.1)
return
#F5:: dimScreen(+10) ; DimScreen
#F6:: dimScreen(-10)
#c:: makeMicroWindow() ; MicroWindow
#f:: listOpenFolders() ; List all open folders
#w:: winAction.show() ; winAction
#`:: runTextObj.showGUI() ; runText
^`::activateProgram(PRG_RS_Clipboard) ; Ditto
#^e:: watchExplorerWindows.recover() ; Recover Explorer Window
#v:: activateProgram(PRG_RS_VideoPlayer) ; Open VideoPlayer
;#r:: activateProgram(PRG_RS_Run) ; Run => Launcher
PrintScreen::activateProgram(PRG_RS_Screenshot)
#m:: winAction.bind_Window() ? winAction.trayIt() ; TrayIt
#t:: Menu, trayIt, Show ; TrayIt Menu
#^c::clipboardBuffer(True)
#^v::clipboardBuffer()
!^v::sendraw % Clipboard
#if Explorer_getActiveWindow() ; Move Files to Common Folder
#n:: moveFilesToCommonFolder(strSplit(getSelectedText({path:True}),"`n","`r"))
#^x:: unZipAndDeleteFromExplorer(Explorer_getActiveWindow()) ; Unzip open Zip file and delete it
#if
~RAlt & RCtrl:: ; Temporarily reduce Volume
~RCtrl & RAlt::
toggleVolume(.5, strSplit(A_ThisHotkey," ")[3])
return
#F10:: ; Global controls for Music player
#Media_Play_Pause::
activateProgram(PRG_RS_MusicPlayer)
return
/*
#if ProcessExist(PRG_RS_MusicPlayer.process)
#F9:: Media_Prev
#F11:: Media_Next
; MusicBee sometimes doesn't respond to Media buttons.
; So I set it's global hotkey to #{F9/10/11}
Media_Prev:: send #{F9}
Media_Play_Pause:: send #{F10}
Media_Next:: send #{F11}
#if
*/
;+^Space:: YouTubePlayPause() ; Play/Pause Youtube
return
;=================== Script Functions - Tray/Pause/Reload/Exit
RETURN
#+t::
updateTray(0, A_ScreenHeight-200)
sleep, 300
Menu, Tray, Show
return
#+p::
Suspend, Permit
SCR_Pause()
return
#+r:: Reload
#+q:: ExitApp
return