mazwoz Posted August 18, 2007 Share Posted August 18, 2007 Hey guys i am having a slight issue trying to get a ping /t to stop without opening the taskmgr and killing the process. blow is my coding, if someone could please help me out i would much appreciate it. Also does anyone know how to close a "help" window without closing the entire program and to where i can still run the main program? CODE#include <GUIConstants.au3> #include"constants.au3" #include<misc.au3> #include<guiedit.au3> #include<file.au3> #include<INET.AU3> #Region ### START Koda GUI section ### Form=c:\documents and settings\bret\my documents\fun\nettestunlimited.kxf $Form2 = GUICreate("Net Test", 931, 585, 214, 118) GUISetIcon("D:03.ico") $file = GUICtrlCreateMenu("File") $filesave = GUICtrlCreateMenuitem("Save", $file) $fileexit = GUICtrlCreateMenuitem("Exit", $file) $help = GUICtrlCreateMenu("Help") $helpme = GUICtrlCreateMenuItem("?Help?", $help) $IP = InputBox("IP Address/Computer name:","Please Inpute the IP Address or the Computer Name here:","192.168.0.1") $GroupBox1 = GUICtrlCreateGroup("", 0, -7, 929, 585) GUICtrlSetImage($GroupBox1,"matrix02.bmp") $PING = GUICtrlCreateButton("PING", 16, 88, 75, 25, 0) $Pingt = GUICtrlCreateButton("PING /T", 112, 88, 75, 25, 0) $cancelping = GUICtrlCreateButton ("Cancel Ping", 200,88,75,25,0) $TRACERT = GUICtrlCreateButton("TRACERT", 16, 144, 75, 25, 0) $IPCONFIG = GUICtrlCreateButton("IPCONFIG", 16, 312, 75, 25, 0) $ipconfigall = GUICtrlCreateButton("IPCONFIG /ALL", 112, 312,85,25,0) $ipCOnfigrel = GUICtrlCreateButton("IPCONFIG /REL", 218, 312, 85, 25, 0) $IPCONFIGREN = GUICtrlCreateButton("IPCONFIG /REN", 324, 312, 85, 25, 0) $NETSTAT = GUICtrlCreateButton("NETSTAT", 16, 256, 75, 25, 0) $NSLOOKUP = GUICtrlCreateButton("NSLOOKUP", 16, 200, 75, 25, 0) $Button1 = GUICtrlCreateButton("&EXIT", 16, 425, 75, 25, 0) $command = GUICtrlCreateInput("Command Line Text", 16, 500, 200,25,0) $enter = GUICtrlCreateButton("Enter", 250, 500,75,25,1) $CHANGEIP = GUICtrlCreateButton("CHANGEIP", 16, 369, 75, 25, 0) $IPADDRESS = GUICtrlCreateLabel("IP ADDRESS/HOST NAME" & @CRLF & @CRLF & @CRLF & $IP , 24, 32, 138, 17) $GUIedit = GUICtrlCreateEdit("", 488, 40, 433, 433) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetBkColor(-1, 0x000000) $dispip = GUICtrlCreateLabel($ip, 24, 48, 260, 28) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### func gui2() GUICreate("Cancel Ping",100,50, 50, 50, $ws_popup, $ws_ex_topmost, $form2) $cancelping = GUICtrlCreateButton("Cancel Ping", 5,5,75,25,0) GUISetState(@sw_show) WinActivate("Net Test") While 1 $nmsg = GUIGetMsg() Switch $nmsg Case $cancelping ProcessClose ("cmd.exe") ProcessClose ("ping.exe") GUIDelete("Cancel Ping") EndSwitch WEnd EndFunc func guihelp() $Form1 = GUICreate("HELP!!!", 633, 447, 193, 115) $Label1 = GUICtrlCreateLabel("ABOUT/HELP", 150, 8, 400, 41) GUICtrlSetFont(-1, 24, 800, 2, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("1. IF YOU DONT KNOW WHAT THE BUTTONS MEAN DON'T USE THEM, OR ASK YOUR SYSTEM ADMINISTRATOR", 24, 88, 587, 25) $Label3 = GUICtrlCreateLabel("2. TO REPORT ERRORS PLEASE EMAIL ADMIN@BRETZAMZOW.COM", 24, 120, 361, 17) $Label4 = GUICtrlCreateLabel("3. THE COMMAND LINE OPTION DOES NOT HAVE FULL FUNCTIONALITY BUT WILL WORK WITH MOST COMMANDS", 24, 152, 599, 17) $Label5 = GUICtrlCreateLabel("4. THIS PROGRAM WAS WRITTEN BY BRET ZAMZOW. THANKS TO EVERYONE WHO HELPED", 24, 184, 488, 17) $Label6 = GUICtrlCreateLabel("A SPECIAL THANKS GOES OUT TO THE AUTOIT CREW AND SGT RO-RO FOR DESIGN HELP AND FUNCTIONALITY", 24, 216, 589, 17) $close = GUICtrlCreateButton("Exit", 195, 248, 75, 25, 0) $Pic1 = GUICtrlCreatePic("C:\Documents and Settings\Bret\My Documents\My Pictures\BRETZAMZOW.jpg", 40, 280, 529, 129, BitOR($SS_NOTIFY,$WS_GROUP)) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg case $gui_event_close ExitLoop CASE $close ExitLoop EndSwitch WEnd EndFunc Opt("TrayMenuMode",1) ; Default tray menu items (Script Paused/Exit) will not be shown. TrayCreateItem("") $aboutitem = TrayCreateItem("About") TrayCreateItem("") $exititem = TrayCreateItem("Exit") TraySetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $Button1 ExitLoop Case $PING ; $get = GUICtrlGetHandle($IP) $ping2 = Run(@ComSpec & " /c ping.exe " & $IP, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $lineping = StdoutRead($ping2) If @error Then ExitLoop GUICtrlSetData($GUIEdit, $lineping, 1) WEnd While 1 $line = StderrRead($lineping) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) WEnd Case $TRACERT ; $get = GUICtrlGetHandle($IP) $trace = Run(@ComSpec & " /c tracert.exe " & $IP, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $linetrace = StdoutRead($trace) If @error Then ExitLoop GUICtrlSetData($GUIEdit, $linetrace, 1) WEnd While 1 $line = StderrRead($linetrace) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) WEnd case $NSLOOKUP $look = Run(@ComSpec & " /c nslookup" & " " & $IP, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) If @Error = -1 Then ExitLoop $linelook = StdoutRead($look) GUICtrlSetData($GUIEdit, $linelook & @CRLF, 1) case $NETSTAT $stat = Run(@ComSpec & " /c netstat", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) If @Error = -1 Then ExitLoop $linestat = StdoutRead($stat) GUICtrlSetData($GUIEdit, $linestat & @CRLF, 1) case $IPCONFIG $config = Run(@ComSpec & " /c ipconfig", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) If @Error = -1 Then ExitLoop $lineconfig = StdoutRead($config) GUICtrlSetData($GUIEdit, $lineconfig & @CRLF, 1) case $IPCONFIGall $CONFIGALL = Run(@ComSpec & " /c ipconfig /all", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $lineCONFIG = StdoutRead($CONFIGALL) If @error Then ExitLoop GUICtrlSetData($GUIEdit, $lineCONFIG, 1) WEnd While 1 $line = StderrRead($lineCONFIG) If @error Then ExitLoop MsgBox(0, "ERROR:", $line) WEnd CASE $CHANGEIP $IP = InputBox("IP ADDRESS/HOST NAME","Input the IP Address or Host Name here:", "192.168.0.1" ,"",16, 32, 153, 21) $IPADDRESS = GUICtrlCreateLabel("IP ADDRESS:" & @CRLF & @crlf & $IP, 24, 32, 146, 41) case $enter $command2 = GUICtrlRead($command) $RUNNCOMMAND = Run(@ComSpec & " /c " & $command2, @WindowsDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $lineCOMMAND = StdoutRead($RUNNCOMMAND) If @error Then ExitLoop GUICtrlSetData($GUIEdit, $lineCOMMAND, 1) WEnd While 1 $lineERR = StderrRead($RUNNCOMMAND) If @error Then ExitLoop MsgBox(0, "ERROR:", $LINEERR) WEnd Case $PINGT ; $get = GUICtrlGetHandle($IP) $pingT2 = Run(@ComSpec & " /c ping.exe -t " & $IP, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $lineping = StdoutRead($pingT2) If @error Then ExitLoop GUICtrlSetData($GUIEdit, $lineping, 1) WEnd While 1 $line = StderrRead($lineping) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) WEnd case $cancelping if ProcessExists ("ping.exe") then ProcessClose("ping.exe") if ProcessExists ("cmd.exe") then ProcessClose("cmd.exe") case $filesave $read = GUICtrlRead($guiedit) $save = FileSaveDialog("Save Test", "c:\", "Text (*.txt)", 16, "nettestoutput.txt") FileWrite($save, $read) CASE $IPCONFIGREL $configREL = Run(@ComSpec & " /c ipconfig /RELease", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) If @Error = -1 Then ExitLoop $lineconfig = StdoutRead($configREL) GUICtrlSetData($GUIEdit, $lineconfig & @CRLF, 1) CASE $IPCONFIGREN $configren = Run(@ComSpec & " /c ipconfig /RENew", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) If @Error = -1 Then ExitLoop $lineconfig = StdoutRead($configREN) GUICtrlSetData($GUIEdit, $lineconfig & @CRLF, 1) case $helpme guihelp() EndSwitch $msg = TrayGetMsg() Select Case $msg = 0 ContinueLoop Case $msg = $aboutitem Msgbox(64, "about:", "A sipmle net test program.") Case $msg = $exititem ExitLoop EndSelect WEnd Link to comment Share on other sites More sharing options...
martin Posted August 18, 2007 Share Posted August 18, 2007 Hey guys i am having a slight issue trying to get a ping /t to stop without opening the taskmgr and killing the process. blow is my coding, if someone could please help me out i would much appreciate it. Maybe rather than try to stop ping you could use the -n 1 parameter to make it only sends one echo at a time. Do that until some flag has been set to stop. If you use Shellexecute then it's easier to stop it but then you have the problem of getting the output from another cmd window into your edit. To make your help form disappear you need to modify your gethelp fn to delete the gui func guihelp() $Form1 = GUICreate("HELP!!!", 633, 447, 193, 115) $Label1 = GUICtrlCreateLabel("ABOUT/HELP", 150, 8, 400, 41) GUICtrlSetFont(-1, 24, 800, 2, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("1. IF YOU DONT KNOW WHAT THE BUTTONS MEAN DON'T USE THEM, OR ASK YOUR SYSTEM ADMINISTRATOR", 24, 88, 587, 25) $Label3 = GUICtrlCreateLabel("2. TO REPORT ERRORS PLEASE EMAIL ADMIN@BRETZAMZOW.COM", 24, 120, 361, 17) $Label4 = GUICtrlCreateLabel("3. THE COMMAND LINE OPTION DOES NOT HAVE FULL FUNCTIONALITY BUT WILL WORK WITH MOST COMMANDS", 24, 152, 599, 17) $Label5 = GUICtrlCreateLabel("4. THIS PROGRAM WAS WRITTEN BY BRET ZAMZOW. THANKS TO EVERYONE WHO HELPED", 24, 184, 488, 17) $Label6 = GUICtrlCreateLabel("A SPECIAL THANKS GOES OUT TO THE AUTOIT CREW AND SGT RO-RO FOR DESIGN HELP AND FUNCTIONALITY", 24, 216, 589, 17) $close = GUICtrlCreateButton("Exit", 195, 248, 75, 25, 0) $Pic1 = GUICtrlCreatePic("C:\Documents and Settings\Bret\My Documents\My Pictures\BRETZAMZOW.jpg", 40, 280, 529, 129, BitOR($SS_NOTIFY,$WS_GROUP)) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Switch $msg case $gui_event_close ExitLoop CASE $close ConsoleWrite("close press") ExitLoop EndSwitch WEnd GuiDelete($Form1);<------------------------- EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
mazwoz Posted August 19, 2007 Author Share Posted August 19, 2007 Maybe rather than try to stop ping you could use the -n 1 parameter to make it only sends one echo at a time.the only problem with this is the fact that it would have to be a continuous loop like a function calling its self until i told it to end the function. I know there has to be a way to be able to use the ping -t and then cancel it when directed but i just can seem to get it to work as the ping.exe and the guiedit constantly updating wont allow me to click the cancel ping button. Link to comment Share on other sites More sharing options...
mazwoz Posted August 19, 2007 Author Share Posted August 19, 2007 (edited) also can anyone tell me why this will work but it is locking up my computer (using 99% of my processor) after it finishes. have tried to compile it first and then run it, have also tried running the au3. still locks up my system every time i run a ping -n with the variable. CODE case $ping3 $var = InputBox("Number of Pings", "Input the number of pings here:","15") $pingn = run(@ComSpec & " /c ping " & $ip & " -n " & $var, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $linepingn = stdoutread($pingn) if @error= -1 then ExitLoop GUICtrlSetData($GUIEdit, $linepingn, 1) WEnd while 1 $line = StderrRead($linepingn) if @error = -1 then ExitLoop MsgBox(0, "ERROR:", $LINE) WEnd Edited August 19, 2007 by mazwoz 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