zFrank Posted August 23, 2008 Share Posted August 23, 2008 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 More sharing options...
Richard Robertson Posted August 23, 2008 Share Posted August 23, 2008 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. Link to comment Share on other sites More sharing options...
zFrank Posted August 23, 2008 Author Share Posted August 23, 2008 i use ZTE DialUp, how to use ping? i want to do some tasks if net is connect and then disconnect it. [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 More sharing options...
Richard Robertson Posted August 23, 2008 Share Posted August 23, 2008 It's an AutoIt function. It's called Ping. Link to comment Share on other sites More sharing options...
Reaper HGN Posted August 26, 2008 Share Posted August 26, 2008 (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 August 26, 2008 by Reaper HGN Link to comment Share on other sites More sharing options...
ReaImDown Posted August 26, 2008 Share Posted August 26, 2008 (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 August 26, 2008 by ReaImDown [u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now