Jump to content

@ All about internet @


 Share

Recommended Posts

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"
Link to comment
Share on other sites

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

#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]
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...