rayven Posted February 4, 2012 Share Posted February 4, 2012 (edited) I'm trying to put in a way to check internet in my script I'm working on. Someone said I should use the TestConnection() function, and I have it in the script but it's not working as it should I want the script to for instance, if the user has internet, let the user know via an msg box that internet is available and continue with the rest of the script. Otherwise, if internet is not available, tell them with a msg box that no internet is detected and exit. The function should ping google to test net connectivity. This is what I have, it fails, though: ToolTip("Checking Internet", 0, 0, "Checking for internet connectivity.", 0) TestConnection() While $AmIConnectedYet = 1 MsgBox(0, "Connection Detected", "An internet connection has been detected, continuing on ...", 2) Wend While $AmIConnectedYet = 0 MsgBox(0, "No Connection Detected", "An internet connection was not detected, Exiting ...", 2) exit; Wend Func TestConnection() While $AmIConnectedYet <> "True" $ping = Ping("google.com") If $ping > 0 then $AmIConnectedYet = "True" EndIf WEnd EndFunc Edited February 4, 2012 by rayven Link to comment Share on other sites More sharing options...
Guest Posted February 4, 2012 Share Posted February 4, 2012 (edited) Use this function it's really good i use it too. Edited February 4, 2012 by Guest Link to comment Share on other sites More sharing options...
Chimaera Posted February 4, 2012 Share Posted February 4, 2012 Here's a canny way from guinness that i always use $net_test = _IsInternetConnectedEx() If $net_test = 1 Then $net_test = "Connected" Else $net_test = "Not Connected" EndIf ConsoleWrite("Internet Is " & $net_test & @CRLF) Func _IsInternetConnectedEx() ; Returns 1 = ON or 0 = OFF Local $is_Return = DllCall("wininet.dll", "int", "InternetGetConnectedState", "int", 0, "int", 0) If (@error) Or ($is_Return[0] = 0) Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_IsInternetConnectedEx If Ive just helped you ... miracles do happen. Chimaera CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices() 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