-
Notifications
You must be signed in to change notification settings - Fork 5
/
Togglekeys.ahk
58 lines (53 loc) · 1.77 KB
/
Togglekeys.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
CapsLockOffTimer(t:=60000){
if (A_TimeIdleKeyboard>t) AND GetKeyState("CapsLock","T") {
SetCapsLockState,Off
Toast.show("CapsLock Turned Off")
return True
}
return False
}
class caseMenu{
__new(){
for _, j in [["U","&UPPER CASE"],["L","&lower case"],["T","&Title Case"],["S","&Sentence case."],["I","&iNVERT cASE"]] {
act:=ObjBindMethod(this,"caseChange",j[1])
Menu, caseMenu, Add, % j[2], % act
}
Menu, caseMenu, Add
for _, i in ["&Capslock","&Numlock","Sc&rollLock","I&nsert"] {
act:=ObjBindMethod(this,"toggle",strReplace(i,"&"))
Menu, caseMenu, Add, % i, % act
}
return
}
show(){
Toast.show("caseMenu")
; sleep, 500
for _, i in ["&Capslock","&Numlock","Sc&rollLock","I&nsert"]
Menu, caseMenu, % GetKeyState(strReplace(i,"&"),"T")?"Check":"Uncheck", % i
Menu, caseMenu, show
return
}
caseChange(type){ ; type: U=UPPER, L=Lower, T=Title, S=Sentence, I=Invert
text:=str_caseChange(getSelectedText(), type)
oldClip:=ClipboardAll
clipboard:=text
Send ^v
sleep 100
Clipboard:=oldClip
return
}
toggle(key){
if key=Insert
Send, {Insert}
else if key=Capslock
SetCapsLockState, % GetKeyState("CapsLock","T")?"Off":"On"
else if key=Numlock
SetNumLockState, % GetKeyState("NumLock","T")?"Off":"On"
else if key=Scrolllock
SetScrollLockState, % GetKeyState("ScrollLock","T")?"Off":"On"
return
}
}
Togglekeys_check(){
return {c:getkeyState("Capslock","T"), n:getkeyState("Numlock","T"), s:getkeyState("ScrollLock","T"), i:getkeyState("Insert","T")}
}