Sign in to follow this  
Followers 0
zFrank

@ All about internet @

6 posts in this topic

hi, please try to answer my questions.

1- how to check if the internet is active and connected?

2- how to connect to internet using autoit?

3- how to disconnect from internet using autoit?

Thanks a lot in advance for the help!


[font="Georgia"]GSM Expert[/font] but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy"
If @Error Then
$Life = "Risk"

Share this post


Link to post
Share on other sites



How about you answer this question then, how does your computer connect to the internet? If you use dial up, just run the program or close it to connect or disconnect.

Checking for internet is easy. Just ping a website you know isn't likely to be down. Google works.

Share this post


Link to post
Share on other sites

It's an AutoIt function. It's called Ping.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

if ping is blocked or doesnt work for you, another way is to use inetget. This works especially well if you have a website that you can place a specific page on. Consider the following code:

#include <File.au3>
;returns 1 if internet is working, 0 if it is not
ConsoleWrite(_CheckInternet("http://yoururlgoeshere.com/file.txt"))

Func _CheckInternet($_address)
    Dim $fa_file
    $fs_file = "C:\temp\randomfile.txt"
    InetGet($_address, $fs_file)
    _FileReadToArray ( $fs_file, $fa_file )
    if($fa_file[1] = "test") Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc

A couple of notes.

-If you dont have a website, then you need to pull down a page from an existing site. However, if the site changes and you are not aware, then the function could return negatively when everything is fine.

-I would recommend you use standard temp directory and randomly generated file names if you dont clean those up

-While this is perhaps more overhead than ping, it works by using port 80, which is generally not blocked (especially in a corporate environment)

-In my example, the file "file.txt" has the word test in it

Edited by Reaper HGN

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

#include <INet.au3>

if _GetIP ( ) = "" then msgbox(0,"","Internet disconnected!") ; checks to see if the internet is connected, if not, give a msgbox

or...

#include <INet.au3>

if _check() = 1 then

_DoSomething() ; continue with the script... internet is connected.

else

_Connect() ; good luck figuring this out

endif

func _check()

if _getip() = "" then return 0

return 1

endfunc

Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

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  
Followers 0