Help with Multiple ListBox GUI Command

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

Help with Multiple ListBox GUI Command

Post by AlFlo » 29 Nov 2021, 22:18

I'm trying to create a script with 4 ListBoxes, to insert various choices from lists as text into another program.

This outstanding script is exactly what I'm trying to do, except with 4 ListBoxes instead of 2 ListBoxes: viewtopic.php?p=65674#p65674

When I tried to modify the script to add 4 ListBoxes, it still only displays 2 ListBoxes. I think where I'm stuck is in changing the size of the Gui display so that it can fit all 4 ListBoxes.

Here's what I've tried:

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.

     
; Win+Shift+C - Combo Box
#+c::

 
Gui Add, ListBox, 8 x16 y40 w200 h290 vAction gAction multi, PREPARE|REVIEW AND ANALYZE|REVISE AND EDIT
Gui Add, Button, Default x16 y336 w54 h36 gInputUTI, Insert Action
Gui Font, s14 Bold c0xFF0000
Gui Add, Text, x16 y8 w120 h23 +0x200, Action:
Gui Font
Gui Add, ListBox, 8 x264 y40 w200 h290 vDocument gDocument multi, CORRESPONDENCE|DOCUMENTS|COMPLAINT|ANSWER|CROSS-COMPLAINT|.
Gui Add, Button, x264 y336 w51 h36 gInputDUTI, Insert Document
Gui Font, s14 Bold c0x00FF40
Gui Add, Text, x264 y8 w120 h23 +0x200, Document:
;
Gui Add, ListBox, 8 x16 y40 w200 h290 vToFrom gToFrom multi, TO|FROM|{Space}
Gui Add, Button, Default x16 y336 w54 h36 gInputUTI, Insert ToFrom
Gui Font, s14 Bold c0xFF0000
Gui Add, Text, x16 y8 w120 h23 +0x200, ToFrom:
Gui Font
Gui Add, ListBox, 8 x264 y40 w200 h290 vPerson gPerson multi, OPPOSING COUNSEL FOR|CLIENT|.
Gui Add, Button, x392 y370 w75 h23 gInputDUTI, Insert Person
Gui Font, s14 Bold c0x00FF40
Gui Add, Text, x264 y8 w120 h23 +0x200, Person:
;
Gui Font
Gui Add, Button, w500 h100 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 y340 w75 h23 gInputChartExit, Insert All 

::/uti::
Gui Show, w481 h400, 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
   
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

InputExit:
Gui, Submit, Hide
;Send, !{Esc}
Gui, Hide
Return
  
InputChartExit:
Gui, Submit, Hide
StringReplace, Action, Action, |,`,%A_Space%, All
StringReplace, Document, Document, |,`,%A_Space%, All
StringReplace, ToFrom, ToFrom, |,`,%A_Space%, All
StringReplace, Person, Person, |,`,%A_Space%, All
SendInput, %Action%{Space}
SendInput, %Document%{Space}
SendInput, %ToFrom%{Space}
SendInput, %Person%{Space}
Return

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Help with Multiple ListBox GUI Command

Post by mikeyww » 29 Nov 2021, 22:54

Since coordinates can be used to place controls on top of each other, start by eliminating your coordinates.

Code: Select all

Gui Add, ListBox, w200 h90 Multi vAction  , PREPARE|REVIEW AND ANALYZE|REVISE AND EDIT
Gui Add, ListBox, wp   hp  Multi vDocument, CORRESPONDENCE|DOCUMENTS|COMPLAINT|ANSWER|CROSS-COMPLAINT
Gui Add, ListBox, wp   hp  Multi vToFrom  , TO|FROM
Gui Add, ListBox, wp   hp  Multi vPerson  , OPPOSING COUNSEL FOR|CLIENT
Gui, Show,, Test
Run this script alone, with no other code. You now have a starting point from which to build. Use this script to change the positioning. After it works, you can add text, and change the fonts.

AlFlo
Posts: 337
Joined: 29 Nov 2021, 21:46

Re: Help with Multiple ListBox GUI Command

Post by AlFlo » 30 Nov 2021, 00:07

Thank you, mikeyww! That's fantastic!

I'm wondering if I can ask one more question. How can I have the 4 listboxes side-by-side, instead of stacked vertically?

Thanks!

User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: Help with Multiple ListBox GUI Command

Post by mikeyww » 30 Nov 2021, 07:36

Code: Select all

Gui Add, ListBox,    w200 h90 Multi vAction  , PREPARE|REVIEW AND ANALYZE|REVISE AND EDIT
Gui Add, ListBox, ym wp   hp  Multi vDocument, CORRESPONDENCE|DOCUMENTS|COMPLAINT|ANSWER|CROSS-COMPLAINT
Gui Add, ListBox, ym wp   hp  Multi vToFrom  , TO|FROM
Gui Add, ListBox, ym wp   hp  Multi vPerson  , OPPOSING COUNSEL FOR|CLIENT
Gui, Show,, Test

AlFlo
Posts: 337
Joined: 29 Nov 2021, 21:46

Re: Help with Multiple ListBox GUI Command

Post by AlFlo » 30 Nov 2021, 14:44

Thank you, sir ... you are a gentleman and a scholar!

Post Reply

Return to “Ask for Help (v1)”