LurchMan Posted May 3, 2013 Share Posted May 3, 2013 Hello Everyone - I'm working with radio buttons and I'm attempting to get the state of the button to see which one has been pressed. I have a small example script below. I cannot seem to get it to report anything different from any of the radio buttons. I have also tried using GuiCtrlRead () to no avail. Any help is appreciated! #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3>Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Form1", 498, 242, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Radio1 = GUICtrlCreateRadio("Radio1", 104, 48, 113, 17) $Radio2 = GUICtrlCreateRadio("Radio2", 104, 96, 113, 17) $Radio3 = GUICtrlCreateRadio("Radio3", 104, 152, 113, 17) GUICtrlCreateButton ("click me", 50, 10) GUICtrlSetOnEvent(-1, "ClickMe") GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Form1Close() Exit EndFunc Func ClickMe () $State1 = GUICtrlGetState ($Radio1) $State2 = GUICtrlGetState ($Radio2) $State3 = GUICtrlGetState ($Radio3) ConsoleWrite($State1 & " " & $State2 & " " & $State3 & @LF) EndFunc Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 3, 2013 Moderators Share Posted May 3, 2013 (edited) Hi, LurchMan. GuiCtrlGetState only gets the state of the control (enabled/disabled/hidden/etc.). I think you may be looking for something like GUICtrlRead instead. Try this:#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) $Form1 = GUICreate("Form1", 498, 242, 192, 124) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") $Radio1 = GUICtrlCreateRadio("Radio1", 104, 48, 113, 17) $Radio2 = GUICtrlCreateRadio("Radio2", 104, 96, 113, 17) $Radio3 = GUICtrlCreateRadio("Radio3", 104, 152, 113, 17) GUICtrlCreateButton ("click me", 50, 10) GUICtrlSetOnEvent(-1, "ClickMe") GUISetState(@SW_SHOW) While 1 Sleep(100) WEnd Func Form1Close() Exit EndFunc Func ClickMe () Select Case GUICtrlRead($Radio1) = 1 ConsoleWrite("Radio Button 1 is selected!") Case GUICtrlRead($Radio2) = 1 ConsoleWrite("Radio Button 2 is selected!") Case GUICtrlRead($Radio3) = 1 ConsoleWrite("Radio Button 3 is selected!") EndSelect EndFunc Edited May 3, 2013 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
LurchMan Posted May 3, 2013 Author Share Posted May 3, 2013 (edited) I could have sworn I tried using GuiCtrlRead () but apparently not. Thanks for the help! Edited May 3, 2013 by LurchMan Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 3, 2013 Moderators Share Posted May 3, 2013 Glad to be of service**Warning, shamelessly stolen from Water "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! 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