allSystemsGo Posted September 4, 2013 Share Posted September 4, 2013 (edited) I have a gif that I would like to play while waiting for the results of tracert. I can't get it to stop once the process closes. Any insight? Here is the code... expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <GuiEdit.au3> #include <ButtonConstants.au3> #include <WinAPIEx.au3> #include <GIFAnimation.au3> #include <Process.au3> Global $address, $hedit, $loop, $stop, $traceaddress $loadGif='C:\temp\loadinganimation.gif' GUICreate("Network Tester", @DesktopWidth / 2, @DesktopHeight / 2) GUICtrlCreateLabel("Ping: ", 20, 28) $address = GUICtrlCreateInput("", 50, 25, 100) $doPing = GUICtrlCreateButton("Ping", 150, 22) $hedit = GUICtrlCreateEdit('', @DesktopWidth / 4, 20, 450, 500, _ BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE, $WS_HSCROLL, $ES_NOHIDESEL)) $loop = GUICtrlCreateCheckbox("Infinite Ping", 180, 22) GUICtrlSetState(-1, $GUI_UNCHECKED) $stop = GUICtrlCreateButton("Stop", 270, 23, 50, 20) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateLabel("Tracert",15,63) $traceaddress=GUICtrlCreateInput("",50,60,100) $tracert=GuiCtrlCreateButton("Tracert",150,58) $netstatus = GUICtrlCreateButton("Network Status", 20, 100, 150, 20) $devices=GuiCtrlCreateButton("Device List",20,140,150,20) $ipconfig=GuiCtrlCreateButton("IP Config",20,180,150,20) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $doPing Call(aping()) Case $msg = $netstatus Call(netstatus()) Case $msg = $devices Call(fingDevice()) Case $msg= $ipconfig Call(ipconfig()) Case $msg=$tracert Global $iPlay=1 $doGif=_GuiCtrlCreateGif($loadGif,"",195,58) GUISetState(@SW_SHOW) Call(tracert()) EndSelect WEnd Func aping() If GUICtrlRead($loop) = 1 Then GUICtrlSetState($stop, $GUI_ENABLE) While 1 $msg = GUIGetMsg() Select Case $msg = $stop ExitLoop EndSelect $ip = GUICtrlRead($address) Local $ping = Ping($ip) If $ping Then ;~ MsgBox(0,"Status","Online, roundtrip time was "& $ping&"ms") GUICtrlSetData($hedit, "Online, roundtrip time was " & $ping & "ms" & @CRLF, @CRLF) Else If @error = 1 Then ;~ MsgBox(0,"Status","No Ping! Host if Offline!") GUICtrlSetData($hedit, "No Ping! Host is Offline!" & @CRLF, @CRLF) Else If @error = 2 Then ;~ MsgBox(0,"Status","No Ping! Host is unreachable!") GUICtrlSetData($hedit, "No Ping! Host is unreachable!" & @CRLF, @CRLF) Else If @error = 3 Then ;~ MsgBox(0,"Status","No Ping! Bad destination!") GUICtrlSetData($hedit, "No Ping! Bad destination!" & @CRLF, @CRLF) Else If @error = 4 Then ;~ MsgBox(0,"Status","No Ping! Check connection!") GUICtrlSetData($hedit, "No Ping! Check connection!" & @CRLF, @CRLF) EndIf EndIf EndIf EndIf EndIf Sleep(100) WEnd Else $ip = GUICtrlRead($address) Local $ping = Ping($ip) If $ping Then ;~ MsgBox(0,"Status","Online, roundtrip time was "& $ping&"ms") GUICtrlSetData($hedit, "Online, roundtrip time was " & $ping & "ms" & @CRLF, @CRLF) Else If @error = 1 Then ;~ MsgBox(0,"Status","No Ping! Host if Offline!") GUICtrlSetData($hedit, "No Ping! Host is Offline!" & @CRLF, @CRLF) Else If @error = 2 Then ;~ MsgBox(0,"Status","No Ping! Host is unreachable!") GUICtrlSetData($hedit, "No Ping! Host is unreachable!" & @CRLF, @CRLF) Else If @error = 3 Then ;~ MsgBox(0,"Status","No Ping! Bad destination!") GUICtrlSetData($hedit, "No Ping! Bad destination!" & @CRLF, @CRLF) Else If @error = 4 Then ;~ MsgBox(0,"Status","No Ping! Check connection!") GUICtrlSetData($hedit, "No Ping! Check connection!" & @CRLF, @CRLF) EndIf EndIf EndIf EndIf EndIf EndIf EndFunc ;==>aping Func netstatus() GUICtrlSetData($hedit, 'Internet connected: ' & (_WinAPI_IsNetworkAlive() <> 0) & @CRLF) EndFunc ;==>netstatus Func fingDevice() If @OSArch='X64' Then If FileExists('C:\Program Files (X86)\Overlook Fing 2.2\bin\fing.exe') Then Sleep(10) Else MsgBox(64,"Fing","Please download and install the latest version of Fing to use this feature!") EndIf EndIf If @OSArch='X86' Then If FileExists('C:\Program Files\Overlook Fing 2.2\bin\fing.exe') Then Sleep(10) Else MsgBox(64,"Fing","Please download and install the latest version of Fing to use this feature!") EndIf EndIf If @OSArch='X65' Then RunWait(@ComSpec & " /c " & 'fing -n'&@IPAddress1&'/24 -r 1 -o log,text,c:\temp\devices.txt',"C:\Program Files (X86)\Overlook Fing 2.2\bin",@SW_HIDE) $file=FileOpen('C:\temp\devices.txt') $text=FileRead($file) GUICtrlSetData($hedit,$text) Else RunWait(@ComSpec & " /c " & 'fing -n'&@IPAddress1&'/24 -r 1 -o log,text,c:\temp\devices.txt',"C:\Program Files\Overlook Fing 2.2\bin",@SW_HIDE) $file=FileOpen('C:\temp\devices.txt') $text=FileRead($file) FileClose($file) GUICtrlSetData($hedit,$text) FileDelete($file) Endif EndFunc Func ipconfig() RunWait(@ComSpec & " /c " & 'ipconfig /all > c:\temp\ip.txt',"",@SW_HIDE) $file=FileOpen('c:\temp\ip.txt') $text=FileRead($file) FileClose($file) sleep(50) GUICtrlSetData($hedit,$text) FileDelete($file) EndFunc Func tracert() $trace=GUICtrlRead($traceaddress) RunWait(@ComSpec & " /c " & 'tracert '&$trace&' >c:\temp\trace.txt',"",@SW_HIDE) ;~ RunWait(@ComSpec & " /c " & 'tracert '&$trace&' >c:\temp\trace.txt',"",@SW_HIDE) ;~ Run('tracert '&$trace&' >c:\temp\trace.txt',"",@SW_HIDE) ;~ Do ;~ Global $iPlay=1 ;~ $doGif=_GuiCtrlCreateGif($loadGif,"",195,58) ;~ GUISetState(@SW_SHOW) ;~ Until Not ProcessExists ('TRACERT.EXE') $file=FileOpen('c:\temp\trace.txt') $text=FileRead($file) FileClose($file) sleep(50) GUICtrlSetData($hedit,$text) FileDelete($file) EndFunc Thanks! Edit: attached the gif i am using. Edited September 4, 2013 by allSystemsGo Link to comment Share on other sites More sharing options...
aleph01 Posted September 4, 2013 Share Posted September 4, 2013 What process plays the .gif? Start the tracert and play the .gif with a ProcessExists loop to monitor your tracert. When that ProcessExists returns a 0, use ProcessClose to stop your .gif. Is this not possible? _aleph_ Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
allSystemsGo Posted September 4, 2013 Author Share Posted September 4, 2013 What process plays the .gif? Start the tracert and play the .gif with a ProcessExists loop to monitor your tracert. When that ProcessExists returns a 0, use ProcessClose to stop your .gif. Is this not possible? _aleph_ The GIF begins when the tracert button is pressed. I have tried to check that IF NOT ProcessExists('TRACERT.EXE') exists Then delete the gif. Does not seem to work. Link to comment Share on other sites More sharing options...
Solution michaelslamet Posted September 4, 2013 Solution Share Posted September 4, 2013 AllSystemsGo, You're missing this line: _GIF_DeleteGIF($doGif) Place it below this line: RunWait(@ComSpec & " /c " & 'tracert '&$trace&' >c:\temp\trace.txt',"",@SW_HIDE) Link to comment Share on other sites More sharing options...
aleph01 Posted September 5, 2013 Share Posted September 5, 2013 Will this delete from memory? Remember, the .gif is running from memory, not from disc storage. Forgive me if my analysis, my approach, my suggestions, my attitude in general are sophomoric, as I'm not nearly approaching a guru in scripting. I see you are defining your .gif path with the following variable: $loadGif='C:temploadinganimation.gif' Check your file association for .gifs. That should give you the process to close to stop the .gif. It looks to me like lines 45 - 47 are the key here, though I may be way off base. I hope a Mod comes in and corrects me, but I'm willing to brainstorm (or brainsprinkle, as the case may be - maybe it'll be a sunshower with a magnificent rainbow!) If you change the variable $iPlay = 1 to $iPlay = 0 after Not ProcessExists(TRACERT.EXE), will that stop the .gif? How about changing the GUISetState? I know that might only hide the .gif, but it would be a work-around until the real fix reveals itself. And I'm not particularly gifted in GUIs. Another work-around: if i recall, a .gif can have a transparent background. How about playing a different .gif after NOT ProcessExists(TRACERT.EXE), one that's tranparent and has no content other than the background. It could even be 1 pixel x 1 pixel. Just some ideas from somone who, rather than thinks out-of-the-box, never had a box with which to begin the thought process. To be honest, I'm just posting to get M23 to have a great belly-laugh before realizing I'm really that ignorant. At the risk of showing the whole forum I'm a fool, I post now. _aleph_ Meds. They're not just for breakfast anymore. Link to comment Share on other sites More sharing options...
allSystemsGo Posted September 5, 2013 Author Share Posted September 5, 2013 AllSystemsGo, You're missing this line: _GIF_DeleteGIF($doGif) Place it below this line: RunWait(@ComSpec & " /c " & 'tracert '&$trace&' >c:\temp\trace.txt',"",@SW_HIDE) I was using the wrong variable to stop the GIF. I'm a goober. 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