Jump to content
Sign in to follow this  
Chimp

versatile multi ping

Recommended Posts

@Chimp

So I'm having trouble closing the GUI using the exit button or the GUI Close. For "Main_GO"

Also how would I go about and make this with GUI sizeable for both funcs?

 

Thank you so much for being so understanding and patience with me. I'm not the best with programming so anything will help thank you very much.

 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=..\..\..\Downloads\monkeyicon.ico
#AutoIt3Wrapper_Outfile=IP Monkey.exe
#AutoIt3Wrapper_Run_Tidy=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <ScreenCapture.au3>
#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <Array.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <ListviewConstants.au3>
#include 'MultiPing.au3' ; <-- take this from the following link:
; http://www.autoitscript.com/forum/topic/156395-versatile-multi-ping
#Region ;ping gui
 Opt("GUIOnEventMode", 1)
; ------ pinger GUI -------------------
Global $StopPing = 0
Local $Win_X = 1200, $Win_Y = 880 ; dimension of window
Global $PingGui = GUICreate("IP Monkey", $Win_X, $Win_Y, -1, -1)
GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui)
Global $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40)
GUICtrlSetFont(-1, 8)
;~ $button1 = GUICtrlCreateLabel("Hit Exit To Quit", 10, $Win_Y - 25, $Win_X - 20, 20, -1, $ES_CENTER)
;~ GUICtrlSetFont(-1, 1, 800)
;~ GUICtrlSetTip(-1, "save")
;~ GUICtrlSetOnEvent(-1, 'QuickRun')
GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP)
GUISetState(@SW_HIDE) ; hidden at startup
; --------- end of pinger gui -------------
#EndRegion ;ping gui


; Generate colored square images
$hImage = _GUIImageList_Create(30, 30)
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red
_GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green

_GUICtrlListView_SetImageList($listview, $hImage, 0)





#Region ### START Koda GUI section ### Form=
$IPpong = GUICreate("IP Monkey", 572, 253, -1, -1)
GUISetBkColor(0xFFFFFF)
Global $data1 = GUICtrlCreateInput("1", 184, 104, 81, 37, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
Global $data2 = GUICtrlCreateInput("23", 280, 104, 73, 37, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER))
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
Global $gobutton = GUICtrlCreateButton("GO", 80, 192, 75, 25)
GUICtrlSetTip(-1, "Runs A Live Continuous Ping" & @CRLF & _
        "Until Told Other Wise")
GUICtrlSetBkColor(-1, 0x00FF00)
Global $quickbutton = GUICtrlCreateButton("Quick Run", 240, 192, 75, 25)
GUICtrlSetTip(-1, "Quickly Scans, Then Saves" & @CRLF & _
        "Results In Your 'PingChecks' " & @CRLF & _
        "Folder Under Your Store Number Folder")
GUICtrlSetBkColor(-1, 0xFFFF00)
$title = GUICtrlCreateLabel("IP Monkey", 16, 128, 116, 33)
GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
$infobutton = GUICtrlCreateButton("?", 536, 16, 27, 25)
GUICtrlSetTip(-1, "Unsure what to do?" & @CRLF & _
        "This will get give you " & @CRLF & _
        "the help for IP Monkey")
GUICtrlSetBkColor(-1, 0xFF8000)
;$superbutton = GUICtrlCreateButton("", 0, 0, 19, 17)
;GUICtrlSetBkColor(-1, 0xFFFFFF)
;GUICtrlSetState(-1, $GUI_HIDE)
$Label1 = GUICtrlCreateLabel("What Store?", 200, 40, 145, 33)
GUICtrlSetFont(-1, 18, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x000000)
Global $exitbutton = GUICtrlCreateButton("Exit", 400, 192, 75, 25)
GUICtrlSetTip(-1, "What Do You Think This Button Does?")
GUICtrlSetBkColor(-1, 0xFF0000)
$Icon = GUICtrlCreatePic("C:\Users\" & @UserName & "\Desktop\monkeyicon-0.jpg", 16, 16, 100, 100)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

#Region ;Declares
; Reads text file for the base list of IP's
Global $aBase_IPlist = _FileReadToArray_mod(".\IP_List.txt")

Global $replace2 = "Second"
Global $replace3 = "Thrid"

Global $userdata1 = GUICtrlRead($data1)
Global $userdata2 = GUICtrlRead($data2)

Global $savefolder = "C:\Users\"
Global $paths = "\Desktop\PingChecks"
Global $1stpaths = "\~~~Store"
Global $2ndpaths = "~~~"
Global $results = FileExists($savefolder & @UserName & $paths)
Global $foldercheck = FileExists($savefolder & @UserName & $paths & $1stpaths & $userdata1 & $userdata2 & $2ndpaths)
Global $savefile = "C:\Users\" & @UserName & "\Desktop\PingChecks\~~~Store" & $userdata1 & $userdata2 & "~~~\"




#EndRegion ;Declares







#Region ; Foldercreation/ScreenCap/HelpFile



Func DirCheck()
    Global $savefolder = "C:\Users\"
    Global $paths = "\Desktop\PingChecks"
    $results = FileExists($savefolder & @UserName & $paths)

    Global $helptext = "C:\Users\" & @UserName & "\Desktop\PingChecks\README.txt"



    If $results = 0 Then
        DirCreate($savefolder & @UserName & $paths)
        FileWrite($helptext, "             ..  IMMMI  ..             " & @CRLF & _
                "           .~MMMMMMMMMMMMM~.            ")
        Createdforstore()



    ElseIf $results = 1 Then
        Createdforstore()

    EndIf



EndFunc   ;==>DirCheck

Func Createdforstore()

    Local $pathslocal = "\Desktop\PingChecks\"

    If $foldercheck = 0 Then
        DirCreate($savefolder & @UserName & $pathslocal & $1stpaths & $userdata1 & $userdata2 & $2ndpaths)
        Screencap()

    ElseIf $foldercheck = 1 Then
        Screencap()


    EndIf

EndFunc   ;==>Createdforstore


Func Screencap()
    $userdata1 = GUICtrlRead($data1)
    $userdata2 = GUICtrlRead($data2)
    Local $savesfile = "C:\Users\" & @UserName & "\Desktop\PingChecks\~~~Store" & $userdata1 & $userdata2 & "~~~\"
    Global $point = ","
    Global $time = "."
    Global $id = "Store"
    Global $tid = "~"


;~  Global $pathslocal = "\Desktop\PingChecks\"


    _ScreenCapture_CaptureWnd($savesfile & @UserName & $tid & $id & $userdata1 & $userdata2 & $tid & @MON & $time & @MDAY & $time & @YEAR & $tid & @HOUR & $time & @MIN & $tid & ".jpg", $PingGui)


    MsgBox(0, "Completed", " Your Ping Scan Is In Your PingChecks Folder, " & @CRLF & _
            "On Your Desktop.")
    Exit

EndFunc   ;==>Screencap


;helpfile

Func Helpfile()



    $readmecheck = FileExists("README.txt")

    If $readmecheck = 1 Then
        ShellExecute("README.txt")



    ElseIf $readmecheck = 0 Then
        Run("Notepad.exe")
        WinWait("Untitled - Notepad")






        ControlSetText("Untitled - Notepad", '', 'Edit1', "             ..  IMMMI  ..             " & @CRLF & _
                "           .~MMMMMMMMMMMMM~.            ")



    EndIf



EndFunc   ;==>Helpfile





#EndRegion ; Foldercreation/ScreenCap/HelpFile




#Region ; Main_GO/Replace_and_GO


#cs
    ##############################  second script  #############################################

    ; this is to ping continuously a list of IP addresses, get and display ping result "live"
    ; it simulates the dos "ping -t" command but performed simultaneously on many IP
    ; presenting the results in a ListView highlighting not responding devices with a red box
#ce


Func replace_And_Go($s_2, $s_3)

    ; Create a new array wit a new list of IP according to passed second and third octet
    Local $aNew_IPlist = $aBase_IPlist
    For $i = 0 To UBound($aNew_IPlist) - 1
        $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3)
    Next

    GUISetState(@SW_HIDE, $IPpong)
    GUISetState(@SW_SHOW, $PingGui)

    ; pass the new list to the pinger
    Main_GO($aNew_IPlist)

    GUISetState(@SW_HIDE, $PingGui)
    GUISetState(@SW_SHOW, $IPpong)

EndFunc   ;==>replace_And_Go



Func Main_GO($IPlist)
    HotKeySet("{esc}", "_button1")
    ; $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's
    ;
    ; the above command, it loads in the $IPlist array the values contained in the file IP_List.txt
    ; values in the file should be separated by a semicolon, something like in the following example:
    ;
    ; hostname1;192.168.0.1
    ; hostname2;192.168.0.5
    ; hostnameX;10.59.7.200
    ; etc....
    ;
    ;  if values in the file are not separated by a semicolon, but another char is used, for example a comma,
    ;  then just pass it as second parameter of the function: $IPlist = _FileReadToArray_mod(".\IP_List.txt", ",")
    ;
    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_DeleteAllItems($listview)
    _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView
    _GUICtrlListView_EndUpdate($listview)

    While Not $StopPing ; 1 ; continuously ping addresses of the previously loaded file (IP_List.txt)
        Sleep(10)
        ;
        ;        $IPlist is the array loaded with all the IP to be pinged (a 2d array in this case)
        ;        |
        ;        |      1 means the IP are in the second column of the $IPlist array (first colun is nr. 0)
        ;        |      |
        ;        |      |  +-->  0 means return back an array loaded with results from all pinged addresses (responding and not responding)
        ;        |      |  |     if you use 1 then only responding addresses are loaded in the returned array [default]
        ;        |      |  |     if you use 2 then only NOT responding addresses are loaded in the returned array
        ;        |      |  |     In this case we do not need an  array to be returned, we only need to perform all pings and pass results
        ;        |      |  |     directly (on the fly) to the "_refresh" callback function that will refresh the listview
        ;        |      |  |
        ;        |      |  |  0 means NO lookup name resolution must be performed
        ;        |      |  |  |
        ;        |      |  |  |   +--> this is the callback function to be called for each pinged address each time the ping has finished
        ;        |      |  |  |   |    (see the MultiPing.au3 file for info on all passed params)
        ;        |      |  |  |   |    6 parameters are passed to this function, but only 2 are used by the called function in this case:
        ;        |      |  |  |   |    [4] roundtrip of the responding ping or -1 if IP is down
        ;        |      |  |  |   |    [5] Index (position) of this IP within the caller's passed array
        ;        |      |  |  |   |
        ;        v      v  v  v   v
        _nPing($IPlist, 1, 0, 0, "_refresh")
    WEnd
    HotKeySet("{esc}", _button1)
    $StopPing = 0
EndFunc   ;==>Main_GO


#EndRegion ; Main_GO/Replace_and_GO



#Region ; QuickScan/Replace_and_GO2

Func replace_And_Go2($s_2, $s_3)

    ; Create a new array wit a new list of IP according to passed second and third octet
    Local $aNew_IPlist = $aBase_IPlist
    For $i = 0 To UBound($aNew_IPlist) - 1
        $aNew_IPlist[$i][1] = StringReplace(StringReplace($aBase_IPlist[$i][1], $replace2, $s_2), $replace3, $s_3)
    Next

    GUISetState(@SW_HIDE, $IPpong)
    GUISetState(@SW_SHOW, $PingGui)

    ; pass the new list to the pinger
    QuickRun($aNew_IPlist)

    GUISetState(@SW_HIDE, $PingGui)
    GUISetState(@SW_SHOW, $IPpong)

EndFunc   ;==>replace_And_Go2

Func QuickRun($IPlist)
    $userdata1 = GUICtrlRead($data1)
    $userdata2 = GUICtrlRead($data2)

    HotKeySet("{esc}", "_button1")

    Local $Win_X = 1200, $Win_Y = 880 ; dimension of window
    $PingGui = GUICreate("IP Monkey" & "~~~" & @UserName & "~~~" & "Store" & $userdata1 & $userdata2 & "~~~" & @MON & "." & @MDAY & "." & @YEAR & "~~~" & @HOUR & "." & @MIN, $Win_X, $Win_Y, -1, -1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "_button1", $PingGui)
    $listview = GUICtrlCreateListView("", 10, 10, $Win_X - 20, $Win_Y - 40)
    GUICtrlSetFont(-1, 8)
    GUICtrlSetStyle($listview, $LVS_ICON) ; + $LVS_NOLABELWRAP)

    ; Generate colored square images
    $hImage = _GUIImageList_Create(30, 30)
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFFFF00, 30, 30)) ; yellow
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0xFF0000, 30, 30)) ; red
    _GUIImageList_Add($hImage, _GUICtrlListView_CreateSolidBitMap($listview, 0x00FF00, 30, 30)) ; green

    _GUICtrlListView_SetImageList($listview, $hImage, 0)

    $button1 = GUICtrlCreateButton("Exit", 10, $Win_Y - 25, $Win_X - 20, 20)
    GUICtrlSetTip(-1, "End of program")
    GUICtrlSetOnEvent(-1, "_button1")
    GUISetState(@SW_SHOW)

;~  $IPlist = _FileReadToArray_mod(".\IP_List.txt") ; Reads text file for list of IP's

    _GUICtrlListView_BeginUpdate($listview)
    _GUICtrlListView_AddArray($listview, $IPlist) ; fill ListView
    _GUICtrlListView_EndUpdate($listview)

    ;While 1
    ; perform Pings and update ListView by the "_refresh" callback function
    $aFinalResult = _nPing($IPlist, 1, 0, 0, "_refresh")
;~  _ArrayDisplay($aFinalResult)

    DirCheck()

EndFunc   ;==>QuickRun

#EndRegion ; QuickScan/Replace_and_GO2

#Region ; Misc Funcs (network)

Func _refresh($Params) ; this receive ping results and displays them in the ListView
    _GUICtrlListView_SetItemImage($listview, $Params[5], 0) ; set colour to Yellow
    Sleep(50) ; a little wait
    If $Params[4] = -1 Then ; Device not responding to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 1) ; set colour to RED
        _GUICtrlListView_EnsureVisible($listview, $Params[5]) ; Position view to this item
    Else ; Device responds to ping
        _GUICtrlListView_SetItemImage($listview, $Params[5], 2) ; set colour to GREEN
    EndIf
EndFunc   ;==>_refresh




Func _button1() ; Button 1 clicked
    $StopPing = 1
    Exit
EndFunc   ;==>_button1

#EndRegion ; Misc Funcs (network)



While (1)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $gobutton
            $userdata1 = GUICtrlRead($data1)
            $userdata2 = GUICtrlRead($data2)
            ; pass the wanted new octet
            replace_And_Go($userdata1, $userdata2) ; generate a list of new IP and Go

        Case $infobutton
            Helpfile()

            ;Case $superbutton
            ;Run("notepad.exe")


        Case $quickbutton
            $userdata1 = GUICtrlRead($data1)
            $userdata2 = GUICtrlRead($data2)
            replace_And_Go2($userdata1, $userdata2)


        Case $exitbutton
            Exit

    EndSwitch
WEnd

 

Share this post


Link to post
Share on other sites

... continues from here: https://www.autoitscript.com/forum/topic/167469-multiping/?do=findComment&comment=1389326

1 hour ago, pintas said:

Oh thank you.

I liked this script because it is very fast but couldn't save the results to file, the way i wanted.

I tried to use your script to ping an array of hosts from a file (without IPs) and couldn't find a way to do it.

Maybe i missed something. Is there a way to do it?

 

@pintas, if your array contains a list of hostnames then something like this below should work
note: when you pass an 1D array, set the second parameter with an empty, and set 0 as third parameter (0 means that the returned array have to contain the list of the devices that responds to the ping and also those not responding.
The returned array contains all the pinged devices, where in column 3 there is the roundtrip value of each, or there is -1 if that device is not responding to the ping)

#include <Array.au3>
#include "MultiPing.au3"

 ; fill the array with yours hostnames (or IP)
Local $aHosts[5] = ['host1', 'host2', 'host3', 'host4', 'host5']

 _ArrayDisplay($aHosts) ; show the input array

 Local $Result = _nPing($aHosts, "", 0) ; ping all the devices

 _ArrayDisplay($Result) ;  show the result of all the pings


 


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites
On 24/04/2018 at 4:24 PM, Chimp said:

... continues from here: https://www.autoitscript.com/forum/topic/167469-multiping/?do=findComment&comment=1389326

@pintas, if your array contains a list of hostnames then something like this below should work
note: when you pass an 1D array, set the second parameter with an empty, and set 0 as third parameter (0 means that the returned array have to contain the list of the devices that responds to the ping and also those not responding.
The returned array contains all the pinged devices, where in column 3 there is the roundtrip value of each, or there is -1 if that device is not responding to the ping)

#include <Array.au3>
#include "MultiPing.au3"

 ; fill the array with yours hostnames (or IP)
Local $aHosts[5] = ['host1', 'host2', 'host3', 'host4', 'host5']

 _ArrayDisplay($aHosts) ; show the input array

 Local $Result = _nPing($aHosts, "", 0) ; ping all the devices

 _ArrayDisplay($Result) ;  show the result of all the pings


 

Sorry i took so long to thank you. :)

It really solved my problem. Fantastic script @Chimp!

Thanks again!

Share this post


Link to post
Share on other sites

You are welcome

I'm glad this script can be useful to someone.
Thans for the appreciation :)


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By argumentum
      The file is now at 
      I added a WOL, tidy up, and moved the file to the uploads section of the forum.
      Suggestions are always mostly welcomed  
    • By argumentum
      In the ZIP is the code and the compiled script.
      This is yet another ping the LAN utility.
      Is quite fast, as gathering the info. is forked.
      The Save Note, saves a note for the given MAC ( you may find it handy )
      The Save MACs, saves the listview to an INI file that can be later use for the WakeOnLAN
      Right click will bring a context menu to do stuff. DClick will refresh the Ping.
      That's it. Comes in handy to have in the USB toolbox  
    • By AoRaToS
      s!mpL3 LAN Messenger as the name suggests is a messenger designed and developed to offer chat communication over Local Area Networks while being as simple to use as possible. This project started way back in 2008 with only basic functionality and is regularly updated with new features in order to make it more useful and user friendly. What I wanted was a simple, small, serverless program that would work without installation cause that was the ideal combination for my workplace back then, so I ended up with this!

      I have attached some images from various versions:
      Check the rest below! (from various versions)

      More than 10.000 downloads!

      s!mpL3 LAN Messenger version 2.9.9.1 - [04/07/2019] - s!mpL3 LAN Messenger.zip
      1. Fixed an issue that would occur when blocking another user and they would re-appear in the TreeView.
      2. Updated File Transfers to make long file names shorter if they were too long to appear in the tray tip.
      3. Removed notifications when checking for updates at application startup if there is no update available.
      You can view/download the full change log here: ChangeLog.txt

      Tested and working on both 32bit and 64 bit editions of Windows XP, Windows Vista, Windows 7, Windows 8, Windows 8.1 and Windows 10.


      Things you need to know before trying it:

      1. Start the program, select one or more connections from what's available and click Connect (If a firewall notice comes up, click 'Allow' or 'Add Exception')
      When someone else on your network does the same, they will appear in your Tree-view and you will appear in theirs, double click their name and chat!

      2. s!mpL3 LAN Messenger does not require a server to be running, it's standalone.

      3. On the first run an .ini file is created at @LocalAppDataDir\s!mpL3 LAN Messenger which stores the settings so that they are used every time you run the application. If you delete the .ini file it will be created again (with default settings at program startup or with your selected settings if you press Save from the Preferences window).

      4. All communication is encrypted using AES so it's quite secure against Network sniffers.

      5. You can send files and folders by dragging and dropping them in a conversation window. Folders are compressed before being sent. You can also drop multiple items to be sent.

      6. There is a "Hide" button located in the tray right click context menu that will hide all open windows. You can assign a Hotkey combination from Preferences. The default combination is Ctrl+H.

      7. s!mpL3 LAN Messenger uses port 60000 by default. You can change the port used by adding "Port=****" (without quotes, stars represent numbers) to the Config file described above. Communication is UDP.

      8. There is an Updater feature you can use to always have the latest available version, you only need an internet connection for that to work. You might need to clear your Internet Explorer Temporary Files in order for it to find an updated version.

      9. You can Hide + Lock s!mpL3 LAN Messenger so it'll require a password in order to "Appear". To enable this, go to the Security Preferences.

      10. Note that versions after 2.9.8.1 are not compatible with previous versions due to the encryption used being changed. I recommend using the latest version, or at least use the same version over the LAN.


      Important Notice:

      I will not be releasing the source code, however, I might share some parts of code if requested...
      If you choose to de-compile this software, don't release the source code.




    • By RestrictedUser
      Hello Guys and AutoIt Scriptwriters!🎉❤️
      I've created a script to notify to me if RDP main IP changed then send a message via Telegram bot to me
      But some of my RDP's Main IP are @IPAddress1 or @IPAddress3 or Public IP Address...
      I want to detect automatically the IP that windows client can run RDP to remotely control
      This image can help you that what i say, there are three RDP with specified IP, i want to run script in these RDP's then capture those IP's changes then notify me via Telegram bot

×
×
  • Create New...