How to check which checkboxes are checked (Multiple checkboxes)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jollyjoe
Posts: 45
Joined: 13 Feb 2021, 18:51

How to check which checkboxes are checked (Multiple checkboxes)

03 May 2024, 22:21

I want to append each checkbox control name to a text file, this is what the gui looks like:
image.png
image.png (3.29 KiB) Viewed 425 times
Each checkbox is named mob1, mob2, mob3, ... and they all point to 1 gLabel called mobmenu

Heres my current code for the glabel, i tried using a variable for ControlGet but it doesnt work

Code: Select all

mobmenu:
	Gui, Submit, NoHide
	_count = 0
	Loop {
		_count++
		_mob := "mob" . _count
		if (_count < 22) {
			ControlGet, isChecked, Checked,, %_mob%
			msgbox % _mob " = " isChecked " count is " _count ;isChecked is always blank, %_mob% is not getting read in the line above
			if (isChecked = 1) {
				FileAppend, %_mob%, CMAP.txt
			}
		}
	}
return
How do I make it so that every box that is checked gets appended to a txt file?
Attachments
image.png
image.png (3.35 KiB) Viewed 425 times
User avatar
mikeyww
Posts: 28869
Joined: 09 Sep 2014, 18:38

Re: How to check which checkboxes are checked (Multiple checkboxes)

04 May 2024, 06:21

Hello,

An If statement inside an infinite loop gets you an infinite loop, unless you provide an iteration count, Until, or break from the loop in some way (e.g., Break).

How to iterate a finite loop and get the iteration number

Below is a simple approach that will store all of your values instead of creating an ever-expanding text file.

Code: Select all

#Requires AutoHotkey v1.1.33.11
Gui Font, s10
Gui Add, CheckBox, w250 vmob1 gMobmenu, Mob1
Gui Add, CheckBox, wp   vmob2 gMobmenu, Mob2
Gui Show,, Checkboxes
Return

Mobmenu:
Gui Submit, NoHide
IniWrite % %A_GuiControl%, config.ini, Checkboxes, % A_GuiControl
Return

When you submit the GUI, you have all of its associated variables' values, so ControlGet is not needed.

Code: Select all

Mobmenu:
Gui Submit, NoHide
Loop 2 {
 _mob := "mob" A_Index
 MsgBox % %_mob%
}
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot] and 153 guests