Sign in to follow this  
Followers 0
Guest nap

reading out checkboxes

23 posts in this topic

hi,

i want to read out the status of checkboxes. how could i do this?

Share this post


Link to post
Share on other sites



Check out ControlCommand().

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

that was not exactly what i was searching for.

i want to read the status of the checkbox and use this value in if... than... else...

Edited by nap

Share this post


Link to post
Share on other sites

Check out ControlCommand().

It will return the checkbox status if you call it like so:

$checked = controlCommand("window title", "window text", controlID, "isChecked")
if ($checked) then
    ...
else
    ...
endIf

Share this post


Link to post
Share on other sites

This is how I did it:

$chkbox = GUICtrlCreateCheckbox(" Adultit Checkbox", -97, 0, 200)
If GUICtrlRead($chkbox) = 1 Then 
    ;do something
EndIf

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered

$chkbox = GUICtrlCreateCheckbox("Adultit Checkbox", 10, 10, 120, 20)
If GUICtrlRead($chkbox) = 1 Then 
    MsgBox(4096, "Is", "Checked")
EndIf

GUISetState ()    ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd

It doesn't work, why?

Share this post


Link to post
Share on other sites

Look at this, may give you and idea:

#include <GUIConstants.au3>

GUICreate("My GUI Checkbox"); will create a dialog box that when displayed is centered

$chkbox = GUICtrlCreateCheckbox("Adultit Checkbox", 10, 10, 120, 20)
$checkCheckBox = GUICtrlCreateButton("Check CheckBox", 10, 50, 120, 20)

GUISetState ()   ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $checkCheckBox
        $CheckRead = GUICtrlRead($chkbox)
        If $CheckRead = $GUI_CHECKED Then
         MsgBox(4096, "Is", "Checked")
        EndIf
    Case $msg = $GUI_EVENT_CLOSE 
        ExitLoop
    EndSelect
WEnd

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Can you make it, when "Opt("GUIOnEventMode", 1)" is on?

That isn't what i want. I need the Checkbox for making a Varible. If it is checked, then make $CHECKBOX = 20 . This is a Option for Coords - a Varibale. Like - Have he it, or not!?

The Option i want to write in a INI-File.

I need help with this problem.

Edited by Zen

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Like this?

#include <GUIConstants.au3>
Dim $CHECKBOX
GUICreate("My GUI Checkbox"); will create a dialog box that when displayed is centered

$chkbox = GUICtrlCreateCheckbox("Adultit Checkbox", 10, 10, 120, 20)
$checkCheckBox = GUICtrlCreateButton("Check CheckBox", 10, 50, 120, 20)

GUISetState ()   ; will display an  dialog box with 1 checkbox

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $chkbox
         $CheckRead = GUICtrlRead($chkbox)
         If $CheckRead = $GUI_CHECKED Then
         $CHECKBOX = "20"
         MsgBox(4096, "NEW COORD","Coord One Is: " & $CHECKBOX)
         EndIf
    Case $msg = $GUI_EVENT_CLOSE
         Exit
    EndSelect

    IF $CHECKBOX = "20" Then
        IniWrite("C:\MYfile.ini" , "Section1", "Key1", $CHECKBOX)
    EndIf
Sleep(100)
WEnd

Edit: Moved Sleep(100) out of Case.

Edited by ronsrules

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thanks a lot, but one little Problem :whistle:

Func Optionen()
    $TestCheck = GUICtrlCreateCheckbox("You have the Test?", 10, 10, 120, 20)
    $TestCheck = "20"
    
    If $TestCheck = "20" Then 
        IniWrite("Optionen.ini" , "Optionen", "Commander", $CommanderCheck) 
        And 
        GUICtrlSetState ($CommanderCheck,1)
    EndIf
EndFunc

When the GUI start again, the Checkbox must be checked. I think this is right, but SciTE says: "ERROR: syntax error" by AND

Where is the mistake?

PS:

I have "Opt("GUIOnEventMode", 1)" in the Code.

.:EDIT:.

When the Checkbox isn't checked, then $TestCheck = "0". Can you add this?

Edited by Zen

Share this post


Link to post
Share on other sites

This:

IniWrite("Optionen.ini" , "Optionen", "Commander", $CommanderCheck)
        And
        GUICtrlSetState ($CommanderCheck,1)

Should be:

IniWrite("Optionen.ini" , "Optionen", "Commander", $CommanderCheck)
        GUICtrlSetState ($CommanderCheck,1)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

$TestCheck = GUICtrlCreateCheckbox("You have the Test?", 10, 10, 120, 20)
    $TestCheck = "20"

The way you have this: $TestCheck will always = "20"

$TestCheck = GUICtrlCreateCheckbox("You have the Test?", 10, 10, 120, 20)
  $CheckTest = ""
  
  If $TestCheck = $GUI_CHECKED Then
      $CheckTest = "20"
IniWrite("Optionen.ini" , "Optionen", "Commander", $CommanderCheck)
        GUICtrlSetState ($CommanderCheck,1)
  EndIf

I got to tell you ... w/ the little bit you posted, I have no idea really if this helps you.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Func Optionen()
    Global $CommanderCheck, $CommanderRead, $Commander

    $CommanderCheck = GUICtrlCreateCheckbox("Commander?", 10, 10, 120, 20)
    $CommanderRead = GUICtrlRead($CommanderCheck)
    
    
    If $CommanderRead = $GUI_UNCHECKED Then
        $Commander = "0"
        IniWrite("Optionen.ini" , "Optionen", "Commander", $Commander)
        GUICtrlGetState($CommanderCheck, 0)
    EndIf
    
    If $CommanderRead = $GUI_CHECKED Then
        $Commander = "20"
        IniWrite("Optionen.ini" , "Optionen", "Commander", $Commander)
        GUICtrlGetState($CommanderCheck, 1)
    EndIf
