Jump to content

Recommended Posts

Posted

I'm fairly unfamiliar with Arrays and how they work, so if someone could help me out that would be great.

Basically what I'm trying accomplish is to create an array of all of our sites so I can ping them and display the results verifying that the site is up and connected.

Here is what I have thus far:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
#include <GUIConstants.au3>
#include <Array.au3>

Dim $line
Dim $item
Dim $stArray[11]

$stArray[0] = "192.168.8.1" ; Smithville
$stArray[1] = "192.168.12.1" ; Pottsdale
$stArray[2] = "192.168.16.1" ; Irwin
$stArray[3] = "192.168.20.1" ; Dayton
$stArray[4] = "192.168.24.1" ; Center1
$stArray[5] = "192.168.32.1" ; Middleburg
$stArray[6] = "192.168.36.1" ; Rockville
$stArray[7] = "192.168.40.1" ; Springvalley
$stArray[8] = "192.168.48.1" ; Minster
$stArray[9] = "192.168.52.1" ; West Alex
$stArray[10] = "192.168.1.253" ; Tuna

$GUI = GUICreate("Site Connections", 400 , 325)
$view = GUICtrlCreateListView ("Site                |Status|Latency", 10, 30, 370, 279)

GUISetState (@SW_SHOW) 

$c = 0
func getPings()
$time = ping("10.56.8.1",10)
    if $time Then
        $item = GuiCtrlCreateListViewItem("Smithville | UP! | "& $time &"ms",$view)
        GUICtrlSetImage(-1, "shell32.dll",19)
        Sleep(500)
    Else
        $item = GUICtrlCreateListViewItem("Smithville | DOWN | n/a",$view)
        GUICtrlSetImage(-1, "shell32.dll",240)
        Sleep(500)
    EndIf
EndFunc
        call("getPings")
$begin = TimerInit()
while 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        
        case Else
            $diff = TimerDiff($begin)
            if $diff > 10000 Then
                $begin = TimerInit()
                GUICtrlDelete($item)
                call("getPings")
            EndIf
    EndSwitch
WEnd

I have to thank zackrspv for helping me with this code; unfortunately, it isn't my own.

Thanks for your help,

-mjg

Posted

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
#include <GUIConstants.au3>
#include <Array.au3>

Dim $line
Dim $item
Dim $stArray[11][2]

$stArray[0][0] = "192.168.8.1" ; Smithville
$stArray[0][1] = "Smithville"

$stArray[1][0] = "192.168.12.1" ; Pottsdale
$stArray[1][1] = "Pottsdale"

$stArray[2][0] = "192.168.16.1" ; Irwin
$stArray[2][1] = "Irwin"

$stArray[3][0] = "192.168.20.1" ; Dayton
$stArray[3][1] = "Dayton"

$stArray[4][0] = "192.168.24.1" ; Center1
$stArray[4][1] = "Center1"

$stArray[5][0] = "192.168.32.1" ; Middleburg
$stArray[5][1] = "Middleburg"

$stArray[6][0] = "192.168.36.1" ; Rockville
$stArray[6][1] = "Rockville"

$stArray[7][0] = "192.168.40.1" ; Springvalley
$stArray[7][1] = "Springvalley"

$stArray[8][0] = "192.168.48.1" ; Minster
$stArray[8][1] = "Minster"

$stArray[9][0] = "192.168.52.1" ; West Alex
$stArray[9][1] = "West Alex"

$stArray[10][0] = "192.168.1.253" ; Tuna
$stArray[10][1] = "Tuna"

$GUI = GUICreate("Site Connections", 400 , 325)
$view = GUICtrlCreateListView ("Site                |Status|Latency", 10, 30, 370, 279)

GUISetState (@SW_SHOW)

$c = 0
func getPings()
    For $X = 0 to Ubound($stArray) -1
        $time = ping($stArray[$X][0],10)
        if $time Then
            $item = GuiCtrlCreateListViewItem($stArray[$X][1] & " | UP! | "& $time &"ms",$view)
            GUICtrlSetImage(-1, "shell32.dll",19)
            Sleep(500)
        Else
            $item = GUICtrlCreateListViewItem($stArray[$X][1] & " | DOWN | n/a",$view)
            GUICtrlSetImage(-1, "shell32.dll",240)
            Sleep(500)
        EndIf
    Next
EndFunc
        getPings()
$begin = TimerInit()
while 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
       
        case Else
            $diff = TimerDiff($begin)
            if $diff > 10000 Then
                $begin = TimerInit()
                GUICtrlDelete($item)
                getPings()
            EndIf
    EndSwitch
WEnd

Posted

I'm fairly unfamiliar with Arrays and how they work, so if someone could help me out that would be great.

Basically what I'm trying accomplish is to create an array of all of our sites so I can ping them and display the results verifying that the site is up and connected.

Here is what I have thus far:

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
#include <GUIConstants.au3>
#include <Array.au3>

Dim $line
Dim $item
Dim $stArray[11]

$stArray[0] = "192.168.8.1" ; Smithville
$stArray[1] = "192.168.12.1" ; Pottsdale

$stArray[2] = "192.168.16.1" ; Irwin
$stArray[3] = "192.168.20.1" ; Dayton
$stArray[4] = "192.168.24.1" ; Center1
$stArray[5] = "192.168.32.1" ; Middleburg
$stArray[6] = "192.168.36.1" ; Rockville
$stArray[7] = "192.168.40.1" ; Springvalley
$stArray[8] = "192.168.48.1" ; Minster
$stArray[9] = "192.168.52.1" ; West Alex
$stArray[10] = "192.168.1.253" ; Tuna

$GUI = GUICreate("Site Connections", 400 , 325)
$view = GUICtrlCreateListView ("Site                |Status|Latency", 10, 30, 370, 279)

GUISetState (@SW_SHOW) 

$c = 0
func getPings()
$time = ping("10.56.8.1",10)
    if $time Then
        $item = GuiCtrlCreateListViewItem("Smithville | UP! | "& $time &"ms",$view)
        GUICtrlSetImage(-1, "shell32.dll",19)
        Sleep(500)
    Else
        $item = GUICtrlCreateListViewItem("Smithville | DOWN | n/a",$view)
        GUICtrlSetImage(-1, "shell32.dll",240)
        Sleep(500)
    EndIf
EndFunc
        call("getPings")
$begin = TimerInit()
while 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        
        case Else
            $diff = TimerDiff($begin)
            if $diff > 10000 Then
                $begin = TimerInit()
                GUICtrlDelete($item)
                call("getPings")
            EndIf
    EndSwitch
WEnd

I have to thank zackrspv for helping me with this code; unfortunately, it isn't my own.

Thanks for your help,

-mjg

See: Replied to IM

NOTE: I'm not detracting from the above solution, as it works just fine. I just like to use text files for ping tests, as it's faster to configure :D

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë ë§§ëñ§ë øƒ !ïƒë.

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
  • Recently Browsing   0 members

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