Diana (Cda) Posted August 18, 2011 Share Posted August 18, 2011 (edited) Hi, I just spent time with the radio button demo (this is really branching out for me <g>). I've gotten as far as I can go, it seems. I'd like to know how to get button A to output a specific path for one computer, and for radio button B to output path on another computer, instead of outputting to a messagebox - either path to be stored until called later on in the same script. How can I do this, pls? Here's my variation of the demo code as it stands now: expandcollapse popup#include <GUIconstants.au3> Opt("GUICoordMode", 1) GUICreate("Home or Work ...", 190, 160) ; width, height, left, top ; Create the controls $button_1 = GUICtrlCreateButton ("O&kay", 30, 85, 120, 35) ; left, top, width, height ;$group_1 = GUICtrlCreateGroup ("Group 1", 30, 90, 165, 160) GUIStartGroup() $radio_1 = GUICtrlCreateRadio ("I am at HOME ...", 50, 25, 100, 20) ; left, top, width, height $radio_2 = GUICtrlCreateRadio ("I am at WORK ...", 50, 50, 100, 20) ; left, top, width, height ; Set the defaults (radio buttons clicked, default button, etc) GUICtrlSetState($radio_1, $GUI_CHECKED) GUICtrlSetState($button_1, $GUI_FOCUS + $GUI_DEFBUTTON) ; Init our vars that we will use to keep track of radio events $radioval1 = 0 ; We will assume 0 = first radio button selected, 2 = last button $radioval2 = 2 GUISetState () While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button_1 MsgBox(0, "Path:", "Home " & $radioval1 & @LF & "Work " & Chr($radioval2 + Asc("A")) & @LF) Case $msg = $radio_1 OR $msg = $radio_2 $radioval1 = $msg - $radio_1 EndSelect WEnd Thank you! Edited August 18, 2011 by Diana (Cda) Link to comment Share on other sites More sharing options...
hannes08 Posted August 18, 2011 Share Posted August 18, 2011 (edited) Hi Diana, did you mean sth. like this? While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button_1 If GUICtrlRead($radio_1) = $GUI_CHECKED Then ; We've selected radio 1! ElseIf GUICtrlRead($radio_2) = $GUI_CHECKED Then ; We've selected radio 2! Else ; No Radiobutton selected. EndIf Case $msg = $radio_1 OR $msg = $radio_2 $radioval1 = $msg - $radio_1 EndSelect WEnd Edited August 18, 2011 by Hannes123 Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
Diana (Cda) Posted August 18, 2011 Author Share Posted August 18, 2011 Hi, Hannes123! Yes, that's it. I incorporated the changes and it works almost perfectly. Here are the changes to the while part: While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $button_1 If GUICtrlRead($radio_1) = $GUI_CHECKED Then Beep(150,25) ClipPut("chkdsk " & $USB_FlashDriveLtr & " /r") Sleep(2500) ;close gui here ElseIf GUICtrlRead($radio_2) = $GUI_CHECKED Then Beep(250,50) ClipPut("chkdsk " & $Work_USB_DriveLtr & " /r") Sleep(2500) ;close gui here Else MsgBox("NOTE!", "No radio button has been selected") Sleep(2500) ;close gui here ; No Radiobutton selected. ?? How is this possible? GUI button has either 1 or other radio button selected by default ... EndIf Case $msg = $radio_1 OR $msg = $radio_2 $radioval1 = $msg - $radio_1 EndSelect WEndI was able to put the path, etc., info in directly. Don't know how it would be called later on in the script, but it did work to put the results in right in this part. The only thing I haven't been able to do is to close the selection box. Where it says ";close gui here" I put in the $GUI_EVENT_CLOSE bit as a sort of what-the-hell-we'll-see-if-this-works action but all I got for my pains was a "Cannot assigns values to constants" error message <g>. So how would we close the box upon hitting the Okay button so that user doesn't have to stop and then close that extra box by the X on upper right-hand corner? Thanks! :oD Link to comment Share on other sites More sharing options...
hannes08 Posted August 18, 2011 Share Posted August 18, 2011 1. If you want to run a program after clicking "Okay" just use the Run() command. 2. If you want to close the GUI after clicking "Okay" just insert an "Exit" statement after your Clipput() or Run() function call. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
Diana (Cda) Posted August 18, 2011 Author Share Posted August 18, 2011 Oh, well, a big d'uh!! It's working with a gui that threw me off. Yes, the plain old Exit command works here just fine <g>. Thanks! I'd always wanted to work with radio buttons and this does the job. Cheers. 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