Jump to content

Select multiple checkboxes and display the ones checked


DigDeep
 Share

Go to solution Solved by Wruck,

Recommended Posts

Hi AutoIT team and members,
 
I would need some urgent help here. I am stuck at a point and have spent huge time trying to correct my script but I am unable to do so. would appriciate if anyone can get my codes corrected and provide me the way I am looking for.

 

What I am looking here is:

1. When I select the 1st drop down, it should show the list of options.

2. When I select from the list of options it should put the messages to the right side of the screen with the steps and Checkboxes.

I'm able to do these 2 steps.

3. Now the things I am not able to do are:

  • If I would select 1 or more than 1 checkboxes and click on Copy to Clipboard then it should copy the Text in the checkboxes so I can paste those steps somewhere as:

Step 1

Step 4

Step 10

  • I haven't included the Select All button here but if I would select the Select All button then it should select all the checkboxes. And then I can select the Copy to Clipboard button to Copy the checked boxes.

 

Can someone please help me get this fixed?

#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>

Dim $Form1, $Label1, $Group1, $Search, $Label2, $Label3, $Label4, $Label5, $Submit, $Group2, $Label6, $Label7, $Copy_to_Clipboard

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Steps", 1903, 980, -1, 3)
$Label1 = GUICtrlCreateLabel("Steps", 0, 40, 1894, 73)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Group1 = GUICtrlCreateGroup("", 8, 112, 433, 857)
GUICtrlSetColor(-1, 0x000000)

$Search = GUICtrlCreateInput("Search", 24, 136, 201, 24)

$Label2 = GUICtrlCreateLabel("Button1", 28, 184, 42, 20)
$Button1 = GUICtrlCreateCombo("", 96, 184, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label3 = GUICtrlCreateLabel("Button2", 24, 240, 69, 20)
$Button2 = GUICtrlCreateCombo("", 96, 240, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label4 = GUICtrlCreateLabel("Button3", 24, 296, 66, 20)
$Button3 = GUICtrlCreateCombo("", 96, 296, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label5 = GUICtrlCreateLabel("Button4", 24, 352, 69, 20)
$Button4 = GUICtrlCreateCombo("", 96, 352, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Submit = GUICtrlCreateButton("Submit", 272, 136, 155, 25, $BS_DEFPUSHBUTTON)

GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 464, 112, 1425, 825)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit




        Case $Button1
            If GUICtrlRead($Button1) = "first issue" Then
                ;MsgBox(0, "", "TEST1")
                $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 504, 184, 97, 17)
                $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 504, 224, 97, 17)
                $Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 504, 264, 97, 17)
                $Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 504, 312, 97, 17)
                $Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 504, 352, 97, 17)
                $Checkbox6 = GUICtrlCreateCheckbox("Checkbox6", 504, 392, 97, 17)
                $Checkbox7 = GUICtrlCreateCheckbox("Checkbox7", 504, 432, 97, 17)
                $Checkbox8 = GUICtrlCreateCheckbox("Checkbox8", 504, 472, 97, 17)
                $Checkbox9 = GUICtrlCreateCheckbox("Checkbox9", 504, 512, 97, 17)
                $Checkbox10 = GUICtrlCreateCheckbox("Checkbox10", 504, 552, 97, 17)
                $Copy_to_Clipboard = GUICtrlCreateButton("Copy to Clipboard", 504, 640, 139, 25, $BS_DEFPUSHBUTTON)
                GUICtrlSetBkColor(-1, 0xC0DCC0)
                $Label6 = GUICtrlCreateLabel("First issue", 480, 136, 1393, 29)
                GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
            EndIf

            If GUICtrlRead($Copy_to_Clipboard) = 1 Then
                MsgBox(0, "Test", " is selected")
            EndIf

            If GUICtrlRead($Button1) = "Second issue" Then

                $Checkbox11 = GUICtrlCreateCheckbox("Checkbox6", 504, 392, 97, 17)
                $Checkbox12 = GUICtrlCreateCheckbox("Checkbox7", 504, 432, 97, 17)
                $Checkbox13 = GUICtrlCreateCheckbox("Checkbox8", 504, 472, 97, 17)
                $Checkbox14 = GUICtrlCreateCheckbox("Checkbox9", 504, 512, 97, 17)
                $Checkbox15 = GUICtrlCreateCheckbox("Checkbox10", 504, 552, 97, 17)
                $Copy_to_Clipboard1 = GUICtrlCreateButton("Copy to Clipboard", 504, 640, 139, 25, $BS_DEFPUSHBUTTON)
                GUICtrlSetBkColor(-1, 0xC0DCC0)
                $Label8 = GUICtrlCreateLabel("Second issue", 480, 136, 1393, 29)
                GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

            EndIf

        Case $Button2
            MsgBox(0, "", GUICtrlRead($Button2))

        Case $Button3
            MsgBox(0, "", GUICtrlRead($Button3))

        Case $Button4
            MsgBox(0, "", GUICtrlRead($Button4))
            #cs



            #CE
            ;           GUIDelete($Form1)

    EndSwitch
