McGyver Posted September 23, 2008 Share Posted September 23, 2008 Looking for a bit of help in handling an error condition. I have an input box that gets a machine name and then does a ping to see if the machine is available on the network. What I am tring to do is make it so that the your can go back and re-enter the machine name on a failure, but I am unsure of how to send them back up to the input box. Any help is appreciated. The exit after Machine Availability: FAILED is where i am looking to send it back up to $machinename = inputbox #Region ### START GUI Machine Name section $Form1 = GUICreate("Tech Tools 1.0", 350, 75) GUISetBkColor(0x000080) $MachineName = InputBox ( "Machine Name", "Enter Machine Name", "", " M" ) If @error = 1 Then Exit ;Verify machine accessible $netvar = Ping ($MachineName);Pings machine to verify availability If $netvar > 0 Then; also possible: If @error = 0 Then ... MsgBox (0,"System Status", "Machine Availability: CONFIRMED") GUICtrlSetBkColor(-1, 0x00ff00) Else MsgBox (0,"System Status", "Machine Availability: FAILED") GUICtrlSetBkColor(-1, 0xff0000) Exit EndIf GUICtrlSetBkColor(-1, 0xC0C0C0) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUISetState(@SW_HIDE) #EndRegion ### END GUI section Link to comment Share on other sites More sharing options...
DjDeep00 Posted September 23, 2008 Share Posted September 23, 2008 @McGyver.... You need to use GUICtrlCreateInput not InputBox. Look in the help file for the example of GUICtrlCreateInput(). Besides you are McGyver you should be able to figure out anything. Link to comment Share on other sites More sharing options...
DaRam Posted September 23, 2008 Share Posted September 23, 2008 Besides you are McGyver you should be able to figure out anything. >_< Link to comment Share on other sites More sharing options...
McGyver Posted September 23, 2008 Author Share Posted September 23, 2008 @McGyver....You need to use GUICtrlCreateInput not InputBox. Look in the help file for the example of GUICtrlCreateInput().Besides you are McGyver you should be able to figure out anything. Ok, I understand that I built the box wrong, but that does not help me with returning to the input if a machine fails the ping test Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 23, 2008 Share Posted September 23, 2008 Ok, I understand that I built the box wrong, but that does not help me with returning to the input if a machine fails the ping test You do it in loop that you don't exit until you get what you want: While 1 $MachineName = InputBox("Machine Name", "Enter Machine Name", "", " M") If @error = 1 Then Exit ;Verify machine accessible $netvar = Ping($MachineName);Pings machine to verify availability If $netvar > 0 Then; also possible: If @error = 0 Then ... MsgBox(0, "System Status", "Machine Availability: CONFIRMED") ExitLoop Else MsgBox(0, "System Status", "Machine Availability: FAILED") EndIf WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
McGyver Posted September 23, 2008 Author Share Posted September 23, 2008 Thanks That pointed me in the right direction Link to comment Share on other sites More sharing options...
DaRam Posted September 23, 2008 Share Posted September 23, 2008 Thanks That pointed me in the right directionOr as DjDeep00 nudged you to.... #include <GUIConstants.au3> #Region ### START GUI Machine Name section $Form1 = GUICreate("Tech Tools 1.0", 350, 75) GUISetBkColor(0x000080) $Btn_Ping = GUICtrlCreateButton("Ping", 8, 8, 73, 25, 0) $Txt_MachineName = GUICtrlCreateInput("Machine Name", 88, 8, 150, 21) GUICtrlSetTip(-1, " Enter Machine Name ") GUISetState(@SW_SHOW) #EndRegion ### END GUI section While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $Btn_Ping $MachineName = GUICtrlRead($Txt_MachineName, 1) If StringLen($MachineName) < 1 Then MsgBox(0, "Eh?", "Enter a Machine Name First !") ContinueLoop EndIf ;Verify machine accessible $netvar = Ping ($MachineName);Pings machine to verify availability If $netvar > 0 Then; also possible: If @error = 0 Then ... MsgBox (0,"System Status", "Machine Availability: CONFIRMED") GUICtrlSetBkColor(-1, 0x00ff00) Else MsgBox (0,"System Status", "Machine Availability: FAILED") GUICtrlSetBkColor(-1, 0xff0000) EndIf EndSwitch WEnd Link to comment Share on other sites More sharing options...
Community On Patrol Posted September 23, 2008 Share Posted September 23, 2008 Hi McGyver, Doing a search of your topic, it's been found many times with the search feature or is listed as a non-descriptive topic. Please do a search before posting new thread topics. And please use descriptive topics so that others that do use the search feature may also find what they are seeking. (You'll also find that using descriptive topics, will get people in your thread that know how to answer your questions, those same people ignore non-descriptive topics). Thanks. 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