Issue: Converting a text from lowercase to uppercase Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
racer
Posts: 29
Joined: 07 May 2022, 15:02

Issue: Converting a text from lowercase to uppercase

Post by racer » 26 May 2022, 18:15

Good evening!
I have a script that if I press and hold the LShift, it converts selected text from lowercase to all caps and paste an exclamation mark at the end of the text (TEXT!), and finally makes the first letter of the next word as a capital letter (TEXT! Text). If I press the LShift and releases it, it just converts selected text from lowercase to all caps with an exclamation mark (TEXT!)

Code: Select all

*LShift::
;(and ⇒ AND!)
	KeyWait, LShift, T0.20
  if (ErrorLevel = 1){
  Clipboard := ""
  SendInput, ^c 
  ClipWait
  StringUpper Clipboard, Clipboard
  clipboard=%clipboard%   
  SendInput %clipboard%{!} ` ;clipboard and space 
; Selects word to the right and upper case
  Clipboard := ""     ; Clears the Clipboard
  SendInput ^+{Right}  
  Sleep, 10
  SendInput ^c   
  ClipWait 0 ;pause for Clipboard data
  StringUpper, Clipboard, Clipboard, T  ; Cap first char (Title)
  SendInput %Clipboard%
}
	else
 {
 ;(and ⇒ AND)		
  Clipboard := ""
  SendInput, ^c 
  ClipWait
  StringUpper Clipboard, Clipboard
  SendInput %Clipboard%
		}
return
The problem is that when I press the LShift and it does it's job, and when I select some text then, it suddenly converts again the selected text from lowercase to all caps, which is very annoying. I found out that it is because the script somehow continues after "else" and executes that final part of the script

Rohwedder
Posts: 7551
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Issue: Converting a text from lowercase to uppercase  Topic is solved

Post by Rohwedder » 27 May 2022, 00:00

Hallo,
try:

Code: Select all

*LShift::
;(and ⇒ AND!)
	KeyWait, LShift, T0.20
  if (ErrorLevel = 1){
  Clipboard := ""
  SendInput, ^c 
  ClipWait
  StringUpper Clipboard, Clipboard
  clipboard=%clipboard%   
  SendInput %clipboard%{!} ` ;clipboard and space 
; Selects word to the right and upper case
  Clipboard := ""     ; Clears the Clipboard
  SendInput ^+{Right}  
  Sleep, 10
  SendInput ^c   
  ClipWait 0 ;pause for Clipboard data
  StringUpper, Clipboard, Clipboard, T  ; Cap first char (Title)
  SendInput %Clipboard%
}
	else
 {
 ;(and ⇒ AND)		
  Clipboard := ""
  SendInput, ^c 
  ClipWait
  StringUpper Clipboard, Clipboard
  SendInput %Clipboard%
		}
KeyWait, LShift ;<<< added
return

racer
Posts: 29
Joined: 07 May 2022, 15:02

Re: Issue: Converting a text from lowercase to uppercase

Post by racer » 27 May 2022, 09:01

Rohwedder wrote:
27 May 2022, 00:00
Hallo,
try:

Code: Select all

*LShift::
;(and ⇒ AND!)
	KeyWait, LShift, T0.20
  if (ErrorLevel = 1){
  Clipboard := ""
  SendInput, ^c 
  ClipWait
  StringUpper Clipboard, Clipboard
  clipboard=%clipboard%   
  SendInput %clipboard%{!} ` ;clipboard and space 
; Selects word to the right and upper case
  Clipboard := ""     ; Clears the Clipboard
  SendInput ^+{Right}  
  Sleep, 10
  SendInput ^c   
  ClipWait 0 ;pause for Clipboard data
  StringUpper, Clipboard, Clipboard, T  ; Cap first char (Title)
  SendInput %Clipboard%
}
	else
 {
 ;(and ⇒ AND)		
  Clipboard := ""
  SendInput, ^c 
  ClipWait
  StringUpper Clipboard, Clipboard
  SendInput %Clipboard%
		}
KeyWait, LShift ;<<< added
return
thanks a lot

Post Reply

Return to “Ask for Help (v1)”