Sign in to follow this  
Followers 0
ttleser

Need help with continual loop

3 posts in this topic

I need to write a program that'll monitor a VPN connection (continually loop). I'm having a problem with the logic, cause I can't seem to get it to loop properly. It should continually ping the VPN computer until it can't, then ping the Internet. Either way it needs to report the results to the same window. If the connection, either goes down it'll report it as down, then if the connection comes up again, it'll remote it. In all cases, it still needs to loop so it can monitor the connection. I will add code later that'll email me once the connection is lost then reconnected. I've been playing with it a while, so don't be surprised if you see something that doesn't make sense. :P

Here's the code:

#include <GuiConstants.au3>
#include <GuiListView.au3>

GUICreate("Connection Monitor", 400, 400)
GUISetIcon("SHELL32.dll", 18)
$font="Arial Black"
$font1="Arial"

; Show the GUI
$status = "VPN Connected"
GUISetState()
GUISetFont (18, 400, 0, $font)
GuiCtrlCreateLabel("Status", 25, 50,)


GUISetFont (9, 400, 0, $font1)
$button_exit = GUICtrlCreateButton('E&xit', 90, 330, 75, 23)

While 1

    $msg = GUIGetMsg()

Select
        Case $msg = $button_exit
            Exit
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    Case $msg = ""
    Do

        $var = Ping("192.168.1.1", 250)
                If $var = 0 Then
        GUISetFont (18, 400, 0, $font)
        GuiCtrlCreateLabel("VPN Down", 140, 50,)
        GuiCtrlSetBkColor(-1, 0xFF0000)
                EndIF
        $var1 = Ping("www.yahoo.com", 250)
               If $var1 = 0 Then
        GUISetFont (18, 400, 0, $font)
        GuiCtrlCreateLabel("Internet Down", 140, 50,)   
        GuiCtrlSetBkColor(-1, 0xFF0000)
                EndIf

    Until $msg = $button_exit

EndSelect

WEnd

Share this post


Link to post
Share on other sites



Duplicate post somehow. Sorry bout that.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0