Jump to content

Traceroute type thing


dillonlim
 Share

Recommended Posts

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()
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...