Sign in to follow this  
Followers 0
FallenAngel617

GUI Checkbox Help

4 posts in this topic

Ok, i am still new to Auto It, so i need some help.

Click a checkbox, then it will enable something when marked when you click "Ok".

Example:

Checkbox one is checked: 1

Checkbox two is checked: 2

Checkbox three isn't checked: 0

Checkbox four is checked: 4

so the code would be 1204 right?

so then i want the #'s to represent words, for example..

0 = (space)

1 = checkbox 1 has been checked,

2 = checkbox 2 has been checked,

3 = checkbox 3 has been checked,

4 = checkbox 4 has been checked,

so it would turn out to be...

"checkbox 1 has been checked,checkbox 2 has been checked, checkbox 4 has been checked,"

you know?

so once the checkmarks are checked, and the 0/1/2/3/4 codes are set, you press "Ok" and it will save those settings.

so now when you... press a button, it types what you saved under the check boxes.

anyone can help me do this, or help me convert what i just said into english? cause it REALLY hard for me to explain how i want this.

THANKS in advance!

Share this post


Link to post
Share on other sites

I'm not sure I can fully understand what are you asking but I'll try to give you an example:

#include <GUIConstants.au3>
$Form1 = GUICreate("AForm1", 147, 152, 193, 115)
$Checkbox1 = GUICtrlCreateCheckbox("ACheckbox1", 10, 16, 121, 17)
$Checkbox2 = GUICtrlCreateCheckbox("ACheckbox2", 10, 36, 121, 17)
$Checkbox3 = GUICtrlCreateCheckbox("ACheckbox3", 10, 57, 121, 17)
$Checkbox4 = GUICtrlCreateCheckbox("ACheckbox4", 10, 76, 121, 17)
$Button1 = GUICtrlCreateButton("OK", 16, 112, 113, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GetCheckboxes()
    EndSwitch
WEnd

Func GetCheckboxes()
    If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
        $display_string1 = "ACheckbox1: CHECKED"
    Else
        $display_string1 = "ACheckbox1: UNCHECKED"
    EndIf
    If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
        $display_string2 = "ACheckbox2: CHECKED"
    Else
        $display_string2 = "ACheckbox2: UNCHECKED"
    EndIf
    If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then
        $display_string3 = "ACheckbox3: CHECKED"
    Else
        $display_string3 = "ACheckbox3: UNCHECKED"
    EndIf
    If GUICtrlRead($Checkbox4) = $GUI_CHECKED Then
        $display_string4 = "ACheckbox4: CHECKED"
    Else
        $display_string4 = "ACheckbox4: UNCHECKED"
    EndIf
    $message_to_show = "Status: "&@CRLF&$display_string1&@CRLF&$display_string2&@CRLF&$display_string3&@CRLF&$display_string4
    MsgBox (0, "Checkbox Status:", $message_to_show)
EndFunc

The script can be made shorter but I deliberately used this way to make the script easier to understand.

Hope it answers your question.


SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
Share on other sites

Hello, thank you for the fast respond.

but i got a few errors in it. One was from the missing "Select", and another said it was missing a "While"

how could you fix this, its somewhere in here:

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GetCheckboxes()
    EndSwitch
WEnd

Thanks

Share this post


Link to post
Share on other sites

What version of AutoIt are you running? It is the latest one (3.2.4.9)?

Are you using SciTE?

Did you copy everything in the code box? I guess you have noticed that you need to scroll a little bit down to get all the code.

Try again to copy the following code (removed the autoit tags).

#include <GUIConstants.au3>
$Form1 = GUICreate("AForm1", 147, 152, 193, 115)
$Checkbox1 = GUICtrlCreateCheckbox("ACheckbox1", 10, 16, 121, 17)
$Checkbox2 = GUICtrlCreateCheckbox("ACheckbox2", 10, 36, 121, 17)
$Checkbox3 = GUICtrlCreateCheckbox("ACheckbox3", 10, 57, 121, 17)
$Checkbox4 = GUICtrlCreateCheckbox("ACheckbox4", 10, 76, 121, 17)
$Button1 = GUICtrlCreateButton("OK", 16, 112, 113, 25, 0)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GetCheckboxes()
    EndSwitch
WEnd

Func GetCheckboxes()
    If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then
        $display_string1 = "ACheckbox1: CHECKED"
    Else
        $display_string1 = "ACheckbox1: UNCHECKED"
    EndIf
    If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then
        $display_string2 = "ACheckbox2: CHECKED"
    Else
        $display_string2 = "ACheckbox2: UNCHECKED"
    EndIf
    If GUICtrlRead($Checkbox3) = $GUI_CHECKED Then
        $display_string3 = "ACheckbox3: CHECKED"
    Else
        $display_string3 = "ACheckbox3: UNCHECKED"
    EndIf
    If GUICtrlRead($Checkbox4) = $GUI_CHECKED Then
        $display_string4 = "ACheckbox4: CHECKED"
    Else
        $display_string4 = "ACheckbox4: UNCHECKED"
    EndIf
    $message_to_show = "Status: "&@CRLF&$display_string1&@CRLF&$display_string2&@CRLF&$display_string3&@CRLF&$display_string4
    MsgBox (0, "Checkbox Status:", $message_to_show)
EndFunc

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0