Guest nap Posted August 2, 2005 Posted August 2, 2005 hi, i want to read out the status of checkboxes. how could i do this?
Guest nap Posted August 2, 2005 Posted August 2, 2005 (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 August 2, 2005 by nap
LxP Posted August 2, 2005 Posted August 2, 2005 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
Arrrghmatey Posted August 2, 2005 Posted August 2, 2005 This is how I did it: $chkbox = GUICtrlCreateCheckbox(" Adultit Checkbox", -97, 0, 200) If GUICtrlRead($chkbox) = 1 Then ;do something EndIf
Zen Posted August 9, 2005 Posted August 9, 2005 #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?
Moderators SmOke_N Posted August 9, 2005 Moderators Posted August 9, 2005 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.
Zen Posted August 10, 2005 Posted August 10, 2005 (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 August 10, 2005 by Zen
Moderators SmOke_N Posted August 10, 2005 Moderators Posted August 10, 2005 (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 August 10, 2005 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.
Zen Posted August 10, 2005 Posted August 10, 2005 (edited) Thanks a lot, but one little Problem 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 August 10, 2005 by Zen
Moderators SmOke_N Posted August 10, 2005 Moderators Posted August 10, 2005 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.
Moderators SmOke_N Posted August 10, 2005 Moderators Posted August 10, 2005 $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.
Zen Posted August 10, 2005 Posted August 10, 2005 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?
Moderators SmOke_N Posted August 10, 2005 Moderators Posted August 10, 2005 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.
Zen Posted August 10, 2005 Posted August 10, 2005 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
Moderators SmOke_N Posted August 10, 2005 Moderators Posted August 10, 2005 #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.
Zen Posted August 10, 2005 Posted August 10, 2005 expandcollapse popup#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.
seandisanti Posted August 10, 2005 Posted August 10, 2005 (edited) expandcollapse popup#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 EndFuncThis 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 August 11, 2005 by cameronsdad
Zen Posted August 11, 2005 Posted August 11, 2005 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.
seandisanti Posted August 11, 2005 Posted August 11, 2005 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 thoughyou 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now