-
Notifications
You must be signed in to change notification settings - Fork 0
/
CapsLockRemap.ahk
69 lines (55 loc) · 1.52 KB
/
CapsLockRemap.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
#Requires AutoHotkey v2.0
#UseHook
; We don't send any letters and this prevents Send "{CapsLock}" from toggling capslock when true
SetStoreCapsLockMode False
global iniFilePath := A_ScriptDir . "/capsLockMap.ini"
if not (FileExist(iniFilePath)) {
IniWrite 0, iniFilePath, "state", "CapsOption"
}
global CapsOption := IniRead(iniFilePath, "state", "CapsOption")
NextOption()
{
global CapsOption
CapsOption += 1
if (CapsOption > 3) {
CapsOption := 1
}
if (CapsOption == 1) {
MsgBox "CapsLock bound to Esc"
} else if (CapsOption == 2) {
MsgBox "CapsLock bound to Ctrl"
} else if (CapsOption == 3) {
MsgBox "CapsLock bound to CapsLock"
}
IniWrite CapsOption, iniFilePath, "state", "CapsOption"
}
Esc & CapsLock::NextOption()
Esc::Esc
*CapsLock::
{
global CapsOption
if (CapsOption == 1) {
Send "{Esc down}"
KeyWait "CapsLock"
Send "{Esc up}"
} else if (CapsOption == 2) {
Send "{Ctrl down}"
KeyWait "CapsLock"
Send "{Ctrl up}"
} else if (CapsOption == 3) {
Send "{CapsLock}"
}
}
CapsMenuSelect(Name, Item, *) {
global CapsOption
CapsMenu.Uncheck(CapsOption . "&")
CapsOption := Item
CapsMenu.Check(Item . "&")
}
CapsMenu := Menu()
CapsMenu.Add("Esc", CapsMenuSelect, "+Radio")
CapsMenu.Add("Ctrl", CapsMenuSelect, "+Radio")
CapsMenu.Add("Caps", CapsMenuSelect, "+Radio")
CapsMenu.Check(CapsOption . "&")
A_TrayMenu.Insert("2&", "Caps Remap", CapsMenu)
TraySetIcon "capslock_dark.png"