GUI checkbox multiple entries Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
hymal7
Posts: 66
Joined: 14 Sep 2016, 05:37

GUI checkbox multiple entries

16 Nov 2018, 11:24

Hi,

I wanted to create a form with multiple where checkboxes can be selected.
I came across this post: https://autohotkey.com/board/topic/2473 ... utton-gui/
I appreciate the idea of

Code: Select all

if IsLabel(A B C D)  ; (implicit . concatenation)
        gosub % A B C D
        0000:
    MsgBox, A=0 B=0 C=0 D=0
    return
1000:
    MsgBox, A=1 B=0 C=0 D=0
    return
0100:
    MsgBox, A=0 B=1 C=0 D=0
    return
1100:
    MsgBox, A=1 B=1 C=0 D=0
    return

; etc.
but even if with 4 checkboxes, there are 16 possible combinations.

The GUI i want to create has 19 checkboxes and will have 361 possible combinations .
Is there an efficient way to make it possible where the user can select multiple checkboxes instead of the method i posted? e.g. using arrays?

Thanks
hymal7
oif2003
Posts: 214
Joined: 17 Oct 2018, 11:43
Contact:

Re: GUI checkbox multiple entries

16 Nov 2018, 12:46

You will have way more than 361 combinations. 2^19 is a very large number. What do the checkbox values corresponds to? Does each combination correspond to a unique action? Or does each checkbox correspond to a single action? A combination of both?
hymal7
Posts: 66
Joined: 14 Sep 2016, 05:37

Re: GUI checkbox multiple entries

19 Nov 2018, 04:48

the checkboxes are part numbers which when ticked (and click a 'send' button) would send an email with a list of parts ticked. The user can select just one or two or all 19 parts depending on his needs.

e.g. The attachment shows just 4 options
Attachments
checkboxes.png
checkboxes.png (8.79 KiB) Viewed 1445 times
digidings
Posts: 24
Joined: 22 Jan 2018, 17:04

Re: GUI checkbox multiple entries  Topic is solved

19 Nov 2018, 07:51

how about a standard solution with loops ?

Code: Select all

    
    MaxParts := 19, PartsPerRow := 3, xSpace := 20, ySpace := 30, width := 60
    Gui Add, Groupbox, % "xm w" . PartsPerRow * (width + xSpace) 
			. " h" . ySpace * (1+ Floor(MaxParts / PartsPerRow)) + 30
			, Backing Mesh
    Loop % MaxParts {
        Gui Add, CheckBox, % ((Mod(A_Index-1, PartsPerRow) == 0) ? "xm+10 yp+" . ySpace : "x+" . xSpace) 
			. " w" . width . " vCB" . A_Index
			, % "part " . Chr(64 + A_Index)
    }
    Gui Add, Button, xm gApply, Apply
    Gui Show
    return

Apply:
    PartSelection := ""
    Loop % MaxParts {
        GuiControlGet, ticked,, % "CB" . A_Index
        PartSelection .= Chr(64 + A_Index) . "=" . (ticked ? "1" : "0") . A_Space
    }
    MsgBox % PartSelection
    return

GuiClose:
    ExitApp

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: aitaixy, Anput, dangoscrub, Google [Bot], joedf, Nerafius and 170 guests