AutoHotkey: Upper & lower letters of selected text

Luis Diaz
Luis Diaz used Ask the Experts™
on
Hello experts,

The following AutoHotkey allows me to add initial character for each line of selected text.

^+-::
Send, ^c
Sleep, 50
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error, No text appearing after one second
  Return
}
ClipboardVar:=Clipboard
UpdatedLines:=""
Loop,Parse,ClipboardVar,`n,`r
  UpdatedLines:=UpdatedLines . "-" . A_LoopField . "`n"
Clipboard:=UpdatedLines
Sleep, 50
MsgBox,4160,Success,Your clipboard has been properly copied., 2
Return

Open in new window


I would like to take as a reference in order to set up two AutoHotkey scripts:
1-Upper the various letters of selected text.
2-Lower the various letters of selected text.

If you have questions, please contact me.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Developer
Fellow 2017
Most Valuable Expert 2018
Commented:
Hi Luis,
Using the code that you posted, here are AutoHotkey hotkeys that do what you want:

^+u:: ; Ctrl+Shift+U - make upper case
Send, ^c
Sleep, 50
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error, No text appearing after one second
  Return
}
ClipboardVar:=Clipboard
UpdatedLines:=""
Loop,Parse,ClipboardVar,`n,`r
  UpdatedLines:=UpdatedLines . "-" . A_LoopField . "`n"
StringUpper,Clipboard,UpdatedLines
Sleep, 50
MsgBox,4160,Success,Your clipboard has been properly copied., 2
Return

^+l:: ; Ctrl+Shift+L - make lower case
Send, ^c
Sleep, 50
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error, No text appearing after one second
  Return
}
ClipboardVar:=Clipboard
UpdatedLines:=""
Loop,Parse,ClipboardVar,`n,`r
  UpdatedLines:=UpdatedLines . "-" . A_LoopField . "`n"
StringLower,Clipboard,UpdatedLines
Sleep, 50
MsgBox,4160,Success,Your clipboard has been properly copied., 2
Return

Open in new window

I simply added one line to each — StringLower and StringUpper. As always, make the hotkeys whatever you want. You may safely include these in your main hotkeys/hotstrings script as long as you select unique hotkeys for them. Regards, Joe
Luis DiazIT consultant

Author

Commented:
Hi Joe,
Thank you very much for this proposal. Unable to test right now. I will keep you informed.
Luis DiazIT consultant

Author

Commented:
Hi Joe,
I tested and it works.
If I want to directly send the clipboard with a paste and without "-" , can I proceed like this?:

^+u:: ; Ctrl+Shift+U - make upper case
Send, ^c
Sleep, 50
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error, No text appearing after one second
  Return
}
ClipboardVar:=Clipboard
UpdatedLines:=""
Loop,Parse,ClipboardVar,`n,`r
  UpdatedLines:=UpdatedLines . A_LoopField . "`n"
StringUpper,Clipboard,UpdatedLines
Sleep, 50
Send, ^v
Return

^+l:: ; Ctrl+Shift+L - make lower case
Send, ^c
Sleep, 50
ClipWait,1
If (ErrorLevel=1)
{
  MsgBox,4144,Error, No text appearing after one second
  Return
}
ClipboardVar:=Clipboard
UpdatedLines:=""
Loop,Parse,ClipboardVar,`n,`r
  UpdatedLines:=UpdatedLines . A_LoopField . "`n"
StringLower,Clipboard,UpdatedLines
Sleep, 50
Send, ^v
Return

Open in new window


Thank you for your help.
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018

Commented:
> can I proceed like this?

Yes. Tested here in Notepad++ with the latest AutoHotkey version — works fine! Regards, Joe
Luis DiazIT consultant

Author

Commented:
Thank you Joe for your feedback.
Joe WinogradDeveloper
Fellow 2017
Most Valuable Expert 2018

Commented:
As always, Luis, you're very welcome. Cheers, Joe

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial