Jump to content

Multi-ping. With expandable window


Triblade
 Share

Recommended Posts

Hiya,

As a collegue needed such a tool, I've created this script which pings something(s), in a cool and efficient way.

NEW: (22-juli-2010)

BugFixed final version and tested it to comply with newest AutoIt version. (3.3.6.1)

New version = 3.5.2

FINAL! (?)

- Descriptions

- Save destinations and descriptions

- See InfoHeader below...

- Tray options for non-native (standard) ping

- More/better error displays

- Start/Stop all button

- Destination checking

- New color for wrong IP

- Tray text on settings to show current value

- Now supposed to work in different languages (the fast ping functing, the others allready worked)

- Now saves settings as well

I know this isn't spectacular, but what is, is the following:

- Is can be set on-top;

- It can be expanded to ping up to 10 destinations; (Newest version can be set beyond 10 - see InfoHeader below or just download the newest script)

- GUI controls in array for dynamic expansion;

- Colored input field when pinged;

- It has some error explanation. (Only for the Slow ping option. Newest version has Case Else for the fast ping function)

See attachements for script and screens.

Fixed New version Script (3.5.2): pong3.au3

Old version Script (3.0): pong3.au3

Older version Script (2): pong2.au3

Oldest version Script (1): pong.au3

Screenshot of main GUI (contracted):

post-20969-1208340395_thumb.png

Screenshot of main GUI (expanded):

post-20969-1208340360_thumb.png

Screenshot of traymenu1:

post-20969-12797911814272_thumb.png

Screenshot of traymenu2:

post-20969-12797911886251_thumb.png

Changelog:

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.6.1 (from 22-07-2010 (dd-mm-yyyy))
 AutoIt Version: 3.2.12.1 (from 05-05-2008 (dd-mm-yyyy)) (Also tested and found working in v3.2.13.6 (beta))
 AutoIt Version: 3.2.10.0 (from 02-04-2008 (dd-mm-yyyy))
 AutoIt Version: 3.2.9.13 (beta) (from 21-12-2007 (dd-mm-yyyy))

 Pong Version:   3.5.2
 Author:         E. Rottier (Triblade)
 Thanks:         GaryFrost, Sm0ke_N, wfuehrer, spillo3000, kylek29, Erwin, monoceres, bacobampense, 2words4uready

 Updated 22-07-2010 (dd-mm-yyyy)
 Created 14-12-2007 (dd-mm-yyyy)

Updated 22-07-2010:
    - Changed: AutoIt Version tot 3.3.6.1, tested as of today
    - Added: 'About' traymenu item
    - Added: $version variable with, oh yes, the version number
    - Fixed: Script broke on an no-array variable being used as an array, which it should've been, on the old line 416
    - Added: 'Ping timeout' notification (line 425) when the hidden cmd-run ping command does not return anything at all, this is classified as an timeout
    - Changed: 'Packet size' and 'Timeout number' trayicon messagebox text to say 'equal or lower' instead of only 'lower' to be more precise
    - Fixed: various description errors in this log

Updated 05-08-2008:
    - Fixed: Script broke on missing includes due to new AutoIt version. Added "#include <StaticConstants.au3>" & "#include <EditConstants.au3>"
        Thanks to: 2words4uready for bringing this to my attention

Updated 05-05-2008:
    - Changed: Program doesn't close on a pressed escape key anymore
    - Changed: Default program icon (internal testing only)
        Thanks to: icomania.com

Updated 19-04-2008:
    - Added: Traytext on fast-ping settings trayitems to show current value
    - Added: Reset to default trayitem in fast-ping setting menu
    - Added: Save settings when the save button is pressed
    - Changed: Default ini filename changed from 'pong.ini' to 'pong3.ini' because of internal changes and clarity
    - Changed: Inifile load sequence location below the creation of the traymenu because some changes need the menu allready created
    - Fixed: Destinations that could not be reached or gave other errors didn't show the destination even when the show destination option was on
    
Updated 18-04-2008:
    - Fixed/Changed: reply-time feedback capture system (line: ~393)
        Thanks to: monoceres for his testing in his native language

Updated 16-04-2008:
    - Added: OnePushClicksAll-button. This a-button (press 'A'll-button) presses all start or stop ping buttons currently on the GUI
        Thanks to: bacobampense for giving me the idea (In post http://www.autoitscript.com/forum/index.php?showtopic=59502&view=findpost&p=506202)
    - Added: More comment text
    - Changed: Added check in the check() function to see if the name to ping doesn't contain a space to speed up the faulty input detection
    - Changed: First octet check in the checkIP() function to accept only if 1 - 223 everthing else has a special meaning (224 = multicast etc)
    - Fixed: Regular expression from using the = to . (in ReEx . means every single char). This because when pinging 127.0.0.1 returns <1ms instead of =1ms
    - Changed: Added number to tooltip per destination and description inputfield
    - Changed: Start position of the GUI to right, top of the screen. Well allmost
    - Changed: Startup default in on-top mode because this program is intended to be ontop in the first place

Updated 15-04-2008:
    - Added: checkIP() function to check if the input IP or IP from DNSname if it is from 1.0.0.0 to 223.254.254.254 before pinging it
    - Added: Show error from DOS box. I just said 'Unknown error' when an error from a DOS box showed, but now I just steal the error msg from the box :)

