-
Notifications
You must be signed in to change notification settings - Fork 0
/
ctrl_caps_as_case_change.ahk
87 lines (77 loc) · 2.07 KB
/
ctrl_caps_as_case_change.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
; ctrl+capslock to show text case change menu
; run script as admin (reload if not as admin)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#SingleInstance Force
SetTitleMatchMode 2
GroupAdd All
Menu Case, Add, &UPPERCASE, CCase
Menu Case, Add, &lowercase, CCase
Menu Case, Add, &Title Case, CCase
Menu Case, Add, &Sentence case, CCase
Menu Case, Add
Menu Case, Add, &Fix Linebreaks, CCase
Menu Case, Add, &Reverse, CCase
^CapsLock::
GetText(TempText)
If NOT ERRORLEVEL
Menu Case, Show
Return
CCase:
If (A_ThisMenuItemPos = 1)
StringUpper, TempText, TempText
Else If (A_ThisMenuItemPos = 2)
StringLower, TempText, TempText
Else If (A_ThisMenuItemPos = 3)
StringLower, TempText, TempText, T
Else If (A_ThisMenuItemPos = 4)
{
StringLower, TempText, TempText
TempText := RegExReplace(TempText, "((?:^|[.!?]\s+)[a-z])", "$u1")
} ;Seperator, no 5
Else If (A_ThisMenuItemPos = 6)
{
TempText := RegExReplace(TempText, "\R", "`r`n")
}
Else If (A_ThisMenuItemPos = 7)
{
Temp2 =
StringReplace, TempText, TempText, `r`n, % Chr(29), All
Loop Parse, TempText
Temp2 := A_LoopField . Temp2
StringReplace, TempText, Temp2, % Chr(29), `r`n, All
}
PutText(TempText)
Return
; Handy function.
; Copies the selected text to a variable while preserving the clipboard.
GetText(ByRef MyText = "")
{
SavedClip := ClipboardAll
Clipboard =
Send ^c
ClipWait 0.5
If ERRORLEVEL
{
Clipboard := SavedClip
MyText =
Return
}
MyText := Clipboard
Clipboard := SavedClip
Return MyText
}
; Pastes text from a variable while preserving the clipboard.
PutText(MyText)
{
SavedClip := ClipboardAll
Clipboard = ; For better compatability
Sleep 20 ; with Clipboard History
Clipboard := MyText
Send ^v
Sleep 100
Clipboard := SavedClip
Return
}