Help Changing Capitalization In Listbox

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AlFlo
Posts: 345
Joined: 29 Nov 2021, 21:46

Help Changing Capitalization In Listbox

01 Dec 2021, 19:16

I have a listbox script to give me mix-and-match choices with numerous listboxes. But I'd like to be able to change the capitalization of the text generated by the script as needed.

Specifically, I sometimes need the text to be all capitals. While other times I need it to be lower case.

Is there a way to change the capitalization on-the-fly, by creating buttons which change the text output to all caps, or lowercase, etc. (Sentence case would also be nice)?

Here's my code:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#+r::Reload  ; Assign Win+Shift+R as a hotkey to restart the script.
     
; Win+Shift+A - list Assembly
#+a::



Gui Add, ListBox, w400 h180 Multi vAction,  PREPARE CORRESPONDENCE TO OPPOSING COUNSEL REGARDING|PREPARE CORRESPONDENCE TO CLIENT REGARDING|PREPARE CORRESPONDENCE TO REGARDING|REVIEW AND ANALYZE CORRESPONDENCE FROM OPPOSING COUNSEL REGARDING|REVIEW AND ANALYZE CORRESPONDENCE FROM CLIENT REGARDING|REVIEW AND ANALYZE CORRESPONDENCE FROM _ REGARDING|TELEPHONE CONFERENCE WITH OPPOSING COUNSEL REGARDING|TELEPHONE CONFERENCE WITH CLIENT REGARDING|TELEPHONE CONFERENCE WITH REGARDING|
Gui Add, ListBox, w400 h180 Multi V1,   PREPARE|REVIEW AND ANALYZE|REVISE AND EDIT|TELEPHONE CONFERENCE WITH|CONFERENCE CALL WITH|CONFERENCE WITH

Gui Add, ListBox, w200 h180 Multi vSpace  , {Space}|SAME
Gui Add, ListBox, wp   hp Multi V2  , I have some list choices here|I have some list choices here
Gui Add, ListBox, ym wp   hp Multi vDocument, CORRESPONDENCE |DOCUMENTS|COMPLAINT|ANSWER|CROSS-COMPLAINT|MEMORANDUM|COURT ORDER|RESPONSES TO|CONTRACT|AGREEMENT|SETTLEMENT AGREEMENT
Gui Add, ListBox, wp   hp Multi V3  , Please let me know if you have any questions or comments regarding the above-described matters.|Confidential Settlement Negotiations And Offer Protected by Cal. Evidence Code Sections 1152 and 1154  Because the purpose of this letter is to set forth a settlement proposal, this letter along with all offers to settle or compromise this matter and the negotiations relating thereto are considered inadmissible to prove liability under California Evidence Code Sections 1152 and 1154.
Gui Add, ListBox, ym wp   hp Multi vDisco, SPECIAL INTERROGATORIES|FORM INTERROGATORIES|REQUEST FOR PRODUCTION OF DOCUMENTS|REQUESTS FOR ADMISSIONS AND GENUINENESS OF DOCUMENTS|DEPOSITION TRANSCRIPT
Gui Add, ListBox, wp   hp Multi V4  , Code of Civil Procedure|Civil Code|Evidence Code|Corporations Code|Labor Code|Government Code|Family Law Code|
Gui Add, ListBox, ym wp   hp Multi vToFrom  , TO|FROM|OF|BY|FOR|REGARDING|BETWEEN|AMONG|PREPARED BY|ON BEHALF OF
Gui Add, ListBox, wp   hp Multi V5  , §|¶|§§|¶¶|©|®|Section|Paragrah
Gui Add, ListBox, ym wp   hp Multi vPerson  , OPPOSING COUNSEL FOR REGARDING|CLIENT REGARDING|ALL OPPOSING COUNSEL REGARDING 
Gui Add, ListBox, wp   hp Multi V6  , Breach of Contract|Negligence|Fraud|Intentional Misrepresentation|Breach of Fiduciary Duty|Unfair Competition|Trademark Infringement|Copyright Infringement|Breach of Covenant of Good Faith and Fair Dealing|Breach of Warranty|Intentional Interference with Contract|Negligenct Interference with Contract|Intentional Interference with Prospective Business Advantage|Negligent Interference with Prospective Business Advantage
Gui Add, ListBox, ym wp   hp Multi VParty  , PLAINTIFF|DEFENDANT|PETITIONER|RESPONDENT|Plaintiff|Defendant|Petitioner|Respondent
Gui Add, ListBox, wp   hp Multi V7  , I have some list choices here|I have some list choices here
Gui Add, ListBox, ym wp   hp Multi VNumber  , SET ONE|SET TWO|SET THREE|FIRST AMENDED|SECOND AMENDED|THIRD AMENDED|Number|No.
Gui Add, ListBox, wp   hp Multi V8  , I have some list choices here|I have some list choices here
Gui Add, ListBox, ym wp   hp Multi VClient  , I have some list choices here|I have some list choices here
Gui Add, ListBox, wp   hp Multi V9  , I have some list choices here|I have some list choices here

Gui, Show,, Test

