Jump to content

Problem with Radio and Checkbox


Recommended Posts

Ok well in my GUI i have some radio's set (8 to be exact) and some checkboxes. (3)

I set it so when i press the button on my GUI, it does a function in witch would write in the .ini whatever info was input. However the radio's and checkboxes dont work.

What i did was check If $Whatever = 1, but that doesnt work.

Example:

Radio's and Checkboxes:

$Char1 = GuiCtrlCreateRadio("One", 20, 110, 50, 20)
$Char2 = GuiCtrlCreateRadio("Two", 90, 110, 50, 20)
$Char3 = GuiCtrlCreateRadio("Three", 20, 140, 50, 20)
$Char4 = GuiCtrlCreateRadio("Four", 90, 140, 50, 20)
$Char5 = GuiCtrlCreateRadio("Five", 20, 170, 50, 20)
$Char6 = GuiCtrlCreateRadio("Six", 90, 170, 50, 20)
$Char7 = GuiCtrlCreateRadio("Seven", 20, 200, 50, 20)
$Char8 = GuiCtrlCreateRadio("Eight", 90, 200, 50, 20)
$Cta = GuiCtrlCreateCheckbox("Use CTA?", 260, 130, 100, 20)
$Pre1 = GuiCtrlCreateCheckbox("Intown Precast?", 260, 150, 100, 20)
$Pre2 = GuiCtrlCreateCheckbox("Outside Precast?", 260, 170, 100, 20)

Function to write in .ini:

Func Writebot()
    FileOpen("Settings\FES.ini", 1)
        If $Pre1 = 1 then
            IniWrite("Settings\FES.ini", "Precast", "Intown", "1")
        Else
            IniWrite("Settings\FES.ini", "Precast", "Intown", "0")
        EndIf
        If $Pre2 = 1 then
            IniWrite("Settings\FES.ini", "Precast", "Outside", "1")
        Else
            IniWrite("Settings\FES.ini", "Precast", "Outside", "0")
        EndIf
        If $Cta = 1 Then
            IniWrite("Settings\FES.ini", "Precast", "Cta", "1")
        Else
            IniWrite("Settings\FES.ini", "Precast", "Cta", "0")
        EndIf
        If $Char1 = 1 then
            IniWrite("Settings\FES.ini", "CharSelect", "Position", "1")
        ElseIf $Char2 = 1 then
            IniWrite("Settings\FES.ini", "CharSelect", "Position", "2")
        ElseIf $Char3 = 1 then
            IniWrite("Settings\FES.ini", "CharSelect", "Position", "3")
        ElseIf $Char4 = 1 then
            IniWrite("Settings\FES.ini", "CharSelect", "Position", "4")
        ElseIf $Char5 = 1 then
            IniWrite("Settings\FES.ini", "CharSelect", "Position", "5")
        ElseIf $Char6 = 1 then
            IniWrite("Settings\FES.ini", "CharSelect", "Position", "6")
        ElseIf $Char7 = 1 then
            IniWrite("Settings\FES.ini", "CharSelect", "Position", "7")
        ElseIf $Char8 = 1 then
            IniWrite("Settings\FES.ini", "CharSelect", "Position", "8")
        Else
            IniWrite("Settings\FES.ini", "CharSelect", "Position", "1")
        EndIf
        FileClose("Settings\FES.ini")
        MsgBox( 0, "Fire-Eye-Stinguisher", "TK_Incorperate and Zappie Say: Configuration complete.")
        GUISetState(@SW_HIDE)
        Exit 0
EndFunc

I don't know what my problem is here, but can somebody help me on this one?

Link to comment
Share on other sites

Already tried, i have no clue what to with it when i read it because it isnt a text output.

at some point you have to read the radio or checkbox to see if its checked or not, then you can assign anything you want to it. do you have the au3 helpfile ?

Link to comment
Share on other sites

  • Developers

$Pre1 = GuiCtrlCreateCheckbox("Intown Precast?", 260, 150, 100, 20)

$Pre1 will contain the Handle to the Control. To get the value of a control you need to do a GUICtrlRead() like:

If GUICtrlRead($Pre1) = 1 then

:lmao:

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

$Pre1 = GuiCtrlCreateCheckbox("Intown Precast?", 260, 150, 100, 20)

$Pre1 will contain the Handle to the Control. To get the value of a control you need to do a GUICtrlRead() like:

If GUICtrlRead($Pre1) = 1 then

:lmao:

Thank you very much, works perfectly. Thanks pecloe for trying to help, i got what you said in your second post.

~TK

Link to comment
Share on other sites

Thank you very much, works perfectly. Thanks pecloe for trying to help, i got what you said in your second post.

~TK

the help file is a great tool, sometimes takes a little digging. the more you dig the easier things will go. heres a scrap from help i think

#include <GUIConstants.au3>
GUICreate("")
$CHECK = GUICtrlCreateCheckbox(" CHECKBOX", 10, 10, 120, 20)
$DONE = GUICtrlCreateButton("done", 20, 40, 60, 25)
GUISetState()
While 1
    $MSG = GUIGetMsg()
    $READ2 = GUICtrlRead($CHECK)
    
    If $MSG = $DONE Then
        If $READ2 = $GUI_CHECKED Then
            $II = MsgBox(262145, "", "checked")
        ElseIf $READ2 = $GUI_UNCHECKED Then
            $II = MsgBox(262145, "", "unchecked")
        EndIf
    EndIf
    If $MSG = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

btw i wasn't trying to be a smart A** but it seems some folks don't know there's a helpfile

Edited by pecloe
Link to comment
Share on other sites

the help file is a great tool, sometimes takes a little digging. the more you dig the easier things will go. heres a scrap from help i think

#include <GUIConstants.au3>
GUICreate("")
$CHECK = GUICtrlCreateCheckbox(" CHECKBOX", 10, 10, 120, 20)
$DONE = GUICtrlCreateButton("done", 20, 40, 60, 25)
GUISetState()
While 1
    $MSG = GUIGetMsg()
    $READ2 = GUICtrlRead($CHECK)
    
    If $MSG = $DONE Then
        If $READ2 = $GUI_CHECKED Then
            $II = MsgBox(262145, "", "checked")
        ElseIf $READ2 = $GUI_UNCHECKED Then
            $II = MsgBox(262145, "", "unchecked")
        EndIf
    EndIf
    If $MSG = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

I checked the GUICtralRead and it didn't have that in it. I use an older beta. (I can't find the download link for the newer ones)

~TK

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...