ZenKensei Posted December 28, 2004 Share Posted December 28, 2004 (edited) Group, I've been working on a GUI application whereby I want to perform various actions selected by a radio button against a server located in a list box. I have the code written to the point where it recognizes any of the controls as a single object, i.e. clicking the list box brings me back the server name, pressing the 'ping' button tells me I've pressed it, etc. My problem is performing a conditional statement based on a radio button selection against a listbox item. Below is the code I've written so far: expandcollapse popup#include <GUIConstants.au3> GUICreate("Server Tools"); will create a dialog box that when displayed is centered ; create serverlist $ServerList = "" $file = FileOpen("servers.txt", 0); 'servers.txt' contains the name of servers, one per line, to work with ; Check if file opened for reading OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Read in lines of text until the EOF is reached While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $ServerList = $ServerList & "|" & $line Wend FileClose($file) ; create gui GUICtrlCreateLabel("Pick Your Server From The List At Right", 64, 32, 100, 75) $ping = GUICtrlCreateRadio("Ping", 65, 125, 75, 25) GUICtrlSetState($ping, $GUI_UNCHECKED) $FTP = GUICtrlCreateRadio("FTP", 65, 150, 75, 25) GUICtrlSetState($FTP, $GUI_UNCHECKED) $close = GUICtrlCreateButton("Exit", 65, 200, 100, 25) $mylist = GUICtrlCreateList("", 176, 32, 121, 97) GUICtrlSetLimit(-1, 200); to limit horizontal scrolling GUICtrlSetData(-1, $ServerList) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = ($FTP) MsgBox(0, "FTP", "You Checked the FTP Box", 2) Case $msg = ($ping) MsgBox(0, "Pinging", "You Checked the Ping Box", 2) Case $msg = $mylist $ServerName = $mylist _RunFunc(GUICtrlRead ($ServerName)) Case $msg = $close MsgBox(0, "EXIT", "Closing the Application", 2) Exit EndSelect Wend ; Func _RunFunc($ServerName) MsgBox(4096, 'Retail Server', 'ServerName: ' & $ServerName) EndFunc ;==>_RunFunc My goal is to select the desired radio button then select the desired server and have the action from the radio button performed on the server from the listbox that is selected. I'm unsure how to tie in any type of CASE or IF THEN statement to test for $FTP & $mylist or $ping & $mylist. Or am I going about this all wrong, should I be using different control types. Thanks in advance, ZK Edited December 28, 2004 by ZenKensei Link to comment Share on other sites More sharing options...
CyberSlug Posted December 28, 2004 Share Posted December 28, 2004 (edited) I'd use normal buttons instead of radio buttons; however, your GUI should work if you simply modify the Select-Case block: $ServerSelected = GUICtrlRead($mylist) Select Case $msg = ($FTP) MsgBox(0, "FTP", "Would perform something like ftp://" & $ServerSelected, 2) ;do FTP stuff.... Case $msg = ($ping) MsgBox(0, "Pinging", "Pinging " & $ServerSelected, 2) ;Run("cmd /c ping " & $ServerSelected) Case $msg = $close MsgBox(0, "EXIT", "Closing the Application", 2) Exit EndSelect Edited December 28, 2004 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
ZenKensei Posted December 28, 2004 Author Share Posted December 28, 2004 Cyberslug, First, thanks as always for the response. The help file is of course a necessity, but nothing takes the place of seeing someone else's take on a piece of code. It never occurred to me to use 'normal' buttons, I guess it would make more sense in the long run (especially when performing multiple functions from the same script instance), i.e. perform a ping of a server, then an FTP session, then an RClient connection, etc. etc. Thanks again, ZK 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