Jump to content
Sign in to follow this  

Need help with continual loop

Recommended Posts

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"

; Show the GUI
$status = "VPN Connected"
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()

        Case $msg = $button_exit
        Case $msg = $GUI_EVENT_CLOSE
    Case $msg = ""

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

    Until $msg = $button_exit



Share this post

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

  • Create New...