;
Gui Font
Gui Add, Button, w100 h25 gInputExit, Exit
; Having issue with the code to insert both complaints and clicks 
; with 1 button... Do I Label section ComplaintDenies: and combine both inputs?
Gui Add, Button, x392 y450 w75 h23 gInputChartExit, Insert All 

::/uti::
Gui Show, w2000 h600, Window
Return
 
Action:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Action  ; Retrieve the ListBox's current selection.
; Send, !{Esc} ; ???
Sleep, 200
SendInput, %Action%
Return
 
InputUTI: 
Gui, Submit, NoHide
Send, !{Esc}
Sleep, 200
StringReplace, Action, Action, |,`,%A_Space%, All
SendInput, %Action%{Space} 
Gui, Hide
Return
   
Party:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Action  ; Retrieve the ListBox's current selection.
; Send, !{Esc} ; ???
Sleep, 200
SendInput, %Party%
Return
 
Gui, Submit, NoHide
Send, !{Esc}
Sleep, 200
StringReplace, Action, Action, |,`,%A_Space%, All
SendInput, %Party%{Space} 
Gui, Hide
Return

Document:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Document  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %Document%{Space}
 
 
InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, Document, Document, |,`,%A_Space%, All
SendInput, %Document%{Space}
Gui, Hide
Return
  
ToFrom:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, ToFrom  ; Retrieve the ListBox's current selection.
; Send, !{Esc} ; ???
Sleep, 200
SendInput, %ToFrom%
Return
 
;InputUTI: 
Gui, Submit, NoHide
Send, !{Esc}
Sleep, 200
StringReplace, ToFrom, ToFrom, |,`,%A_Space%, All
SendInput, %ToFrom%{Space} 
Gui, Hide
Return
   
Person:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Person  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %Person%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, Person, Person, |,`,%A_Space%, All
SendInput, %Person%{Space}
Gui, Hide
Return

Disco:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Disco  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %Disco%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, Disco, Disco, |,`,%A_Space%, All
SendInput, %Disco%{Space}
Gui, Hide
Return

Number:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Number  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %Number%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, Number, Number, |,`,%A_Space%, All
SendInput, %Number%{Space}
Gui, Hide
Return

Client:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Client  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %Client%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, Client, Client, |,`,%A_Space%, All
SendInput, %Client%{Space}
Gui, Hide
Return

Space:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Space  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %Space%{Space}
 
 
; InputDUTI: 
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, Space, Space, |,`,%A_Space%, All
SendInput, %Space%{Space}
Gui, Hide
Return
  
1:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Client  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %1%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, 1, 1, |,`,%A_Space%, All
SendInput, %1%
Gui, Hide
Return

2:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Client  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %2%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, 2, 2, |,`,%A_Space%, All
SendInput, %2%
Gui, Hide
Return

3:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Client  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %3%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, 3, 3, |,`,%A_Space%, All
SendInput, %3%
Gui, Hide
Return

4:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Client  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %4%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, 4, 4, |,`,%A_Space%, All
SendInput, %4%
Gui, Hide
Return

5:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Client  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %5%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, 5, 5, |,`,%A_Space%, All
SendInput, %5%
Gui, Hide
Return

6:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Client  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %6%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, 6, 6, |,`,%A_Space%, All
SendInput, %6%
Gui, Hide
Return

7:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Client  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %7%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, 7, 7, |,`,%A_Space%, All
SendInput, %7%
Gui, Hide
Return

8:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Client  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %8%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, 8, 8, |,`,%A_Space%, All
SendInput, %8%
Gui, Hide
Return

9:
if A_GuiControlEvent <> DoubleClick
	return
GuiControlGet, Client  ; Retrieve the ListBox's current selection.
;Send, !{Esc}
Sleep, 200
SendInput, %9%{Space}
 
 
;InputDUTI:
Gui, Submit, Hide
;Send, !{Esc}
Sleep, 200
; *LAlt::
; Send, {Space} ; This line sends keystrokes to the active (foremost) window.
StringReplace, 9, 9, |,`,%A_Space%, All
SendInput, %9%
Gui, Hide
Return

InputExit:
Gui, Submit, Hide
;Send, !{Esc}
Gui, Hide
Return
  
