GUI, checkbox. Separating options Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Osvaldas
Posts: 3
Joined: 01 Oct 2022, 12:51

GUI, checkbox. Separating options

Post by Osvaldas » 01 Oct 2022, 13:20

Hi there I'm stuck with something that's very simple hopefully.
My script looks like:

Code: Select all

#b::
LaunchGenerator:
SetBatchLines, -1
Gui, Destroy
CoordMode, Mouse, Screen
Gui,Font,s9,Arial
Gui, Add, Text,, Options
Gui, Add, CheckBox, vop1, Option1
Gui, Add, CheckBox, vop2, Option2
Gui, Add, CheckBox, vop3, Option3

Gui, Add, Text, ys, More options:
Gui, Add, CheckBox, vop4, Option4
Gui, Add, CheckBox, vop5, Option5
Gui, Add, CheckBox, vop6, Option6

Gui, Add, Button, xs yp+50 w60 h40 gponfirm, Copy 


MouseGetPos, coordx, coordy
coordy := coordy-350
; coordx := coordx-140
Gui, Show, x%coordx% y%coordy%
; Gui, Show, AutoSize Center
Return

ponfirm:

 Gui, Submit
	Clipboard =
	if (op1 =1)
	text1 := "one, "
	if (op2 =1)
	text2 := "two, "
	if (op3 =1)
	text3 := "three, "
	if (op1 =1 or op2 =1 or op3 =1)
	text7:= "`r`n - First half: "

	if (op4 =1)
	text4 := "four, "
	if (op5 =1)
	text5 := "five, "
	if (op6 =1)
	text6 := "six, "
	if (op4 =1 or op5 =1 or op6 =1)
	text8:= "`r`n - Other half: "
	text9:= "Things chosen:"
	

	clipboard := text9 text7 text1 text2 text3 text8 text4 text5 text6

	ClipWait, %clipboard%
	text1 :=
	text2 :=
	text3 :=
	text4 :=
	text5 :=
	text6 :=
	text7 :=
	text8 :=
	Text9 :=
	Return
My GUI:
image.png
image.png (5.8 KiB) Viewed 298 times
it pastes:
image.png
image.png (2.57 KiB) Viewed 298 times

So I need to add comas between options as there will be loads of them and that seems to be easiest way to do it. This way I get a coma at the end of each line
Could anybody see the way to manipulate the ending of each line? Say: to have ";" at the end of a first one instead of coma? I was tryng to add {backspace} here and there, didnt work.
I would appreaciate any ideas here.
Thanks!
Last edited by joedf on 01 Oct 2022, 14:08, edited 1 time in total.
Reason: [code] tags

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

Re: GUI, checkbox. Separating options  Topic is solved

Post by mikeyww » 01 Oct 2022, 14:39

Code: Select all

str := ["one", "two", "three", "four", "five", "six"]

#b::
Gui, Destroy
CoordMode, Mouse
Gui, Font, s9, Arial
Gui, Add, Text    ,     , Options
Gui, Add, CheckBox, vop1, Option1
Gui, Add, CheckBox, vop2, Option2
Gui, Add, CheckBox, vop3, Option3
Gui, Add, Text    , ym  , More options:
Gui, Add, CheckBox, vop4, Option4
Gui, Add, CheckBox, vop5, Option5
Gui, Add, CheckBox, vop6, Option6
Gui, Add, Button, xm w200 Default, Copy
MouseGetPos, x, y
y -= 350
Gui, Show, x%x% y%y%, Strings
Return

ButtonCopy:
Gui, Submit
text = Things chosen:
If op1 op2 op3 {
 text .= "`nFirst half: "
 Loop, 3
  text .= op%A_Index% ? str[A_Index] ", " : ""
 text := Trim(text, " ,")
}
If op4 op5 op6 {
 text .= "`nSecond half: "
 Loop, 3
  n := A_Index + 3, text .= op%n% ? str[n] ", " : ""
 text := Trim(text, " ,")
}
Clipboard := "", Clipboard := text
ClipWait, 0
If ErrorLevel
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Return
Explained: Trim

Osvaldas
Posts: 3
Joined: 01 Oct 2022, 12:51

Re: GUI, checkbox. Separating options

Post by Osvaldas » 08 Oct 2022, 09:01

mikeyww wrote:
01 Oct 2022, 14:39

Code: Select all

str := ["one", "two", "three", "four", "five", "six"]

#b::
Gui, Destroy
CoordMode, Mouse
Gui, Font, s9, Arial
Gui, Add, Text    ,     , Options
Gui, Add, CheckBox, vop1, Option1
Gui, Add, CheckBox, vop2, Option2
Gui, Add, CheckBox, vop3, Option3
Gui, Add, Text    , ym  , More options:
Gui, Add, CheckBox, vop4, Option4
Gui, Add, CheckBox, vop5, Option5
Gui, Add, CheckBox, vop6, Option6
Gui, Add, Button, xm w200 Default, Copy
MouseGetPos, x, y
y -= 350
Gui, Show, x%x% y%y%, Strings
Return

ButtonCopy:
Gui, Submit
text = Things chosen:
If op1 op2 op3 {
 text .= "`nFirst half: "
 Loop, 3
  text .= op%A_Index% ? str[A_Index] ", " : ""
 text := Trim(text, " ,")
}
If op4 op5 op6 {
 text .= "`nSecond half: "
 Loop, 3
  n := A_Index + 3, text .= op%n% ? str[n] ", " : ""
 text := Trim(text, " ,")
}
Clipboard := "", Clipboard := text
ClipWait, 0
If ErrorLevel
 MsgBox, 48, Error, An error occurred while waiting for the clipboard.
Return
Explained: Trim
beautiful and looks much more efficient! Thanks you!

Post Reply

Return to “Ask for Help (v1)”