Jump to content
Sign in to follow this  

Check if internet is down script

Recommended Posts



I have made a small script for use on infoscreens on a school i work on, and i am a newbie into autoit scripting.

This is i want the script to do:

First check if internet is on the pc, if not then a splashimage is coming up that says internet is down. While the splashimage is up i want the script to check the whole time if the internet has returned and then close the splashimage, the rest is ok.

Here is the script

$ping = Ping ( "www.google.no" )
if @error Then
    SplashImageOn ( "infoskjerm", "C:/infoskjerm.JPG", @DesktopWidth,@DesktopHeight,0,0,1)
        $ping = Ping ( "www.google.no" )
    Until Not @error
;Starter Firefox og maksimerer og gjør firefox fullskjerm
    SplashImageOn ( "infoskjerm", "C:/infoskjerm.JPG", @DesktopWidth,@DesktopHeight,0,0,1)
    run ("C:\Programfiler\Mozilla Firefox\firefox.exe" ,"", @SW_MAXIMIZE)
    WinActivate ( "show tilte browse - Mozilla Firefox" )
    WinWaitActive ("show tilte browse - Mozilla Firefox")
    Send ("{TAB} {F11}") 
    WinWait ("show tilte browse - Mozilla Firefox")
    MouseMove ( 1400, 980 )

Can someone help me? :idea:

Share this post

Link to post
Share on other sites

Hey, do you want to use your code as a base?

I prefer working with functions, but you can incorporate it into the main program as well.

Here's something you can try:

It continuously checks for internet and if the connection is lost the splash is shown, once the connection returns the splash disappears.

The function returns 0 when there is no connection and returns the ping time otherwise.

$splashfile = "1.jpg"
$splashon = 0

while 1
    $internet = checkinternet()
    if $internet > 0 Then
        ;there is a connection

func checkinternet()
    $res = Ping("www.google.no",2000)
    if $res = 0 and $splashon = 0 Then
            $splashon = 1
    ElseIf $res > 0 and $splashon = 1 then
            $splashon = 0
    return $res


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.