Updated 14-04-2008:
    - Changed: Redesigned fastpong function to use Sm0ke_N's created Regular expression. This because in different languages the English words don't apply
        Thanks to: Sm0ke_N for his Regular expression code (In post: http://www.autoitscript.com/forum/index.php?showtopic=59502&view=findpost&p=448274)

 Updated 11-04-2008:
    - Added: Created "'non-native ping' Settings" menu in the tray
    - Changed: Renamed variable from $traymenu to $trayoptions to avoid confusion with the new traymenu
    - Added: 'Set timeout' in traymenu so you can set the timeout of the (non-native) ping from 50 to 3999. Default set to 1000
        Thanks to: Erwin for the hint
    - Changed: Moved above timeout trayitem and ICMP packet size trayitem to 'non-native ping' Settings traymenu
    - Fixed: Code for the ICMP packet size checking. It had two = signs and maximum size is reduced from 65535 to 65500 for this is the maximum ping allows
        Thanks to: monoceres for his report (In post: http://www.autoitscript.com/forum/index.php?showtopic=59502&view=findpost&p=504808)

 Updated 10-04-2008:
    - Changed: Wait time in ms in the fastpong() function from 15 to 1000 ms. (This is a DOS command from which the output is grabbed and processed) This because it gave to many errors
        Thanks to: Erwin for the ping loss 'bug'

 Updated 02-04-2008:
    - Changed: Version from 2 to 3. This because of the new functions, AutoIt version used and time passed :)
    - Changed: Variable name from 'actief' to 'active' to be English compliant
    - Changed: Wait time in ms in the fastpong() function from 10 to 15 ms. (This is a DOS command from which the output is grabbed and processed) This because it gave to many errors
    - Added Implemented save-to-ini function. Added 's'-button, associated subroutines and variables to save settings to ini-file. This because many people seemed to want this. (Allways keep your users happy ;) )
    - Added local $filler variable in the saveini function because the $active[$i] arrayitem does not allways contain the IP or name. This is because the ping address does not has to be activated
        Thanks to: wfuehrer for the tip (In post: http://www.autoitscript.com/forum/index.php?showtopic=59502&view=findpost&p=457868)
    - Added function to set the ICMP packet size. Added 'Set ICMP packet size' button in the traymenu. Default set to 32. Also added -l option in DOS command in False function for this new function
        Thanks to: spillo3000 for the hint (In post: http://www.autoitscript.com/forum/index.php?showtopic=59502&view=findpost&p=488261)
    - Added Description fields. These are accessable with the > and < button. Also added this feature to the save function, ofcourse
        Thanks to: kylek29 for the suggestion (In post: http://www.autoitscript.com/forum/index.php?showtopic=59502&view=findpost&p=482390)

 Updated 21-12-2007:
    - Added global $max variable to expand maximum number of ping entries when wanted. (don't recommand to do this cause of lag issues)
    - Changed: Some harcoded variables (10's and 9's) to use the $max var instead
    - Added Slow ping option in the Global options traymenu to be able to use the AutoIt native ping function instead of the command prompt, which is OS dependant
    - Added fastpong function. The original ping is still there and accessable through the traymenu in the Global options as Slow ping. Fastpong uses the command prompt of the OS for faster results
        Thanks to: GaryFrost for this idea and sample (In post: http://www.autoitscript.com/forum/index.php?showtopic=59502&view=findpost&p=448259 )
    - Added Case Else in the $error Switch. This because the fastping gives too long error messages to display. So it display's a simple 'Unknown ping loss' message. (Also I'm to lazy to check every posibility)

 Script Function:
    Ping up to $max (standard set to 10) hosts from one window.
    Interresting abilities:
        - Expandable window to create more ping-entries ($max = standard set to 10)
        - Use AutoIt native ping, or via a hidden DOS box the DOS command ping. (Standard. And you can set more variables)
        - On-top function via the Tray
        - Hide / Show GUI option in the Tray
        - GUI controls in array for dynamic expansion
        - Ping error-text
        - Colored input field when pinged
        - External ping option (standard set). Faster but uses the external cmd prompt to get fast results
        - Internal ping option. Slower but isn't using the external cmd prompt
        - Tooltips with controls (the least interresting if you'd ask me)
        
        Okay, some of this so-called interresting stuff may not be as interresting for some, but it was for me and hopefully for others.
        
    (The maximum of 10 entries is because of the ping-timeout, else the lag would be even larger than it allready can be. However this $max var can be set to a larger number.)

#ce ----------------------------------------------------------------------------

It uses the following includes:

- #include <GUIConstantsEx.au3>

- #include <Constants.au3>

- #include <Array.au3>

- #include <StaticConstants.au3>

- #include <EditConstants.au3>

Edit10: Uploaded bugfixed version. (3.5.2 (final - again))

Edit9: Uploaded fixed version to comply with newest AutoIt. (3.5.1 (final))

Edit8: Uploaded new fixed version with new functionality. (3.5 (final))

Edit7: Upped new fixed version. (3.4)

Edit6: Upped new version. (3.3)

Edit5: Upped new version. (3.1)

Edit4: Edited fastping timeout, so new version uploaded.

Edit3: New version added and completely edited 1st post to show that.

Edit2: Added new script and InfoHeader codebox.

Edit1: Layout.

Don't download below attachement, download the ones above in the post instead!

pong3.au3

Edited by Triblade

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

Without looking at your code you could speed up the ping timeout process for example:

#include <Constants.au3>

$sPingLocation = "autoitscript.com"

$aPing = _PingIt($sPingLocation)

If $aPing[2] Then
    MsgBox(0, "On Line (" & $sPingLocation & ")", "IP: " & $aPing[0] & @LF & "roundtrip-time in milliseconds: " & $aPing[1])
Else
    MsgBox(0, "Off Line (" & $sPingLocation & ")", "IP: " & $aPing[0])
EndIf

Func _PingIt($sLocation)
    Local $sData = "", $line = "", $aResult[3]
    Local $hping = Run(@ComSpec & " /c ping -n 1 -w 10 " & $sLocation, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

    While 1
        $line = StdoutRead($hping)
        If @error Then ExitLoop
        $sData &= $line
    WEnd
    $line = StringMid($sData, StringInStr($sData, "Reply from") + 11)
    $end = StringInStr($line, ":") - 1
    $aResult[0] = StringMid($line, 1, $end)

    If StringInStr($sData, "Received = 1") Then
        $aResult[2] = 1
        $line = StringMid($sData, StringInStr($sData, "time") + 5)
        $end = StringInStr($line, "TTL=") - 2
        $aResult[1] = StringMid($line, 1, $end)
    EndIf
    Return $aResult
EndFunc   ;==>_PingIt

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

  • Moderators

Without looking at your code you could speed up the ping timeout process for example:

#include <Constants.au3>

$sPingLocation = "autoitscript.com"

$aPing = _PingIt($sPingLocation)

If $aPing[2] Then
    MsgBox(0, "On Line (" & $sPingLocation & ")", "IP: " & $aPing[0] & @LF & "roundtrip-time in milliseconds: " & $aPing[1])
Else
    MsgBox(0, "Off Line (" & $sPingLocation & ")", "IP: " & $aPing[0])
EndIf

Func _PingIt($sLocation)
    Local $sData = "", $line = "", $aResult[3]
    Local $hping = Run(@ComSpec & " /c ping -n 1 -w 10 " & $sLocation, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

    While 1
        $line = StdoutRead($hping)
        If @error Then ExitLoop
        $sData &= $line
    WEnd
    $line = StringMid($sData, StringInStr($sData, "Reply from") + 11)
    $end = StringInStr($line, ":") - 1
    $aResult[0] = StringMid($line, 1, $end)

    If StringInStr($sData, "Received = 1") Then
        $aResult[2] = 1
        $line = StringMid($sData, StringInStr($sData, "time") + 5)
        $end = StringInStr($line, "TTL=") - 2
        $aResult[1] = StringMid($line, 1, $end)
    EndIf
    Return $aResult
EndFunc   ;==>_PingItoÝ÷ Ûú®¢×v'ßz·§·²¶É·¢Ø^²Úâ *n«b¢{h¡«­¢+Ø¥¹±Õ±Ðí
½¹ÍѹÑ̹ÔÌÐì((ÀÌØíÍA¥¹1½Ñ¥½¸ôÅÕ½ÐíÕѽ¥ÑÍÉ¥Áй½´ÅÕ½Ðì((ÀÌØíA¥¹ô}A¥¹%Ð ÀÌØíÍA¥¹1½Ñ¥½¸¤()%U ½Õ¹ ÀÌØíA¥¹¤ôÈQ¡¸(5Í ½à À°ÅÕ½Ðí=¸1¥¹ ÅÕ½ÐìµÀìÀÌØíÍA¥¹1½Ñ¥½¸µÀìÅÕ½Ðì¤ÅÕ½Ðì°ÅÕ½Ðí%@èÅÕ½ÐìµÀìÀÌØíA¥¹lÁtµÀì1µÀìÅÕ½ÐíɽչÑÉ¥ÀµÑ¥µ¥¸µ¥±±¥Í½¹ÌèÅÕ½ÐìµÀìÀÌØíA¥¹lÅt¤)±Í(5Í  ½à À°ÅÕ½Ðí=1¥¹ ÅÕ½ÐìµÀìÀÌØíÍA¥¹1½Ñ¥½¸µÀìÅÕ½Ðì¤ÅÕ½Ðì°ÅÕ½Ðí%@èÅÕ½ÐìµÀìÀÌØíA¥¹lÁt¤)¹%()Õ¹}A¥¹%Ð ÀÌØíÍ1½Ñ¥½¸¤(1½°ÀÌØíÍÑôÅÕ½ÐìÅÕ½Ðì°ÀÌØí±¥¹ôÅÕ½ÐìÅÕ½Ðì°ÀÌØíIÍÕ±Ð(1½°ÀÌØí¡Á¥¹ôIÕ¸¡
½µMÁµÀìÅÕ½Ðì½Á¥¹µ¸ÄµÜÄÀÅÕ½ÐìµÀìÀÌØíÍ1½Ñ¥½¸°MåÍѵ¥È°M]}!%°ÀÌØíMQII}
!%1¬ÀÌØíMQ=UQ}
!%1¤((]¡¥±Ä(ÀÌØí±¥¹ôMѽÕÑI ÀÌØí¡Á¥¹¤(%ÉɽÈQ¡¸á¥Ñ1½½À(ÀÌØíÍѵÀìôÀÌØí±¥¹(]¹($ÀÌØíIÍÕ±ÐôMÑÉ¥¹IáÀ ÀÌØíÍÑ°ÅÕ½Ðì ý̤¸¬ü ÀäÈí¬ÀäÈì¸ÀäÈí¬ÀäÈì¸ÀäÈí¬ÀäÈì¸ÀäÈí¬¤¸¬üô ÀäÈí¬¥µÌÅÕ½Ðì°Ä¤(%%%ÍÉÉä ÀÌØíIÍձФQ¡¸IÑÕɸÀÌØíIÍÕ±Ð(%IÑÕɸMÑÉ¥¹IáÀ ÀÌØíÍÑ°ÅÕ½Ðì ý̤ÀäÈíl ÀäÈí¬ÀäÈì¸ÀäÈí¬ÀäÈì¸ÀäÈí¬ÀäÈì¸ÀäÈí¬¤ÀäÈítÅÕ½Ðì°Ä¤)¹Õ¹ìôôÐí}A¥¹%Ð

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

I just started using AutoIt and it's great.

I like your script Triblade but how do I make it to write a .ini (IniWrite) file with the ip's and when I start it next time it read (IniRead) them so I don't have to write the ip once again.

I know it's possible to do but don't know exactly how so maybe you can help me.

Pain

Link to comment
Share on other sites

Thanks! *Whishes there was a blush-emoticon*

And I was thinking about speeding up ping the ping process by calling the external ping program.

I was thinking about a menu item for speedy pings and slow pings for people who don't want to much processes in there list.

Thanks for the idea and script on how to use the ping command! I will look into that when I've got spare time @ work :)

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

I just started using AutoIt and it's great.

I like your script Triblade but how do I make it to write a .ini (IniWrite) file with the ip's and when I start it next time it read (IniRead) them so I don't have to write the ip once again.

I know it's possible to do but don't know exactly how so maybe you can help me.

Pain

Try below script. :)

This attached AutoIt script contains the following adustments:

- Additional 's'-button to save current ping destinations to an ini file originally called: 'pong.ini' in the same directory as the .exe; (Deletes ini file whole section content before writing)

- If exists, read 'pong.ini' and sets ping window to saved settings.

pong.au3 file with save-to-ini function: <removed attachement - included in newest version, see first page>

Edited by Triblade

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

Added new script in first post.

Now thanks to GaryFrost added fast ping as default ping to speed up ping's.

@GaryFrost: Thanks for the sample. I've took it and included a (very?) edited version of it into my script. It's now in the top post.

@SmOke_N: Thanks for the regular expression sample. I will studie it, but won't use it because I don't fully understand it yet :)

Edit: Added thanks ^_^

P.S. No ratings? If you like the script, then vote or post me some comments or something :) Thanks!

Edited by Triblade

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

  • 2 weeks later...

Try below script. :)

This attached AutoIt script contains the following adustments:

- Additional 's'-button to save current ping destinations to an ini file originally called: 'pong.ini' in the same directory as the .exe; (Deletes ini file whole section content before writing)

- If exists, read 'pong.ini' and sets ping window to saved settings.

pong.au3 file with save-to-ini function:

Hi!

With your saveini() function you have to switch the gui to show destination names before saving because you read the gui contend. When you use the vars of the $actief array the ini file always gets the right names.

If IniWrite($iniloc, "ping destinations", $i, $actief[$i]) = 0 Then

CU

Wolfgang

Wolfgang Führer

Link to comment
Share on other sites

  • 1 month later...

I'm really liking this script. Some suggestions ...

- Port the save function to the newest version.

- Allow a "Description" field next to the colored ping box. This will help know what it is that is down if you don't have a device name (such as a timeclock/etc).

Link to comment
Share on other sites

  • 2 weeks later...

HOw can i change the size of the icmp packet ???

I'm really liking this script. Some suggestions ...

- Port the save function to the newest version.

- Allow a "Description" field next to the colored ping box. This will help know what it is that is down if you don't have a device name (such as a timeclock/etc).

Link to comment
Share on other sites

  • 4 weeks later...

Hi!

With your saveini() function you have to switch the gui to show destination names before saving because you read the gui contend. When you use the vars of the $actief array the ini file always gets the right names.

If IniWrite($iniloc, "ping destinations", $i, $actief[$i]) = 0 Then

CU

Wolfgang

I used your good tip and incorporated it into my code.

I'm really liking this script. Some suggestions ...

- Port the save function to the newest version.

- Allow a "Description" field next to the colored ping box. This will help know what it is that is down if you don't have a device name (such as a timeclock/etc).

I sent you a pm with what you meant with the 'port the save function'.

And I did use you suggestion of the description fields. (see new version)

HOw can i change the size of the icmp packet ???

Interresting 'hint'.

You coulden't in the old version. (at least if you didn't added it yourself)

I did, however, added this function in the newest version. See the traymenu for that.

Thanks you all for you wonderfull suggestions!

(Sorry for the late respons..)

Edited by Triblade

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

  • 2 weeks later...

Really nice!

Some things though, I cannot ping anything unless I use native ping, maybe I'm missing something?

Found a little bug too, if try to change the ICMP packet size the script crashes.

Keep up the good work :D

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

Really nice!

Some things though, I cannot ping anything unless I use native ping, maybe I'm missing something?

Found a little bug too, if try to change the ICMP packet size the script crashes.

Keep up the good work :D

Thanks for the constructive comment!

What OS are you using because maybe the DOS command which is used by the non-native ping may return different results depending on OS.

And what packet size and timeout are you using? Standard? A large packet size may not be supported by devices between you and your target. And if the timeout is set to low it will timeout before the results can come back. I tried a ping once in a DOS box and the time was 181ms. When I did the same ping but with a -w option of 1000(ms) it did work. I pinged citrix.com.

And thanks for the ICMP packet size bug report.

I've fixed it (I think) and put the new version up.

The problem was that I used two = signs. And it could never do both while being different.

Also changes the maximum ICMP packet size to 65500 instead of 65535. (DOS ping doesn't allow a higher number, this is because with overhead the ping packet may not be larger then 65535 bytes. Else it becomes a Ping of Death :D ) (src=PoD)

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

Hmm, when I see all your scripts I don't think I have to ask if you use the latest AutoIt version...

Could you place this piece:

msgbox(0, "Output", $selectedoutput)

Beneath this piece: (in the fastpong function)

While 1
    $line = StdoutRead($console); Read a line of the output of the command screen output
    If @error Then ExitLoop
    $selectedoutput &= $line; Put all the read lines together in one variable
WEnd

As you can allready read this gives a messagebox with the outcome of the DOS ping. Maybe there is something strange in there?

If you don't want to type it out or program something else in it, you could do me a favor if you could post a screenshot or something of that outcome.

Thanks!

My active project(s): A-maze-ing generator (generates a maze)

My archived project(s): Pong3 (Multi-pinger)

Link to comment
Share on other sites

Aha! I solved it! :D

Since I use a Swedish version of windows the DOS return value is not "Recieved = 1" but rather "Mottagna = 1" and "time" is "tid".

If you wish to fix multi-language support then you should use switch or select @OSLang at the beginning of your script and choose the right string :D

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

  • Moderators

Aha! I solved it! :D

Since I use a Swedish version of windows the DOS return value is not "Recieved = 1" but rather "Mottagna = 1" and "time" is "tid".

If you wish to fix multi-language support then you should use switch or select @OSLang at the beginning of your script and choose the right string :)

:D Or just use Regular Expressions so you don't have to worry about having an obscenely large conditional statement :D

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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...