summaryrefslogtreecommitdiff
path: root/_windows/ahk/capslock.ahk
blob: e9e4ff00b141d2d6ee66d358ce6f71a6b8cf7aea (plain)
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
#Requires AutoHotkey v2
#SingleInstance Force

GroupAdd("IDE", "ahk_exe rider64.exe")
GroupAdd("IDE", "ahk_exe code.exe")
GroupAdd("IDE", "ahk_exe code-insiders.exe")
GroupAdd("IDE", "ahk_exe webstorm64.exe")
GroupAdd("IDE", "ahk_exe devenv.exe")

GroupAdd("Browser", "ahk_exe msedge.exe")
GroupAdd("Browser", "ahk_exe firefox.exe")

CapsLockState := false
HarpoonLastWindowIndex := 0

HarpoonRun(winTitle) {
    SetTitleMatchMode 2
    DetectHiddenWindows false

    windows := WinGetList(winTitle)

    if windows.Length = 0 {
        return
    }

    if WinActive(winTitle) {
        global HarpoonLastWindowIndex := Mod((HarpoonLastWindowIndex + 1), windows.Length)
    } else {
        global HarpoonLastWindowIndex := 0
    }

    WinActivate windows[HarpoonLastWindowIndex + 1]
}

CapsLock::LCtrl
<^[::Esc

RAlt & `::HarpoonRun("ahk_exe WindowsTerminal.exe")
RAlt & 1::HarpoonRun("ahk_exe Discord.exe")
RAlt & 2::HarpoonRun("ahk_group IDE")
RAlt & 3::HarpoonRun("ahk_group Browser")
RAlt & 4::HarpoonRun("ahk_exe Element.exe")
RAlt & 5::HarpoonRun("ahk_exe code.exe")
RAlt & 0::HarpoonRun("ahk_exe WINWORD.EXE")
RAlt & 9::HarpoonRun("ahk_class CabinetWClass")

RAlt & k::Send "#{Up}"
RAlt & j::Send "#{Down}"
RAlt & \::{
    global CapsLockState := not CapsLockState
    SetCapsLockState CapsLockState
}

Tab & h::Left
Tab & j::Down
Tab & k::Up
Tab & l::Right
Tab::Tab

RCtrl & Backspace::Reload