EndFunc

My next test... it doesn't work. I don't see the mistake! Is this Global important? Can i delete it?

Share this post


Link to post
Share on other sites

Assuming that you have your ini like this:

[Optionen]

Commander=

Try using the full path to your .ini file instead of "Optionen.ini".

The way you have it it will also return 0 and 20 if the checkbox is checked.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

He write the ini. But ever commander=0

When it is checked, then Commander=20 (in the ini)

AND when you start the gui again, the Checkbox is checked.

When it is unchecked, then Commander=0

And when you start the gui again, the Checkbox is unchecked.

This is all, what i want :whistle:

Share this post


Link to post
Share on other sites

#include <guiconstants.au3>
;<>===================START===================<>
; HOPEFULLY THERE IS A GUI UP HERE SOMEWHERE?
;<>===================+END+===================<>
Func Optionen()
    Dim $CommanderCheck
    
    $CommanderCheck = GUICtrlCreateCheckbox("Commander?", 10, 10, 120, 20); is this already created in your GUI above this Function?
    GUISetState()
    
    If $CommanderCheck = $GUI_CHECKED Then
        $Commander = "20"
        IniWrite("Optionen.ini" , "Optionen", "commander", $Commander)
    Else
        $Commander = "0"
        IniWrite("Optionen.ini" , "Optionen", "commander", $Commander); lower cased your commander since you typed it was commander=0 
    EndIf
EndFunc


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC", 0)
Opt("GUIResizeMode", 0)

Opt("TrayIconHide", 1)

$mainwindow = GuiCreate("Zen - ScriptBox - neZ", 400, 350)
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")

$helpmenu = GUICtrlCreateMenu ("?")

$optionitem = GUICtrlCreateMenuitem ("Optionen",$helpmenu)
GUICtrlSetOnEvent($optionitem, "Optionen")

GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
Wend


Func Optionen()
    Dim $CommanderCheck
    
    $CommanderCheck = GUICtrlCreateCheckbox("Commander?", 10, 10, 120, 20); is this already created in your GUI above this Function?
    GUISetState()
    
    If $CommanderCheck = $GUI_CHECKED Then
        $Commander = "20"
        IniWrite("Optionen.ini" , "Optionen", "commander", $Commander)
    Else
        $Commander = "0"
        IniWrite("Optionen.ini" , "Optionen", "commander", $Commander); lower cased your commander since you typed it was commander=0 
    EndIf
EndFunc

Func Terminate()
  If @GUI_WINHANDLE = $mainwindow Then 
    MsgBox(0, "Bye Bye", "Thanks for you visiting :) ", 5)
    Exit
  EndIf 
EndFunc

This is the GUI with your Code! It doesn't work.

Share this post


Link to post
Share on other sites

#18 ·  Posted (edited)

#include <GUIConstants.au3>

Opt("GUIOnEventMode", 1)
Opt("GUICloseOnESC", 0)
Opt("GUIResizeMode", 0)

Opt("TrayIconHide", 1)

$mainwindow = GuiCreate("Zen - ScriptBox - neZ", 400, 350)
GUISetOnEvent($GUI_EVENT_CLOSE, "Terminate")

$helpmenu = GUICtrlCreateMenu ("?")

$optionitem = GUICtrlCreateMenuitem ("Optionen",$helpmenu)
GUICtrlSetOnEvent($optionitem, "Optionen")

GUISetState ()

$msg = 0
While $msg <> $GUI_EVENT_CLOSE
    $msg = GUIGetMsg()
Wend
Func Optionen()
    Dim $CommanderCheck
    
    $CommanderCheck = GUICtrlCreateCheckbox("Commander?", 10, 10, 120, 20); is this already created in your GUI above this Function?
    GUISetState()
    
    If $CommanderCheck = $GUI_CHECKED Then
        $Commander = "20"
        IniWrite("Optionen.ini" , "Optionen", "commander", $Commander)
    Else
        $Commander = "0"
        IniWrite("Optionen.ini" , "Optionen", "commander", $Commander); lower cased your commander since you typed it was commander=0 
    EndIf
EndFunc

Func Terminate()
  If @GUI_WINHANDLE = $mainwindow Then 
    MsgBox(0, "Bye Bye", "Thanks for you visiting :) ", 5)
    Exit
  EndIf 
EndFunc

This is the GUI with your Code! It doesn't work.

<{POST_SNAPBACK}>

you're problem is you're running your gui in event mode, but you've not specified an event for the control. in the help file check out GUICtrlSetOnEvent() function. i'm not going to write your code for you though.

**edit***

fixed typo

Edited by cameronsdad

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

I dont know, how it works.

I know that "Opt("GUIOnEventMode", 1)" on is. I have it write on the top. I dont see the mistake. I need help with the code, then i can see and do it better when i need it again.

Share this post


Link to post
Share on other sites

I dont know, how it works.

I know that "Opt("GUIOnEventMode", 1)" on is. I have it write on the top. I dont see the mistake. I need help with the code, then i can see and do it better when i need it again.

<{POST_SNAPBACK}>

This is 'help with the code'

in the help file check out GUICtrlSetOnEvent() function. i'm not going to write your code for you though

you have events setup for each of the other controls except the checkbox. Right now you have no event setup for your checkbox, so when it's clicked, it just changes the value, nothing else happens. in order to have anything else happen, you need to create an even that calls a function. you've done it in atleast 2 other places in your code, well the person who did your other work for you did, so i am not going to do this for you too. look at the rest of the code, specifically the other controls, they have events assigned to them just about right after they are created.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

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