When it disconnects, I currently have a Gui popup flashing until the connection is restored. My issue is I don't know how to make this script give the connection restored popup only once, and it keeps flashing like the disconnected message does.
Please help!!
Code: Select all
global Connected := TRUE
SetTimer CheckInternet, 1000
Return
CheckInternet()
{
If (!IsConnected())
{
Soundbeep, 800, 100 ; Cuckoo Alert
Soundbeep, 600, 100
Gui, +AlwaysOnTop -Caption +hwndHGUI +LastFound
Gui, Color, 123456
Gui, Font, s14 w800 cRED q5, Calibri
Gui, Margin, 15, 15
Gui, Add, Text, w333 h50 Center +0x0200 0x00800000, ATTENTION: Internet Has Disconnected!!
Gui, Font, s12 w400 cYELLOW q5, Calibri
Gui, Add, Text, x67 y+5, Continuing Connection Monitoring...
Gui, Font, s12 w400 cABCDEF q5, Calibri
Gui, Add, Text, x33 y+5, Will Notify Once Connection Is Reestablished.
Gui, Show, Hide
WinGetPos, X, Y, W, H
R := Min(W, H) // 5
WinSet, Region, 0-0 W%W% H%H% R%R%-%R%
Gui, Show
OnMessage(0x0201, "WM_LBUTTONDOWN")
Sleep, 500
Gui, Destroy
Return
Connected := FALSE
}
Else
{
Soundbeep, 1800, 250
Gui, +AlwaysOnTop -Caption +hwndHGUI +LastFound
Gui, Color, ABCDEF
Gui, Font, s14 w800 cGREEN q5, Calibri
Gui, Margin, 15, 15
Gui, Add, Text, w333 h50 Center +0x0200 0x00800000, ATTENTION: Internet Has Reconnected!!
Gui, Font, s12 w400 c123456 q5, Calibri
Gui, Add, Text, x67 y+5, Continuing Connection Monitoring...
Gui, Show, Hide
WinGetPos, X, Y, W, H
R := Min(W, H) // 5
WinSet, Region, 0-0 W%W% H%H% R%R%-%R%
Gui, Show
OnMessage(0x0201, "WM_LBUTTONDOWN")
Sleep, 2000
Gui, Destroy
Return
If (!Connected)
{
Connected := TRUE
}
}
}
IsConnected()
{
INetworkListManager := ComObjCreate("{DCB00C01-570F-4A9B-8D69-199FDBA5723B}", "{DCB00000-570F-4A9B-8D69-199FDBA5723B}")
DllCall(NumGet(NumGet(INetworkListManager+0)+11*A_PtrSize), "UPtr", INetworkListManager, "UShortP", t, "UInt")
ObjRelease(INetworkListManager)
Return t
}
WM_LBUTTONDOWN() {
PostMessage, 0x00A1, 2, 0
}
Return