Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CapsLock:: ; the invoking key
- SetCapsLockState, Off ; turn it off right away because no one wants that
- oldClipboard := Clipboard ; we're mucking with the clipboard, so save for later
- Send, {ctrl down}c{ctrl up} ; copy whatever we have selected
- if (StrLen(Clipboard) = 0) { ; empty clipboard, get out fast
- Clipboard := oldClipboard ; reset clipboard
- exit
- }
- StringUpper, uppered, Clipboard ; used a couple times so made a variable
- StringLower, lowered, Clipboard ; ditto
- if (lowered == Clipboard) ; if we're the lower case version of the selection
- Clipboard := uppered ; upper case it
- else if (uppered == Clipboard) ; if we're the upper case version for the selection
- Clipboard := RegExReplace(lowered, "((?:^|[.!?]\s+)[a-z])", "$u1") ; sentence case it http://www.autohotkey.com/board/topic/24431-convert-text-uppercase-lowercase-capitalized-or-inverted/
- else ; otherwise
- Clipboard := lowered ; lower case it
- Send, {ctrl down}v{ctrl up} ; paste what we just altered
- selectionLength := StrLen(Clipboard); get the string length
- Send, {shift down}{Left %selectionLength%}{shift up}; select the n characters to the left of the paste
- Clipboard := oldClipboard ; put the old clipboard back
Advertisement
Add Comment
Please, Sign In to add comment