InputChartExit:
Gui, Submit, Hide 
StringReplace, Space, Space, |,`,%A_Space%, All
StringReplace, Document, Document, |,`,%A_Space%, All
StringReplace, ToFrom, ToFrom, |,`,%A_Space%, All
StringReplace, Person, Person, |,`,%A_Space%, All
StringReplace, Party, Party, |,`,%A_Space%, All
StringReplace, Disco, Disco, |,`,%A_Space%, All
StringReplace, Number, Number, |,`,%A_Space%, All
StringReplace, Client, Client, |,`,%A_Space%, All
StringReplace, 1, 1, |,`,%A_Space%, All
StringReplace, 2, 2, |,`,%A_Space%, All
StringReplace, 3, 3, |,`,%A_Space%, All
StringReplace, 4, 4, |,`,%A_Space%, All
StringReplace, 5, 5, |,`,%A_Space%, All
StringReplace, 6, 6, |,`,%A_Space%, All
StringReplace, 7, 7, |,`,%A_Space%, All
StringReplace, 8, 8, |,`,%A_Space%, All
StringReplace, 9, 9, |,`,%A_Space%, All

SendInput, %Action%
SendInput, %Space%
SendInput, %Document%
SendInput, %Space%
SendInput, %ToFrom%
SendInput, %Space%
SendInput, %Person%
SendInput, %Party%
SendInput, %Disco%
SendInput, %Number%
SendInput, %Client%
SendInput, %1%
SendInput, %2%
SendInput, %3%
SendInput, %4%
SendInput, %5%
SendInput, %6%
SendInput, %7%
SendInput, %8%
SendInput, %9%
Reload
Return
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: Help Changing Capitalization In Listbox

01 Dec 2021, 21:51

Format will get you whichever case you want. Your button can set a flag to indicate one of the cases. Sentence case usually just means that the first letter is uppercase, and the rest is lower.
AlFlo
Posts: 345
Joined: 29 Nov 2021, 21:46

Re: Help Changing Capitalization In Listbox

01 Dec 2021, 22:26

Thanks. I don't know where to add the flags. I tried adding buttons like this, but they don't work:

Code: Select all

 Gui Add, Button, x492 y550 w75 h23, Flag{:U}, UPPER 
; Gui Add, Button, x592 y550 w75 h23, Format{:L}, lower
; Gui Add, Button, x692 y550 w75 h23, Format{:T}, Title
And I tried adding this various places:

Code: Select all

Format("{:U}, {:L} and {:T}", "upper", "LOWER", "title")
And I tried having the button modify a sting, like this:

Code: Select all

InputUpper:
Gui, Submit, Hide 
StringReplace, 1, 1, |,Format{:U}, All
StringReplace, 2, 2, |,Format{:U}, All
StringReplace, 3, 3, |,Format{:U}, All
StringReplace, 4, 4, |,Format{:U}, All
StringReplace, 5, 5, |,Format{:U}, All
StringReplace, 6, 6, |,Format{:U}, All
StringReplace, 7, 7, |,Format{:U}, All
StringReplace, 8, 8, |,Format{:U}, All
StringReplace, 9, 9, |,Format{:U}, All
Sorry ... I obviously have no idea what I'm doing :)
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: Help Changing Capitalization In Listbox

02 Dec 2021, 06:21

Look at the example in the link that I posted.

You can use Format wherever you have text to format.

Code: Select all

Send % Format("{:T}", "EXIT")
Gui Add, Button, w100 h25 vb1, % Format("{:L}", "Exit")
Gui, Show
Sleep, 1000
SoundBeep, 1500
GuiControl,, b1, % Format("{:U}", "Exit")
Explained: FormatForce an expression
AlFlo
Posts: 345
Joined: 29 Nov 2021, 21:46

Re: Help Changing Capitalization In Listbox

02 Dec 2021, 16:00

Thanks. I've tried every combination I can think of, but nothing is working. For example, I tried adding this under the button-creation code:

Code: Select all

Gui Add, Button, w100 h25 vb1, % Format("{:L}", "Exit")
I tried adding this for the variable Document:

Code: Select all

StringReplace, Document, Document, NewStr, OldStr, Format{:L}, Format{:U}, All
And this for the variable Action:

Code: Select all

Send % Format("{:L}",action)
I tried adding this in the specific section regarding one of the variables:

Code: Select all

Send % Format("{:U}, {:L}!")
User avatar
mikeyww
Posts: 26882
Joined: 09 Sep 2014, 18:38

Re: Help Changing Capitalization In Listbox

02 Dec 2021, 16:21

With the following lines, what actually happens?

Code: Select all

Gui Add, Button, w100 h25 vb1, % Format("{:L}", "Exit")

Send % Format("{:L}", action)
What is the value of "action"? Show screenshots of the output.

Use a very short test script to demonstrate these techniques, and what the output is. Include the script here.

You can't make up your own syntax for Format. You have to use the AHK syntax. Stick with what is shown in the documentation. The function accepts the format as the first parameter, and the values as the subsequent parameters. If you provide no values, there is nothing to format.
AlFlo
Posts: 345
Joined: 29 Nov 2021, 21:46

Re: Help Changing Capitalization In Listbox

02 Dec 2021, 21:26

Thanks, I figured it out!

I have my buttons like this:

Code: Select all

Gui Add, Button, x300 y450 w75 h23 gInputChartExit, As-Is
Gui Add, Button, x500 y450 w75 h23 gInputChartExit3, % Format("{:T}", "Title")
Gui Add, Button, x900 y450 w75 h23 gInputChartExit1, % Format("{:L}", "lower")
Gui Add, Button, x700 y450 w75 h23 gInputChartExit2, % Format("{:U}", "UPPER")
Then I set up a set of SendInput commands for gInputChartExit, gInputChartExit1, gInputChartExit2 and gInputChartExit3, where all of the variable listed are plain vanilla for the As-Is version ("Action" is one of my variables):

Code: Select all

SendInput, %Action%
Title formatted for the Title version:

Code: Select all

SendInput, % Format("{:T}", Action)
Etc.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 211 guests