-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathfaststring.ahk
71 lines (53 loc) · 1.19 KB
/
faststring.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
#SingleInstance force
_list_hotstring := ComObjCreate("Scripting.Dictionary")
_UpFirst(input)
{
input := RegExReplace(input, "([^a-zA-Z]*)([a-z])?(.*)" , "$1$U2$3")
return input
}
_UpAll(input)
{
StringUpper, input, input
return input
}
dispatchHotstring()
{
global _list_hotstring
key:=trim(A_ThisHotKey)
macro:=_list_hotstring.item(key)
StringRight, lastChar, macro, 1
if(A_EndChar!=lastChar)
{
macro:=macro A_EndChar
}
ClipBoard:=macro
Send ^v
}
addHotstring(key, val)
{
global _list_hotstring
; strip key of "::" if present
key := RegExReplace(key, "(:\w*:)?(\w+)" , "$2")
if(Trim(key)="")
{
MsgBox addHotstring::registering empty key is not allowed
return
}
; key with first [a-z] letter in upper case
keyu1 := ":CX:" _UpFirst(key)
; key with everything in upper case
keyuall := ":CX:" _UpAll(key)
; default catchall key
keydefault := ":X:" key
if(keyu1==keyuall)
{
}else
{
_list_hotstring.item(keyuall) := _UpAll(val)
Hotstring(keyuall , "dispatchHotstring", On)
}
_list_hotstring.item(keyu1) := _UpFirst(val)
_list_hotstring.item(keydefault) := val
Hotstring(keyu1 , "dispatchHotstring", On)
Hotstring(keydefault , "dispatchHotstring", On)
}