Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;-Change Text Case-----------------------------------------
- cycleNumber := 1
- #IfWinNotActive ahk_class XLMAIN
- ^t::
- If (cycleNumber==1)
- {
- ConvertUpper()
- cycleNumber:= 2
- }
- Else If (cycleNumber==2)
- {
- ConvertLower()
- cycleNumber:= 3
- }
- Else If (cycleNumber==3)
- {
- ConvertTitleCase()
- cycleNumber:= 4
- }
- Else
- {
- ConvertSentence()
- cycleNumber:= 1
- }
- Return
- ConvertUpper()
- {
- clipSave := Clipboard
- Clipboard = ; Empty the clipboard so that ClipWait has something to detect
- SendInput, ^c ;copies selected text
- ClipWait
- StringReplace, Clipboard, Clipboard, `r`n, `n, All ;Fix for SendInput sending Windows linebreaks
- StringUpper, Clipboard, Clipboard
- Len:= Strlen(Clipboard)
- SendInput, ^v ;pastes new text
- Send +{left %Len%}
- Clipboard := clipSave
- }
- ConvertLower()
- {
- clipSave := Clipboard
- Clipboard = ; Empty the clipboard so that ClipWait has something to detect
- SendInput, ^c ;copies selected text
- ClipWait
- StringReplace, Clipboard, Clipboard, `r`n, `n, All ;Fix for SendInput sending Windows linebreaks
- StringLower, Clipboard, Clipboard
- Len:= Strlen(Clipboard)
- SendInput, ^v ;pastes new text
- Send +{left %Len%}
- Clipboard := clipSave
- }
- ConvertTitleCase()
- {
- clipSave := Clipboard
- Clipboard = ; Empty the clipboard so that ClipWait has something to detect
- SendInput, ^c ;copies selected text
- ClipWait
- StringReplace, Clipboard, Clipboard, `r`n, `n, All ;Fix for SendInput sending Windows linebreaks
- StringLower, Clipboard, Clipboard, T
- Len:= Strlen(Clipboard)
- SendInput, ^v ;pastes new text
- Send +{left %Len%}
- Clipboard := clipSave
- }
- ConvertSentence()
- {
- clipSave := Clipboard
- Clipboard = ; Empty the clipboard so that ClipWait has something to detect
- SendInput, ^c ;copies selected text
- ClipWait
- StringReplace, Clipboard, Clipboard, `r`n, `n, All ;Fix for SendInput sending Windows linebreaks
- StringLower, Clipboard, Clipboard
- Clipboard := RegExReplace(Clipboard, "(((^|([.!?]+\s+))[a-z])| i | i')", "$u1")
- Len:= Strlen(Clipboard)
- SendInput, ^v ;pastes new text
- Send +{left %Len%}
- VarSetCapacity(OutputText, 0) ;free memory
- Clipboard := clipSave
- }
- #IfWinNotActive
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement