Frit Posted March 10, 2006 Share Posted March 10, 2006 My question is simple: How do I get variable information from checkboxes and buttons? I want to make the program knows when the check box (or button) is marked to do something I want. Link to comment Share on other sites More sharing options...
cppman Posted March 10, 2006 Share Posted March 10, 2006 Here is how to get wether a checkbox or radio button is checked.... $GUI_UNCHECKED Radio or Checkbox will be unchecked $GUI_CHECKED Radio or Checkbox will be checked for buttons While 1 ;Starts an INFINITE LOOP $msg = GUIGetMsg() ;Listens to see if a control is pressed case $msg = $YourButtonVariable ; If the control that is pressed is your button then.. note($YourButtonVariable is the variable you made your button in.. ex. $Button_1 = GUICtrlCreateButton()) ExecuteFunctionName() ;execute this function... WEnd Hope that helps Miva OS Project Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 10, 2006 Moderators Share Posted March 10, 2006 If it's your own GUI, you'll use the $ sign before the creation to create the variable. $GUI = GUICreate('Title') $CheckBox1 = GUICtrlCreateCheckBox('CkBox', 10, 10) GUISetState() While 1 $msg = GUIGetMsg() If $msg = - 3 Then Exit If $msg = $CheckBox1 And GUICtrlRead($CheckBox1) = 1 Then MsgBox(0, '', 'You Checked the check box') EndIf Sleep(10) Wend If it's another application, look up ControlCommand() in the help file. 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. Link to comment Share on other sites More sharing options...
Valuater Posted March 10, 2006 Share Posted March 10, 2006 (edited) #include <GUIConstants.au3> GUICreate("My GUI radio"); will create a dialog box that when displayed is centered $radio1 = GUICtrlCreateRadio ("Radio 1", 10, 10, 120, 20) GUICtrlSetState ($radio1,$GUI_CHECKED) $radio2 = GUICtrlCreateRadio ("Radio 2", 10, 40, 120, 20) $btn = GUICtrlCreateButton( "Test", 100, 100, 100, 20) GUISetState () ; will display an dialog box with 1 checkbox ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $btn Then If BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED Then MsgBox(0,"test", " Radio 1 was checked ") ElseIf BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED Then MsgBox(0,"test", " Radio 2 was checked ") EndIf EndIf If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend 8) getting slower am i Edited March 10, 2006 by Valuater Link to comment Share on other sites More sharing options...
Frit Posted March 10, 2006 Author Share Posted March 10, 2006 @Chris Your script has an error. I thinks it's with the "case" part. Something about a "select". Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 10, 2006 Moderators Share Posted March 10, 2006 @Chris Your script has an error. I thinks it's with the "case" part. Something about a "select".Get on him!!! Tell him to use [ code] [/ code] tags too while your at it!! 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. Link to comment Share on other sites More sharing options...
cppman Posted March 10, 2006 Share Posted March 10, 2006 (edited) Get on him!!! Tell him to use [ code] [/ code] tags too while your at it!!hahah... I did'nt even provide full code?????????? im confused.... what was the error message? i don't even have a case statement in their... lol Edited March 10, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
greenmachine Posted March 10, 2006 Share Posted March 10, 2006 Here is how to get wether a checkbox or radio button is checked....$GUI_UNCHECKED Radio or Checkbox will be unchecked $GUI_CHECKED Radio or Checkbox will be checked for buttonsWhile 1 ;Starts an INFINITE LOOP$msg = GUIGetMsg() ;Listens to see if a control is pressedcase $msg = $YourButtonVariable ; If the control that is pressed is your button then.. note($YourButtonVariable is the variable you made your button in.. ex. $Button_1 = GUICtrlCreateButton())ExecuteFunctionName() ;execute this function...WEndHope that helpshahah... I did'nt even provide full code??????????im confused....what was the error message? i don't even have a case statement in their... lolThis line sure looks like a case statement to me: case $msg = $YourButtonVariableThe rest of the guys posted code, so I'm not going to.... Link to comment Share on other sites More sharing options...
cppman Posted March 10, 2006 Share Posted March 10, 2006 (edited) oh, woops, i did'nt see that.. sorry people... While 1;Starts an INFINITE LOOP $msg = GUIGetMsg();Listens to see if a control is pressed select case $msg = $YourButtonVariable; If the control that is pressed is your button then.. note($YourButtonVariable is the variable you made your button in.. ex. $Button_1 = GUICtrlCreateButton()) ExecuteFunctionName();execute this function... EndSelect WEnd urrr, today is not my day... Edited March 10, 2006 by CHRIS95219 Miva OS Project Link to comment Share on other sites More sharing options...
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