Jump to content
Sign in to follow this  

Another Internet Monitor (ping based w/ tray status)

Recommended Posts

I was searching the internet and the forums for an autoit based keep alive script for my internet as well as a way to have a small notification about it in the system tray. 
I couldn't find any so I went ahead and threw this together.  if anyone has any suggestions or comments i would love to hear them!
It works for me and i will include a link to a pre-compiled version if you want it:  thttp://tricamtech.com/script/NetStatus.exe
the ICO files are in that directory too. 
#AutoIt3Wrapper_Res_Comment=Pings Google Public DNS
#AutoIt3Wrapper_Res_Description=Internet Ping Monitor
#AutoIt3Wrapper_Res_LegalCopyright=TRiCAM Tech Solutions

Opt("TrayMenuMode", 3) ; The default tray menu items will not be shown and items are not checked when selected. These are options 1 and 2 for TrayMenuMode.
TraySetIcon(@ScriptFullPath, -6) ; Set the tray menu icon using the shell32.dll and the random index number.
sleep(3000) ;allow network to start up before running if on startup

Func status()
   Local $iExit = TrayCreateItem("Exit")
   TraySetState(1) ; Show the tray menu.
   Local $hTimer = TimerInit() ; Begin the timer and store the handle in a variable.
   Local $iDiff = 0, $iIndex = 0

   Local $iPing1 = Ping("", 1500)
;Run first time!
             If $iPing1 Then ;
                 icon('1', $iPing1)
                 icon('0', $iPing1)

  While 1
     $iDiff = TimerDiff($hTimer) ; Find the difference in time from the previous call of TimerInit
      Local $iPing = Ping("", 1500)

        If $iDiff > 5000 Then ; If the difference is greater than 5 seconds then change the tray menu icon.

             If $iPing Then ;
                 icon('1', $iPing)
                 ;MsgBox(1, "", "You are Offline! Investigate!", 3000) If you want a notification.
                 icon('0', $iPing)
            $hTimer = TimerInit() ; Reset the timer.


        Switch TrayGetMsg()
            Case $iExit ; Exit the loop.

Func icon($response, $pingtime)

    If $response = 1 Then
            TraySetToolTip("Connected - Time: " & $pingtime &"ms")
            TraySetIcon(@ScriptFullPath, -5)
           ; TraySetIcon("C:\Status\connected.ico") for use before compile 
         ElseIf $response = 0 Then
            TraySetToolTip("Disconnected - Error: " & $pingtime)
            TraySetIcon(@ScriptFullPath, -6)
            ;TraySetIcon("C:\Status\disconnected.ico") for use before compile 


Thanks guys!


Edited by TRiCAM

Share this post

Link to post
Share on other sites

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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.