ttleser Posted December 16, 2006 Posted December 16, 2006 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. Here's the code: expandcollapse popup#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
Paulie Posted December 16, 2006 Posted December 16, 2006 I found someone else with a similar question, maybe they could help youhttp://www.autoitscript.com/forum/index.php?showtopic=37967Try NOT to double post
ttleser Posted December 16, 2006 Author Posted December 16, 2006 Duplicate post somehow. Sorry bout that.
Recommended Posts