Network toolbox script for AutoIt.

Here’s a handy AutoIt script that does a simple ping, resolves IP addresses to their host names and displays your IP address. When you run it, an icon will appear in your system tray. Just right-click the icon to access the menu. No way can you do something like this in VBScript.

#Include
#include
#NoTrayIcon

Opt(“TrayMenuMode”,1)

$pinger = TrayCreateItem(“Pinger”)
TrayCreateItem(“”)
$nresolver = TrayCreateItem(“Resolver”)
TrayCreateItem(“”)
$ipaddress = TrayCreateItem(“My IP Address”)
TrayCreateItem(“”)
$exititem = TrayCreateItem(“Exit”)

TraySetState()

While 1
$msg = TrayGetMsg()
Select
Case $msg = 0
ContinueLoop
Case $msg = $pinger
$target = InputBox(“Pinger”, “Enter ping target:”)
$var = Ping($target,250)
If $var Then; also possible: If @error = 0 Then …
Msgbox(0,”Status”, $target & ” is online.” & @CRLF & “Roundtrip time was: ” & $var)
Else
Msgbox(0,”Status”,”An error occured with number: ” & @error)
EndIf
Case $msg = $nresolver
Dim $sResult, $sIp, $star
TCPStartup()
$star = InputBox(“Host name resolver”, “Enter target:”)
$sIp = TCPNameToIP($star)
$sResult = _TCPIpToName ($sIp)
If @error Then
MsgBox(0, “_TCPIpToName()”, “@error = ” & @error & @LF & “@extended = ” & @extended)
Else
MsgBox(0, “Host name resolver”, $sResult)
EndIf
Case $msg = $IPAddress
$PublicIP = _GetIP()
MsgBox(0, “IP Address”, “Your IP Address is: ” & $PublicIP)

Case $msg = $exititem
ExitLoop
EndSelect
WEnd

Exit

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s