summaryrefslogtreecommitdiff
path: root/_windows/ahk/capslock.ahk
blob: 85f81e46824878b4483055330f00838a816bcd9e (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
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
#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
ShiftLockState := 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]
}

#HotIf GetKeyState("CapsLock", "P")
\::{
    global CapsLockState := not CapsLockState
    SetCapsLockState CapsLockState
}
Enter::{
    global ShiftLockState := not ShiftLockState
    if ShiftLockState {
        SendInput "{LShift Down}"
    } else {
        SendInput "{LShift Up}"
    }
}
+Enter::{
    global ShiftLockState := not ShiftLockState
    if ShiftLockState {
        SendInput "{LShift Down}"
    } else {
        SendInput "{LShift Up}"
    }
}

; vim motion
h::Left
j::Down
k::Up
l::Right

y::^Left
u::^Down
i::^Up
o::^Right

n::Home
m::PgDn
,::PgUp
.::End

; vim motion w select
+h::+Left
+j::+Down
+k::+Up
+l::+Right

+y::^+Left
+u::^+Down
+i::^+Up
+o::^+Right

+n::+Home
+m::+PgDn
+,::+PgUp
+.::+End

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

Esc::Run "taskmgr"

; window manipulation
!h::#Left
!j::#Down
!k::#Up
!l::#Right

!y::#+Left
!u::#+Down
!i::#+Up
!o::#+Right

; desktop switching
!,::^#Left
!m::^#Right

q::Esc
#HotIf

CapsLock::{
    KeyWait "CapsLock"
    if A_ThisHotkey = "CapsLock" {
        Send "{Escape}"
    }
}

!CapsLock::{
    return
}
^CapsLock::{
    return
}
^!CapsLock::{
    return
}
+CapsLock::{
    return
}

Esc::F13