Sign in to follow this  
Followers 0
dillonlim

Traceroute type thing

3 posts in this topic

Wrote this while I was bored at work. Not quite sure what value it adds to the console traceroute if any.

#include <Constants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

GUICreate("Traceroute Thingy", 500, 500)
GUICtrlCreateLabel("IP Address:", 10, 13, 60, 20)
$ipaddress = GUICtrlCreateInput("", 80, 10, 200, 20)
$start = GUICtrlCreateButton("TRACE", 300, 10, 80, 20)
$clear = GUICtrlCreateButton("CLEAR", 400, 10, 80, 20)
$display = GUICtrlCreateEdit("", 10, 40, 480, 420, $ES_READONLY)
GUICtrlCreateLabel("Status:", 10, 473, 40, 20)
$status = GUICtrlCreateEdit("Idle", 50, 470, 440, 20, $ES_READONLY)
GUISetState(@SW_SHOW)

While 1
$msg = GUIGetMsg()
Select

    Case $msg = $GUI_EVENT_CLOSE
    ExitLoop

        Case $msg = $start

    Local $tracert = ""
    Local $st = 1
    Local $tracestatus = "run"
    GUICtrlSetData($status, "Tracing route")
    $getip = GUICtrlRead($ipaddress)
    $troute = Run("cmd.exe /c tracert.exe -h 30 -w 10 " & $getip, "", @SW_HIDE, $STDOUT_CHILD)

    Do
        If $tracestatus = "run" Then
            $tracert &= StdoutRead($troute)
            If @error Then 
                $tracestatus = "stop"
            EndIf
        EndIf
        $trace = StringStripCR($tracert)
        $tracesplit = StringSplit($trace, @CRLF)
        $arrayvar = UBound($tracesplit)

        If $st = $tracesplit[0] AND $tracestatus = "run" Then
            Sleep(500)
        ElseIf $arrayvar < 7 Then
            Sleep(500)
        ElseIf $st < $tracesplit[0] AND $arrayvar >= 7 Then
            $readchar = StringLeft($tracesplit[$st], 5)
            $cleanchar = StringStripWS($readchar, 8)
            If StringIsDigit($cleanchar) = 1 Then
                GUICtrlSetData($display, $tracesplit[$st] & @CRLF, 1)
                Sleep(1500)
            EndIf
        EndIf
        $st = $st + 1

    Until $st = $tracesplit[0] AND $tracestatus = "stop"
    GUICtrlSetData($status, "Done")

    Case $msg = $clear
    GUICtrlSetData($ipaddress, "")
    GUICtrlSetData($display, "")
    GUICtrlSetData($status, "Idle")

EndSelect
WEnd
GUIDelete()

Share this post


Link to post
Share on other sites



Sorry but I've never tried it on Win7. I only tested it on XP.

Been running for 10 minutes without any output, win 7 32

Also you might want to add an escape route from the Do...Until loop.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0