daniel02 Posted April 13, 2009 Posted April 13, 2009 Hi all, I tired now for several minutes work with a checkbox but I can get it run. Also the help file did not help me For you guys it will be very easy I think. If the checkbox is "checked" I want to set a variable to 1. If it is not checked to 0. As log as the script is running I want to be able to change the state of this variable with the checkbox. The only thing I found is $GUI_UNCHECKED $GUI_CHECKED but I am not sure how to work with it. Thanks in advance Daniel
DaRam Posted April 13, 2009 Posted April 13, 2009 Search the help file for '_GUICtrlButton_GetCheck', there is an example script using radio buttons and a check boxI tired now for several minutes work with a checkbox but I can get it run. Also the help file did not help me
daniel02 Posted April 13, 2009 Author Posted April 13, 2009 Mh the example is not working. If I run it and check the boxes or change the control buttons it did not change the values.
DaRam Posted April 13, 2009 Posted April 13, 2009 Post your code or fragment you are having trouble withMh the example is not working. If I run it and check the boxes or change the control buttons it did not change the values.
Developers Jos Posted April 13, 2009 Developers Posted April 13, 2009 #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Global $checkCN, $msg, $Checked = 0 GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered $checkCN = GUICtrlCreateCheckbox("CHECKBOX 1", 10, 10, 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 = $GUI_EVENT_CLOSE ExitLoop Case $msg = $checkCN If GUICtrlRead($checkCN) = $GUI_CHECKED Then $Checked = 1 Else $Checked = 0 EndIf EndSelect WEnd 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.
nitekram Posted April 13, 2009 Posted April 13, 2009 (edited) #include <GUIConstantsEx.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $checkCN, $msg GUICreate("My GUI Checkbox") ; will create a dialog box that when displayed is centered $checkCN = GUICtrlCreateCheckbox("CHECKBOX 1", 10, 10, 120, 20) GUICtrlSetState(-1, $GUI_CHECKED) ; the checkbox is checked 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 EndFunc ;==>Example Edited April 13, 2009 by nitekram 2¢ All by me:"Sometimes you have to go back to where you started, to get to where you want to go." "Everybody catches up with everyone, eventually" "As you teach others, you are really teaching yourself." From my dad "Do not worry about yesterday, as the only thing that you can control is tomorrow." WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2 AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit Docs SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language Programming Tips Excel Changes ControlHover.UDF GDI_Plus Draw_On_Screen GDI Basics GDI_More_Basics GDI Rotate GDI Graph GDI CheckExistingItems GDI Trajectory Replace $ghGDIPDll with $__g_hGDIPDll DLL 101? Array via Object GDI Swimlane GDI Plus French 101 Site GDI Examples UEZ GDI Basic Clock GDI Detection Ternary operator
daniel02 Posted April 13, 2009 Author Posted April 13, 2009 I just wantED to set the debug mode on or off with the checkbox.. And it is working now Thanks a lot!!!! Here is my code perhaps there is a better way? GuiCreate($Prog_Title, 200, 250) WinSetOnTop($Prog_Title, "", 1) $start = GUICtrlCreateButton(" Start ",10, 10) $stop = GUICtrlCreateButton(" Stop ", 80, 10) $debugon = GUICtrlCreateCheckbox ("Debug Mode", 5, 130) GUICtrlCreateLabel("Current Function/Debug:", 5, 150) $CurrentFunction = GUICtrlCreateInput("Function", 5, 170, 125, 20) GuiSetState() While 1 If ControlCommand ( $Prog_Title, "", $debugon, "IsChecked") = 1 $debug=1 Else $debug=0 endif $msg = GUIGetMsg() Select Case $msg = $start ;CorrectHeadingNew($zieloxpos, $zieloypos) heading() Case $msg = $stop Exit Case $msg = $GUI_EVENT_CLOSE Exit EndSelect WEnd Func heading() If $debug = 1 Then GUICtrlSetData($CurrentFunction, " Heading ") $d1=abs($headpos - $zipos) If abs($headpos - $zielheadpos) < 180 Then MsgBox(0, "Heading", "right" &$d1) Else MsgBox(0, "Heading", "left"&$d1) EndIf EndFunc ; ######## heading
andybiochem Posted April 14, 2009 Posted April 14, 2009 ...perhaps there is a better way? Maybe not better per se, but shorter.... replace: If ControlCommand($Prog_Title, "", $debugon, "IsChecked") = 1 Then $debug = 1 Else $debug = 0 EndIf with this: $debug = 0 If GUICtrlRead($debugon) = 1 Then $debug = 1 - Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!
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