AntiVirusGuy Posted May 16, 2005 Posted May 16, 2005 This is a script from another user that I simplified since I only need to ping two destinations. I do not understand how radio buttons work does anyone have a nice easy example or can you tell me why this does not work thanks a bunch #include <GuiConstants.au3> GuiCreate("Ping Tool", 300, 300) GuiSetIcon(@SystemDir & "\mspaint.exe", 0) ; selection GUISetFont (16, 400, 0, "Arial") $radio = GuiCtrlCreateGroup("Domain Controller:", 30, 20, 180, 100) $radio1 = GuiCtrlCreateRadio("CSCDC1", 50, 40, 120) GuiCtrlSetState(-1, $GUI_CHECKED) $radio2 = GuiCtrlCreateRadio("CSCDC2", 50, 80, 120) GUICtrlCreateGroup ("",-99,-99,1,1);close group ; create ping button $ping= GUICtrlcreateButton("Ping!", 130, 250, 60, 35) ; GUI MESSAGE LOOP GuiSetState() While 1 $msg = GUIGetMsg() Select Case GUICtrlRead($radio1) = $GUI_CHECKED $ip = "novell.com" Case GUICtrlRead($radio2) = $GUI_CHECKED $ip = "yahoo.com" Case $msg = $ping RunWait(@ComSpec & " /C Ping -a -n 1 " & $ip & " > Find_IP.txt",@MyDocumentsDir, @SW_HIDE) $ip = FileRead(@MyDocumentsDir & "\Find_IP.txt", FileGetSize(@MyDocumentsDir & "\Find_IP.txt")) FileDelete(@MyDocumentsDir & "\Find_IP.txt") MsgBox(0,"Returned Ping String [data]", "" & $ip) ; MsgBox(0,"" & $strcomputer & " IP:", "" & $ip) EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd
MSLx Fanboy Posted May 16, 2005 Posted May 16, 2005 remove the Cases where you are checking the radio, and just put in the Case $msg = $ping area If $GUICtrlRead($radio1) = $GUI_CHECKED Then $ip = "novell.com" Else $ip = "yahoo.com" EndIf make sure to put that before the RunWait Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
steveR Posted May 16, 2005 Posted May 16, 2005 (edited) It might be because the program is never reaching the $ping case. It checks the radio button and skips the rest expandcollapse popup#include <GuiConstants.au3> GUICreate("Ping Tool", 300, 300) GUISetIcon(@SystemDir & "\mspaint.exe", 0) ; selection GUISetFont(16, 400, 0, "Arial") $radio = GUICtrlCreateGroup("Domain Controller:", 30, 20, 180, 100) $radio1 = GUICtrlCreateRadio("CSCDC1", 50, 40, 120) GUICtrlSetState(-1, $GUI_CHECKED) $radio2 = GUICtrlCreateRadio("CSCDC2", 50, 80, 120) GUICtrlCreateGroup("", -99, -99, 1, 1);close group ; create ping button $ping = GUICtrlCreateButton("Ping!", 130, 250, 60, 35) ; GUI MESSAGE LOOP GUISetState() While 1 $msg = GUIGetMsg() If GUICtrlRead($radio1) = $GUI_CHECKED Then $ip = "novell.com" Else $ip = "yahoo.com" EndIf Select Case $msg = $ping ConsoleWrite("ping") ConsoleWrite(@ComSpec & " /C Ping -a -n -1 " & $ip & " > Find_IP.txt") RunWait(@ComSpec & " /C Ping -a -n -1 " & $ip & " > Find_IP.txt", @MyDocumentsDir, @SW_HIDE) $ip = FileRead(@MyDocumentsDir & "\Find_IP.txt", FileGetSize(@MyDocumentsDir & "\Find_IP.txt")) FileDelete(@MyDocumentsDir & "\Find_IP.txt") MsgBox(0, "Returned Ping String [data]", "" & $ip) ; MsgBox(0,"" & $strcomputer & " IP:", "" & $ip) EndSelect If $msg = $GUI_EVENT_CLOSE Then ExitLoop WEnd Edited May 16, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
AntiVirusGuy Posted May 16, 2005 Author Posted May 16, 2005 ok i understand the if and else what if I want to have 4 or 5 options how do I do that?It might be because the program is never reaching the $ping case. It checks the radio button and skips the rest<{POST_SNAPBACK}>
steveR Posted May 16, 2005 Posted May 16, 2005 (edited) Just add more elseIf <exp[b][/b]ression> Then statements ... [ElseIf exp[b][/b]ression-n Then [elseif statements ... ]] ... [Else [else statements] ... EndIf or use select case/endselectSelect Case <exp[b][/b]ression> statement1 ... [Case statement2 ...] [Case Else statementN ...] EndSelect Edited May 16, 2005 by steveR AutoIt3 online docs Use it... Know it... Live it...MSDN libraryglobal Help and SupportWindows: Just another pane in the glass.
MSLx Fanboy Posted May 16, 2005 Posted May 16, 2005 Embed the select statements for the radios within the Ping! case statement Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
MSLx Fanboy Posted May 16, 2005 Posted May 16, 2005 While $msg <> $GUI_EVENT_CLOSE If $msg = $ping Then If GUICtrlRead($radio1) Then $ip = "site1.com" If GUICtrlRead($radio2) Then $ip = "site2.com" If GUICtrlRead($radio3) Then $ip = "site3.com" If GUICtrlRead($radio4) Then $ip = "site4.com" RunWait(@ComSpec & " /c ping -a -n -1" & $ip & " > Find_IP.txt", @MyDocumentsDir, @SW_HIDE) ;...more stuff WEnd Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
AntiVirusGuy Posted May 17, 2005 Author Posted May 17, 2005 perfect thank youWhile $msg <> $GUI_EVENT_CLOSE If $msg = $ping Then If GUICtrlRead($radio1) Then $ip = "site1.com" If GUICtrlRead($radio2) Then $ip = "site2.com" If GUICtrlRead($radio3) Then $ip = "site3.com" If GUICtrlRead($radio4) Then $ip = "site4.com" RunWait(@ComSpec & " /c ping -a -n -1" & $ip & " > Find_IP.txt", @MyDocumentsDir, @SW_HIDE) ;...more stuffWEnd<{POST_SNAPBACK}>
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