WEnd
Link to comment
Share on other sites

You should build your checkboxes like this

Local $checkboxes[10]
For $i = 0 to 9
    $checkboxes[$i] = GUICtrlCreateCheckbox("Checkbox" & $i+1, 504, 184 + (40*$i), 97, 17)
Next

and check the states like this

$states = ""
For $i = 0 to 9
    If GuiCtrlRead($checkboxes[$i]) = $GUI_CHECKED Then $states &= "step " & $i+1 & @crlf
Next
Msgbox(0,"", $states)
Edited by mikell
Link to comment
Share on other sites

or 

for $Checkbox1 to $Checkbox10
  If GuiCtrlRead($checkboxes[$i]) = $GUI_CHECKED Then $states &= "step " & $i+1 & @crlf
Next
 Msgbox(0,"", $states)

also can create your  Copy_to_Clipboard GUICtrlCreateButton out of your $Button1 event. hide it. when $Button1 is pressed showit and use the code below in your Clipboard GUICtrlCreateButton event.

Saludos

Edited by Danyfirex
Link to comment
Share on other sites

sunshinesmile84,

You are handling you copy to clipboard button wrong...see comments in code...

#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>

Dim $Form1, $Label1, $Group1, $Search, $Label2, $Label3, $Label4, $Label5, $Submit, $Group2, $Label6, $Label7, $Copy_to_Clipboard

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Steps", 1103, 980, -1, 3)
$Label1 = GUICtrlCreateLabel("Steps", 0, 40, 1894, 73)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Group1 = GUICtrlCreateGroup("", 8, 112, 433, 857)
GUICtrlSetColor(-1, 0x000000)

$Search = GUICtrlCreateInput("Search", 24, 136, 201, 24)

