convert text first letter of multiple words to upper case

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
kwstas13
Posts: 43
Joined: 19 Mar 2016, 06:26

convert text first letter of multiple words to upper case

Post by kwstas13 » 09 Apr 2016, 10:02

hello I found this script from robertcollier4 that capitalize the selected text with f1

Code: Select all

SendMode Input  ; Forces Send and SendRaw to use SendInput buffering for speed.

;Replace selected text with uppercase
f1::
	Clipboard = ; Empty the clipboard so that ClipWait has something to detect
	SendInput, ^c ;copies selected text
	ClipWait
	StringReplace, OutputText, Clipboard, `r`n, `n, All ;Fix for SendInput sending Windows linebreaks 
	StringUpper, OutputText, OutputText
	SendRaw % OutputText
        VarSetCapacity(OutputText, 0) ;free memory
Return
but how I can make this to convert the first letter (only) of the word to capital?
so if I select a text and press f2 for example the word welcome to be converted as Welcome. Any idea ?Thanks
Last edited by kwstas13 on 09 Apr 2016, 10:56, edited 1 time in total.

User avatar
menteith
Posts: 51
Joined: 04 Feb 2016, 12:22

Re: convert text first letter of the word to upper case

Post by menteith » 09 Apr 2016, 10:09

Use:

Code: Select all

StringUpper, OutputText, OutputText, T
An ordinary user who needs some help with developing own programs for his own use.

User avatar
kwstas13
Posts: 43
Joined: 19 Mar 2016, 06:26

Re: convert text first letter of the word to upper case

Post by kwstas13 » 09 Apr 2016, 10:35

menteith wrote:Use:

Code: Select all

StringUpper, OutputText, OutputText, T
well its ok but this works only for one word and not for multiple
the script I found works for multiple any other idea ?

garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: convert text first letter of multiple words to upper case

Post by garry » 09 Apr 2016, 14:28

it works like user 'menteith' mentioned
mark text and use F2

Code: Select all

$F2::
Clipboard:=""
sendinput, ^c{right}
clipwait,2
b:=clipboard
StringUpper, c, b ,T
msgbox,%c%
b=
c=
clipboard=
return

an example for wikipedia

Code: Select all

b=li xIAng lAn
StringUpper, c, b ,T
StringReplace, c , c , %A_space%, _, All
run,https://en.wikipedia.org/wiki/%c%
exitapp

User avatar
HinkerLoden
Posts: 93
Joined: 23 Mar 2016, 07:50
Contact:

Re: convert text first letter of multiple words to upper case

Post by HinkerLoden » 09 Apr 2016, 16:11

StringCaseSense, On ;|Off|Locale

Got some problems with that too. Is now added in the Template i design atm.

Code: Select all

;************************************************
; AHK _ SCRIPT STRUCTURE TEMPLATE v1.1
; by HinkerLoden
; 25/03/2016 
; OS  			--> 	Win 10 / etc. 
;AHK Version	-->		1.1.23.05 
;************************************************

;************************************************
;Script Global Settings
;************************************************

#NoEnv						; Clear All Systemvariables 
#Persistent 				;Keeps a script permanently running until ExitApp execute

#SingleInstance force		;The word FORCE skips the dialog box and replaces the old instance automatically, which is similar in effect to the Reload command.

;************************************************
;Performance PARAMETERS - if you need speed 
;************************************************
;SetBatchLines, -1   		
;Process, Priority, , L  ;A  - Max Speed
;************************************************
; Input PARAMETERS
;************************************************
SendMode Input					;Default = Event , Play - for Speed -> Set Keydelay to -1 & Setmousedely to -1 
;----
SetKeyDelay, 10, 10   			; for speed -1, -1, 
SetMouseDelay, 25				;0 recommend   /  -1 for max speed 
SetDefaultMouseSpeed, 0			;0-100 
;************************************************
;History Protocols 
;Switch setting for more Speed 
;************************************************
#KeyHistory 1					;  0 - No Keyhistory 
ListLines  On  					; Off  - for more speed 
;************************************************
;Window detection
;************************************************
SetTitleMatchMode, 2
SetTitleMatchMode Fast			;slow detect hidden windows

SetWinDelay, 200  				;0 - for more speed 

;StringCaseSense, On|Off|Locale
;DetectHiddenWindows, On		; | Off   
;i double the standard settings to be on the save side 
;#######################				#######################
; Script Parameter
;#######################				#######################

SetWorkingDir %A_ScriptDir%  	;Ensures a consistent starting directory.

;#Include %A_ScriptDir%\YourLibrarys2integrate.ahk

CoordMode, Pixel, Screen		;relative/Window - active Window
CoordMode, Mouse, Screen

;WinMinimizeAll					;Optional

;#######################				#######################
; Try to avoid pure numbers inside the code - adress all Vars here
;=============================================================
; 						Variable Section
;=============================================================
;#######################				#######################
;global / static
;EnvUpdate ; --> Notifies the OS and all running applications that environment variable(s) have changed. 
;#######################				#######################

;===============================  TimerVars
Variable_01	=	
Variable_02	=	
Variable_03	=	
Variable_04	=	
Variable_05	=	
Variable_06	=	
Variable_07	=	
Variable_08	=	
Variable_09	=	
Variable_10	=	
;#######################				#######################
;=============================================================
; 						CODE 
;=============================================================
;#######################				#######################

 
 
;=============================================================
; 						GUI 
;=============================================================
;=============================================================

;#######################				#######################

;=============================================================






;=============================================================
; 						gLabel 
;=============================================================
;ButtonX
;=============================================================
;EditX
;=============================================================
;
;=============================================================


;=============================================================
; 						TIMER 
;=============================================================
;TimerX
;=============================================================
return

; Timer2
;=============================================================
Timer2:
 
return
 
;=============================================================
; 						HOTKEYS 
;=============================================================




; Hotkey1
;=============================================================






; Hotkey2
;=============================================================




; Exit 
;=============================================================
Exit:
!x::  ; Hotkey ALT+x.
GuiEscape:
GuiClose:
 ExitApp


 
;#######################				#######################
;=============================================================
; 						FUNCTIONS 
;=============================================================
;#######################				#######################


User avatar
kwstas13
Posts: 43
Joined: 19 Mar 2016, 06:26

Re: convert text first letter of multiple words to upper case

Post by kwstas13 » 09 Apr 2016, 17:48

Alright really thank you guys I save the scripts for future use. I found textpad editor that actually can do these functions. It's good to know how these functions work. I appreciate your help and time.

SifJar
Posts: 398
Joined: 11 Jan 2016, 17:52

Re: convert text first letter of multiple words to upper case

Post by SifJar » 10 Apr 2016, 18:08

HinkerLoden wrote:Got some problems with that too. Is now added in the Template i design atm.
What a ridiculously long & complicated script to post for something so simple.

garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: convert text first letter of multiple words to upper case

Post by garry » 11 Apr 2016, 01:37

it's a template

SifJar
Posts: 398
Joined: 11 Jan 2016, 17:52

Re: convert text first letter of multiple words to upper case

Post by SifJar » 11 Apr 2016, 08:20

garry wrote:it's a template
Yes, I can read. But that is still stupidly complex. IMO one of the best things about AHK is it's simplicity, and how you can do very impressive things with only a few lines of code. If you were to use a template like that for every script, you've instantly got an unwieldy and ugly long script, for very little real benefit. In addition, you're setting a bunch of stuff that you are probably only going to use in a small fraction of your scripts, which is pointless and inefficient.

garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: convert text first letter of multiple words to upper case

Post by garry » 11 Apr 2016, 11:32

remembers me Y2K problem, how to save expensive memory
https://en.wikipedia.org/wiki/Year_2000_problem
...Many tricks were used to squeeze needed data into fixed-field 80-character records.
Saving two digits for every date field was significant in this effort.
In the 1960s, computer memory and mass storage were scarce and expensive...
ok, understand what you mean ( ... the best things about AHK is it's simplicity ... )

jim7181812
Posts: 16
Joined: 10 Jun 2016, 10:46

Re: convert text first letter of multiple words to upper case

Post by jim7181812 » 28 Jun 2016, 10:20

Anyone have a script that will make the first letter of every sentence capitalize? Say I type out a bunch of private notes into notepad then want to make it public so I want to properly edit it and capitalize. Is there a script that will do this for me?

Guest

Re: convert text first letter of multiple words to upper case

Post by Guest » 28 Jun 2016, 12:57

If you search you will find a few solutions, i just googled convert text to sentences autohotkey:
https://autohotkey.com/board/topic/7162 ... e-utility/
https://autohotkey.com/board/topic/2443 ... -inverted/
https://autohotkey.com/board/topic/51153-sentence-case/

Read the threads for various solutions (in the last one there is a nice one by laszlo for example)

Happy Searching! :dance: :beer: 8-) :lol: ;) :superhappy:

jim7181812
Posts: 16
Joined: 10 Jun 2016, 10:46

Re: convert text first letter of multiple words to upper case

Post by jim7181812 » 28 Jun 2016, 13:15

!^k:: ; Sentence case
StringLower, Clipboard, Clipboard
Clipboard := RegExReplace(Clipboard, "((?:^|[.!?]\s+)[a-z])", "$u1")
Send %Clipboard%
RETURN

thats what i was looking for, thank you guest

Post Reply

Return to “Ask for Help (v1)”