Jump to content

Script checks the internet connection


Tiger
 Share

Recommended Posts

I have wrote a script, that runs always. then the internet connection is active then show the trayicon. but the script start and close.

#NoTrayIcon
Opt("TrayIconDebug", 0)
Opt("TrayMenuMode", 1)

AdlibEnable("internet", 500)

Func internet()
    If (Ping("www.google.de", 500) <> 0) And (Ping("www.yahoo.de", 750) <> 0) Then
        ; Show TrayIcon
        Opt("TrayIconHide", 0)
    Else
        ; Hide TrayIcon
        Opt("TrayIconHide", 1)
    EndIf
EndFunc   ;==>_internet
My UDFs:- _RegEnumKey
Link to comment
Share on other sites

You need an infinite loop:

#NoTrayIcon
Opt("TrayIconDebug", 0)
Opt("TrayMenuMode", 1)
HotKeySet("{F9}", "ExitModule")
internet()
AdlibEnable("internet", 10000)
Func internet()
    If Ping("www.google.de") Or Ping("www.yahoo.de") Then
        Opt("TrayIconHide", 0)
    Else
        Opt("TrayIconHide", 1)
    EndIf
EndFunc;==>internet
While 1
    Sleep(60)
WEnd
Func ExitModule()
    Exit
EndFunc;==>ExitModule

The above code works on my machine. Once program execution reached the end of the original version, it correctly exited. But with this line in your script:

Opt("TrayMenuMode", 1)

you needed a way to stop the program, and that is why you should have that ExitModule and the HotKeySet.

Edited by Squirrely1

Das Häschen benutzt Radar

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...