$Label2 = GUICtrlCreateLabel("Button1", 28, 184, 42, 20)
$Button1 = GUICtrlCreateCombo("", 96, 184, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label3 = GUICtrlCreateLabel("Button2", 24, 240, 69, 20)
$Button2 = GUICtrlCreateCombo("", 96, 240, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label4 = GUICtrlCreateLabel("Button3", 24, 296, 66, 20)
$Button3 = GUICtrlCreateCombo("", 96, 296, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label5 = GUICtrlCreateLabel("Button4", 24, 352, 69, 20)
$Button4 = GUICtrlCreateCombo("", 96, 352, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Submit = GUICtrlCreateButton("Submit", 272, 136, 155, 25, $BS_DEFPUSHBUTTON)

GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 464, 112, 1425, 825)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit




        Case $Button1
            If GUICtrlRead($Button1) = "first issue" Then
                ;MsgBox(0, "", "TEST1")
                $Checkbox1 = GUICtrlCreateCheckbox("Checkbox1", 504, 184, 97, 17)
                $Checkbox2 = GUICtrlCreateCheckbox("Checkbox2", 504, 224, 97, 17)
                $Checkbox3 = GUICtrlCreateCheckbox("Checkbox3", 504, 264, 97, 17)
                $Checkbox4 = GUICtrlCreateCheckbox("Checkbox4", 504, 312, 97, 17)
                $Checkbox5 = GUICtrlCreateCheckbox("Checkbox5", 504, 352, 97, 17)
                $Checkbox6 = GUICtrlCreateCheckbox("Checkbox6", 504, 392, 97, 17)
                $Checkbox7 = GUICtrlCreateCheckbox("Checkbox7", 504, 432, 97, 17)
                $Checkbox8 = GUICtrlCreateCheckbox("Checkbox8", 504, 472, 97, 17)
                $Checkbox9 = GUICtrlCreateCheckbox("Checkbox9", 504, 512, 97, 17)
                $Checkbox10 = GUICtrlCreateCheckbox("Checkbox10", 504, 552, 97, 17)
                $Copy_to_Clipboard = GUICtrlCreateButton("Copy to Clipboard", 504, 640, 139, 25, $BS_DEFPUSHBUTTON)
                GUICtrlSetBkColor(-1, 0xC0DCC0)
                $Label6 = GUICtrlCreateLabel("First issue", 480, 136, 1393, 29)
                GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
            EndIf

            ; $Copy_to_Clipboard is a button control.  guictrlread will give you the text of the control, 
            ; you probably want to include this in your MSG loop

;~          If GUICtrlRead($Copy_to_Clipboard) = 1 Then
;~              MsgBox(0, "Test", " is selected")
;~          EndIf

            If GUICtrlRead($Button1) = "Second issue" Then

                $Checkbox11 = GUICtrlCreateCheckbox("Checkbox6", 504, 392, 97, 17)
                $Checkbox12 = GUICtrlCreateCheckbox("Checkbox7", 504, 432, 97, 17)
                $Checkbox13 = GUICtrlCreateCheckbox("Checkbox8", 504, 472, 97, 17)
                $Checkbox14 = GUICtrlCreateCheckbox("Checkbox9", 504, 512, 97, 17)
                $Checkbox15 = GUICtrlCreateCheckbox("Checkbox10", 504, 552, 97, 17)
                $Copy_to_Clipboard1 = GUICtrlCreateButton("Copy to Clipboard", 504, 640, 139, 25, $BS_DEFPUSHBUTTON)
                GUICtrlSetBkColor(-1, 0xC0DCC0)
                $Label8 = GUICtrlCreateLabel("Second issue", 480, 136, 1393, 29)
                GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

            EndIf

        Case $Button2
            MsgBox(0, "", GUICtrlRead($Button2))

        Case $Button3
            MsgBox(0, "", GUICtrlRead($Button3))

        Case $Button4
            MsgBox(0, "", GUICtrlRead($Button4))

        ; added case for button to output messages to console

        Case $Copy_to_Clipboard

            For $1 = 1 To 15
                If GUICtrlRead(Eval('Checkbox' & $1)) = 1 Then ConsoleWrite('step # ' & $1 & @CRLF)
            Next

    EndSwitch
WEnd

Also, you should really implement mikell's suggestion for using an array for the checkbox control ids.  This will make it much easier to handle them later in code.

kylomas

edit: took a closer look at your code.  I think your implementation can be improved, if I understand what you are trying to do.  In particular, if you are going to have varying events (checkboxes) based on selectioins then you may want to externalize that data (ini file, etc).

Also, what are the four combo controls for?

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

sunshinesmile84,

Proof of concept externalizing the data for a check list and generating checklists based on varying criteria...

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiComboBox.au3>
#include <array.au3>

#AutoIt3Wrapper_Add_Constants=n

local $inifile = @scriptdir & '\task.txt'

Local $gui010 = GUICreate('Task Checklist Helper', 800, 750)

; create group and tasks combo boxes

GUICtrlCreateGroup('Tasks', 10, 10, 300, 700)
Local $cmb001 = GUICtrlCreateCombo('', 20, 40, 280, 20)
Local $cmb002 = GUICtrlCreateCombo('', 20, 140, 280, 20)
Local $cmb003 = GUICtrlCreateCombo('', 20, 240, 280, 20)
Local $cmb004 = GUICtrlCreateCombo('', 20, 340, 280, 20)
GUICtrlCreateGroup('', -99, -99, 1, 1)

_GUICtrlComboBox_SetCueBanner($cmb001, 'Select a Group #1 Item')
_GUICtrlComboBox_SetCueBanner($cmb002, 'Select a Group #2 Item')
_GUICtrlComboBox_SetCueBanner($cmb003, 'Select a Group #3 Item')
_GUICtrlComboBox_SetCueBanner($cmb004, 'Select a Group #4 Item')

; create group for checkboxes, static controls and submit button.  Hide the controls initially

GUICtrlCreateGroup('Task Checklist', 340, 10, 450, 700)
Local $aCHK[30][2], $Sub_BTN
For $1 = 0 To UBound($aCHK) - 1
    $aCHK[$1][0] = GUICtrlCreateCheckbox('', 360, $1*20+30, 80, 20)
    GUICtrlSetState(-1, $gui_hide)
    $aCHK[$1][1] = guictrlcreatelabel('',450, $1*20+33, 330, 20)
    $Sub_BTN = guictrlcreatebutton('Submit',500,680,140,20)
    GUICtrlSetState(-1, $gui_hide)
Next

; populate the comboboxes

local $aSections = IniReadSectionNames($inifile)
if @error <> 0 then exit msgbox(16,'** ERROR **','Error reading ini file = ' & $inifile)

local $aSection

for $1 = 1 to $aSections[0]
    $aSection = IniReadSection($inifile,$aSections[$1])
    if @error <> 0 then exit msgbox(16,'** ERROR **','Error reading ini file section = ' & $aSections[$1])
    guictrlsetdata(eval('cmb' & $aSection[1][1]),$aSections[$1])
next

GUISetState()

While 1
    Switch GUIGetMsg()
        Case $gui_event_close
            Exit
        case $cmb001
            _chklst($cmb001)
        case $cmb002
            _chklst($cmb002)
        case $cmb003
            _chklst($cmb003)
        case $cmb004
            _chklst($cmb004)
        case $Sub_BTN
            ConsoleWrite('!------------------------------------------------' & @CRLF)
            for $1 = 0 to ubound($aCHK) - 1
                if guictrlread($aCHK[$1][0]) = 1 then ConsoleWrite('Task # ' & $1 & ' - ' & guictrlread($aCHK[$1][1]) & ' checked' & @CRLF)
            next
    EndSwitch
WEnd

func _chklst($idx)

    for $1 = 0 to ubound($aCHK) - 1
        guictrlsetstate($aCHK[$1][0],$gui_unchecked)
        guictrlsetstate($aCHK[$1][0],$gui_hide)
        guictrlsetdata($aCHK[$1][1],'')
    next

    local $asect = inireadsection($inifile,guictrlread($idx))

    for $1 = 2 to $asect[0][0]
        guictrlsetdata($aCHK[$1-1][0],'Task # ' & $asect[$1][0])
        guictrlsetdata($aCHK[$1-1][1],$asect[$1][1])
        guictrlsetstate($aCHK[$1-1][1],$gui_show)
        guictrlsetstate($aCHK[$1-1][0],$gui_show)
    next

    guictrlsetstate($Sub_BTN,$gui_show)

endfunc

Limitations:

ini file capacity = 32K (I think but can't find it in the Help file right now)

number of tasks on checklist max of 30 (as currently coded)

max length of task description field = 55 (as currently coded) 

 

This is the ini file that I used for this demo task.txt.  It has a .TXT extention because ew can not upload ini type files.  It will work as is.

If this is not what you are going after you may find some of the techniques useful.

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

You should build your checkboxes like this

Local $checkboxes[10]
For $i = 0 to 9
    $checkboxes[$i] = GUICtrlCreateCheckbox("Checkbox" & $i+1, 504, 184 + (40*$i), 97, 17)
Next
and check the states like this

$states = ""
For $i = 0 to 9
    If GuiCtrlRead($checkboxes[$i]) = $GUI_CHECKED Then $states &= "step " & $i+1 & @crlf
Next
Msgbox(0,"", $states)

Hi,

 

I have tried your step here but I am getting errors for the Case close is wrong. Attaching the new codes here with the errors in Red... Could you please help me in reaalying the codes correctly.

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            If GUICtrlRead($Button1) = "first issue" Then
                $Label6 = GUICtrlCreateLabel("First issue", 480, 136, 1393, 29)
                GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
                ;   MsgBox(0, "", "TEST1")
                Local $checkboxes[10]
                For $i = 0 To 9
                    $checkboxes[$i] = GUICtrlCreateCheckbox("Checkbox" & $i + 1, 504, 184 + (40 * $i), 97, 17)
                Next
                $Copy_to_Clipboard = GUICtrlCreateButton("Copy to Clipboard", 504, 640, 139, 25)
                GUICtrlSetBkColor(-1, 0xC0DCC0)
            EndIf

        Case $Copy_to_Clipboard
            $states = ""
            For $i = 0 To 9
                If GUICtrlRead($checkboxes[$i]) = $GUI_CHECKED Then
                    $states &= "step " & $i + 1 & @CRLF
;### Tidy Error -> "next" is closing previous "if" on line 75
                Next
                MsgBox(0, "", $states)

;### Tidy Error -> "endswitch" is closing previous "case" on line 56
        EndSwitch
;### Tidy Error -> "wend" is closing previous "switch" on line 55
    WEnd
Link to comment
Share on other sites

You changed the one line If/Then statement into 2 lines without using an EndIf to close the If statement, that's why you're getting an error. Either add an EndIf before the Next statement, or put it back to one line.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

You changed the one line If/Then statement into 2 lines without using an EndIf to close the If statement, that's why you're getting an error. Either add an EndIf before the Next statement, or put it back to one line.

I changed it to one line and it got compiled without any errors. But screen closes with a flash. It doesn't launch at all.

Link to comment
Share on other sites

You declare $checkbox array in one switch case. If that case doesn't trigger, it doesn't exist. If the 2nd case executes prior to the first - it will bomb out.

understand and I got that part working. But I am back to square one now. I got the codes as they should be but when I select any or multiple checkboxes the clipboard button doesn't do anything. Rather the msgbox comes up as blank when I select the dropdown.

#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>

Dim $Form1, $Label1, $Group1, $Search, $Label2, $Label3, $Label4, $Label5, $Submit, $Group2, $Label6, $Label7, $Copy_to_Clipboard

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Steps", 1903, 980, -1, 3)
$Label1 = GUICtrlCreateLabel("Steps", 0, 40, 1894, 73)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Group1 = GUICtrlCreateGroup("", 8, 112, 433, 857)
GUICtrlSetColor(-1, 0x000000)

$Search = GUICtrlCreateInput("Search", 24, 136, 201, 24)

$Label2 = GUICtrlCreateLabel("Button1", 28, 184, 42, 20)
$Button1 = GUICtrlCreateCombo("", 96, 184, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label3 = GUICtrlCreateLabel("Button2", 24, 240, 69, 20)
$Button2 = GUICtrlCreateCombo("", 96, 240, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label4 = GUICtrlCreateLabel("Button3", 24, 296, 66, 20)
$Button3 = GUICtrlCreateCombo("", 96, 296, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label5 = GUICtrlCreateLabel("Button4", 24, 352, 69, 20)
$Button4 = GUICtrlCreateCombo("", 96, 352, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Submit = GUICtrlCreateButton("Submit", 272, 136, 155, 25, $BS_DEFPUSHBUTTON)

GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 464, 112, 1425, 825)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            If GUICtrlRead($Button1) = "first issue" Then
                $Label6 = GUICtrlCreateLabel("First issue", 480, 136, 1393, 29)
                GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
                ;   MsgBox(0, "", "TEST1")
                Local $checkboxes[10]
                For $i = 0 To 9
                    $checkboxes[$i] = GUICtrlCreateCheckbox("Checkbox" & $i + 1, 504, 184 + (40 * $i), 97, 17)
                Next
                $Copy_to_Clipboard = GUICtrlCreateButton("Copy to Clipboard", 504, 640, 139, 25)
                GUICtrlSetBkColor(-1, 0xC0DCC0)
                
                $states = ""
                For $i = 0 To 9
                    If GUICtrlRead($checkboxes[$i]) = $GUI_CHECKED Then $states &= "step " & $i + 1 & @CRLF
                Next
                MsgBox(0, "", $states)
                
            EndIf
    EndSwitch
WEnd
Link to comment
Share on other sites

I understand you now. You do not have $Copy_to_Clipboard defined in the GUI While loop. So when you click on it, nothing happens as nothing has been defined to happen.

Basically, you need to add another case statement for that function.

Edited by Wruck
Link to comment
Share on other sites

I understand you now. You do not have $Copy_to_Clipboard defined in the GUI While loop. So when you click on it, nothing happens as nothing has been defined to happen.

Basically, you need to add another case statement for that function.

If I put the $Copy_to_Clipboard as another case then it again throws me the IF closed before error.

It is implortant for me to get this by tomorrow and I am scratching my codes here. Could you please get my codes outlined and paste here. Greatly appriciated your time.

Link to comment
Share on other sites

 

You should build your checkboxes like this

Local $checkboxes[10]
For $i = 0 to 9
    $checkboxes[$i] = GUICtrlCreateCheckbox("Checkbox" & $i+1, 504, 184 + (40*$i), 97, 17)
Next

and check the states like this

$states = ""
For $i = 0 to 9
    If GuiCtrlRead($checkboxes[$i]) = $GUI_CHECKED Then $states &= "step " & $i+1 & @crlf
Next
Msgbox(0,"", $states)
#NoTrayIcon
#RequireAdmin
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=y
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiMenu.au3>

Dim $Form1, $Label1, $Group1, $Search, $Label2, $Label3, $Label4, $Label5, $Submit, $Group2, $Label6, $Label7, $Copy_to_Clipboard

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Steps", 1903, 980, -1, 3)
$Label1 = GUICtrlCreateLabel("Steps", 0, 40, 1894, 73)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, 0xA6CAF0)
$Group1 = GUICtrlCreateGroup("", 8, 112, 433, 857)
GUICtrlSetColor(-1, 0x000000)

$Search = GUICtrlCreateInput("Search", 24, 136, 201, 24)

$Label2 = GUICtrlCreateLabel("Button1", 28, 184, 42, 20)
$Button1 = GUICtrlCreateCombo("", 96, 184, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label3 = GUICtrlCreateLabel("Button2", 24, 240, 69, 20)
$Button2 = GUICtrlCreateCombo("", 96, 240, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label4 = GUICtrlCreateLabel("Button3", 24, 296, 66, 20)
$Button3 = GUICtrlCreateCombo("", 96, 296, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Label5 = GUICtrlCreateLabel("Button4", 24, 352, 69, 20)
$Button4 = GUICtrlCreateCombo("", 96, 352, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetData(-1, "First issue|Second issue")

$Submit = GUICtrlCreateButton("Submit", 272, 136, 155, 25, $BS_DEFPUSHBUTTON)

GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 464, 112, 1425, 825)

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            If GUICtrlRead($Button1) = "first issue" Then
                $Label6 = GUICtrlCreateLabel("First issue", 480, 136, 1393, 29)
                GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
                ;   MsgBox(0, "", "TEST1")
                Local $checkboxes[10]
                For $i = 0 To 9
                    $checkboxes[$i] = GUICtrlCreateCheckbox("Checkbox" & $i + 1, 504, 184 + (40 * $i), 97, 17)
                Next
                $Copy_to_Clipboard = GUICtrlCreateButton("Copy to Clipboard", 504, 640, 139, 25)
                GUICtrlSetBkColor(-1, 0xC0DCC0)
                
                $states = ""
                For $i = 0 To 9
                    If GUICtrlRead($checkboxes[$i]) = $GUI_CHECKED Then $states &= "step " & $i + 1 & @CRLF
                Next
                MsgBox(0, "", $states)
                
            EndIf
    EndSwitch
WEnd

Hi Mikell,

Could you please check the code?

Link to comment
Share on other sites

sunshinesmile84,

I understand that this is important to you, however, this is a volunteer forum and as such the members help at their pleasure.  You have been given adequate help to solve each problem if you do a little digging yourself.  Moreover, I wrote a demo for you, despite the lack of answers to my questions because the problem interested me.

However, now it is time for you to "get wet".  The questions that you are asking are syntactical in nature and easily answered by the Help file.  You will find that the more effort you expend the more help you will get.

Please review ALL of the thread, try the examples.  As I indicated earlier, I believe that your design is flawed.  Maybe you should start back at the beginning by explaining what it is you are trying to do.

Good Luck,

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

  • Solution

Okay... I changed some things around in your code. Not sure if this is what you are looking for.

#NoTrayIcon
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $hGUI_MainWindow, $hGUI_CTRL_LBL_Steps, $hGUI_CTRL_GRP_Unlabeled1, $hGUI_CTRL_INP_Search, $hGUI_CTRL_BTN_Submit
Global $hGUI_CTRL_LBL_IssueList1, $hGUI_CTRL_CMB_IssueList1, $hGUI_CTRL_LBL_IssueList2, $hGUI_CTRL_CMB_IssueList2
Global $hGUI_CTRL_LBL_IssueList3, $hGUI_CTRL_CMB_IssueList3, $hGUI_CTRL_LBL_IssueList4, $hGUI_CTRL_CMB_IssueList4
Global $hGUI_CTRL_GRP_Unlabeled2, $hGUI_CTRL_LBL_IssueWnd1, $hGUI_CTRL_BTN_Copy2Clip, $aGUI_CTRL_CHK_GroupedBoxes[10]
Global $iGUI_Message, $iLoop, $sChkValues, $iUBound1D = UBound($aGUI_CTRL_CHK_GroupedBoxes, 1) - 1
WinGUI_Construct()
While 1
    $iGUI_Message = GUIGetMsg()
    Switch $iGUI_Message
        Case $GUI_EVENT_CLOSE
            Exit
        Case $hGUI_CTRL_CMB_IssueList1
            If GUICtrlRead($hGUI_CTRL_CMB_IssueList1) = 'First issue' Then
                GUICtrlSetState($hGUI_CTRL_LBL_IssueWnd1, $GUI_SHOW)
                GUICtrlSetState($hGUI_CTRL_BTN_Copy2Clip, $GUI_SHOW)
                For $iLoop = 0 To $iUBound1D Step 1
                    GUICtrlSetState($aGUI_CTRL_CHK_GroupedBoxes[$iLoop], $GUI_SHOW)
                Next
            Else
                GUICtrlSetState($hGUI_CTRL_LBL_IssueWnd1, $GUI_HIDE)
                GUICtrlSetState($hGUI_CTRL_BTN_Copy2Clip, $GUI_HIDE)
                For $iLoop = 0 To $iUBound1D Step 1
                    GUICtrlSetState($aGUI_CTRL_CHK_GroupedBoxes[$iLoop], $GUI_HIDE)
                Next
            EndIf
        Case $hGUI_CTRL_BTN_Copy2Clip
            $sChkValues = ''
            For $iLoop = 0 To $iUBound1D Step 1
                If GUICtrlRead($aGUI_CTRL_CHK_GroupedBoxes[$iLoop]) = $GUI_CHECKED Then $sChkValues &= "step " & $iLoop + 1 & @CRLF
            Next
            MsgBox(0, '', $sChkValues)
    EndSwitch
WEnd
Func WinGUI_Construct()
    $hGUI_MainWindow = GUICreate('Steps', 1903, 980, -1, 3)
    $hGUI_CTRL_LBL_Steps = GUICtrlCreateLabel('Steps', 0, 40, 1894, 73)
    GUICtrlSetFont($hGUI_CTRL_LBL_Steps, 14, 400, 0, 'MS Sans Serif')
    GUICtrlSetBkColor($hGUI_CTRL_LBL_Steps, 0xA6CAF0)
    $hGUI_CTRL_GRP_Unlabeled1 = GUICtrlCreateGroup('', 8, 112, 433, 857)
    GUICtrlSetColor($hGUI_CTRL_GRP_Unlabeled1, 0x000000)
    $hGUI_CTRL_INP_Search = GUICtrlCreateInput('Search', 24, 136, 201, 24)
    $hGUI_CTRL_LBL_IssueList1 = GUICtrlCreateLabel('Button1', 28, 184, 42, 20)
    $hGUI_CTRL_CMB_IssueList1 = GUICtrlCreateCombo('', 96, 184, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
    GUICtrlSetData($hGUI_CTRL_CMB_IssueList1, '|First issue|Second issue')
    $hGUI_CTRL_LBL_IssueList2 = GUICtrlCreateLabel('Button2', 24, 240, 69, 20)
    $hGUI_CTRL_CMB_IssueList2 = GUICtrlCreateCombo('', 96, 240, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
    GUICtrlSetData($hGUI_CTRL_CMB_IssueList2, '|First issue|Second issue')
    $hGUI_CTRL_LBL_IssueList3 = GUICtrlCreateLabel('Button3', 24, 296, 66, 20)
    $hGUI_CTRL_CMB_IssueList3 = GUICtrlCreateCombo('', 96, 296, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
    GUICtrlSetData($hGUI_CTRL_CMB_IssueList3, '|First issue|Second issue')
    $hGUI_CTRL_LBL_IssueList4 = GUICtrlCreateLabel('Button4', 24, 352, 69, 20)
    $hGUI_CTRL_CMB_IssueList4 = GUICtrlCreateCombo('', 96, 352, 329, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
    GUICtrlSetData($hGUI_CTRL_CMB_IssueList4, '|First issue|Second issue')
    $hGUI_CTRL_BTN_Submit = GUICtrlCreateButton('Submit', 272, 136, 155, 25, $BS_DEFPUSHBUTTON)
    GUICtrlCreateGroup('', -99, -99, 1, 1)
    $hGUI_CTRL_GRP_Unlabeled2 = GUICtrlCreateGroup('', 464, 112, 1425, 825)
    $hGUI_CTRL_LBL_IssueWnd1 = GUICtrlCreateLabel("First issue", 480, 136, 1393, 29)
    GUICtrlSetFont($hGUI_CTRL_LBL_IssueWnd1, 12, 400, 0, "MS Sans Serif")
    GUICtrlSetState($hGUI_CTRL_LBL_IssueWnd1, $GUI_HIDE)
    $hGUI_CTRL_BTN_Copy2Clip = GUICtrlCreateButton("Copy to Clipboard", 504, 640, 139, 25)
    GUICtrlSetState($hGUI_CTRL_BTN_Copy2Clip, $GUI_HIDE)
    GUICtrlSetBkColor($hGUI_CTRL_BTN_Copy2Clip, 0xC0DCC0)
    For $iLoop = 0 To $iUBound1D Step 1
        $aGUI_CTRL_CHK_GroupedBoxes[$iLoop] = GUICtrlCreateCheckbox("Checkbox" & $iLoop + 1, 504, 184 + (40 * $iLoop), 97, 17)
        GUICtrlSetState($aGUI_CTRL_CHK_GroupedBoxes[$iLoop], $GUI_HIDE)
    Next
    GUICtrlCreateGroup('', -99, -99, 1, 1)
    GUISetState(@SW_SHOW)
EndFunc   ;==>WinGUI_Construct

BTW - kylomas is absolutely right. Most of this has been minor syntax errors. SciTe does a great job of telling you where the error is and what caused it. From there a bit of research should lead you to your answer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...