Code: Select all
;MyPingStart:
#SingleInstance force ; replaces the old instance automaticallymyUser = %A_UserName%
#p::
x = 1
;numOfPings = 1
myCLIP := clipboard
myCLIP = %myCLIP% ; relies on "autotrim" to remove leading/trailing white-space
myCLIP := RegExReplace(myCLIP, "[ ?,#_*|""]") ;remove special chars
;StringReplace , myCLIP, myCLIP, %A_Space%,,All
StringReplace, myCLIP, myCLIP, `n, , All ;;remove invisible CR
StringReplace, myCLIP, myCLIP, `r, , All
IPvalidation := CheckIP(myCLIP)
;msgbox IP: %IPvalidation%
if (IPvalidation) {
;msgbox valid %IPvalidation% IP: %IP%
} else {
msgbox Please enter valid IP
return
}
;CIDLEN := StrLen(clipboard)
CLIPLEN := StrLen(myCLIP)
if (CLIPLEN > 8 && CLIPLEN < 49)
{
run, %comspec% /k color 8 & ping -t %myCLIP%, ,
WinWait, ping -t %myCLIP%
;WinMove, 0, 0, , , 600, 400
x := numOfPings*525
;msgbox numofpings: %numOfPings% x: %x%
WinMove, , ,x, 890, 520, 195 ;height=850 title/text/x/y/width/height
;Winmove,Editor,,,,150,150
numOfPings++
;msgbox after increment pings: %numOfPings% x: %x%
} else {
msgbox requires IP address in clipboard
}
return
;MyKillPingStart:
#w::
processes=cmd.exe,ping.exe
Loop, parse, processes, `, ;an escaped comma divide the string based on every occurrence of a comma
{
Loop
{
Process, Close, %A_LoopField%
Process, Exist, %A_LoopField%
} Until !ErrorLevel
}
numOfPings = 0
return
CheckIP(IP)
{
pos = 1
While pos := RegExMatch(IP, "\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}", match, pos+StrLen(match))
return 1
pos = 1
While pos := RegExMatch(IP, "([a-fA-F0-9]{0,4}:){7,7}[a-fA-F0-9]{0,4}", match, pos+StrLen(match)) ;([a-fA-F0-9]{0,4}:){7,7}[a-fA-F0-9]{0,4}
return 2
If (IP = "")
{
return 0
}
return 0 ;failed
}
/*
msgbox w: numofPings: %numOfPings%
while numOfPings > 0
{
Process, Exist, ping.exe
If (ErrorLevel <> 0) {
Process, Close, cmd.exe
Process, Close, ping.exe
;msgbox w: numofPings: %numOfPings%
} Else {
;msgbox ping winder not found
}
numOfPings--
}
Return
*/