Swift Posted February 23, 2008 Share Posted February 23, 2008 This works...like half the time...then does work other times...can anyone help me? While 1 InetGet("http://www.autoitscript.com") If @error = 0 Then ToolTip("No Internet", 1, 1) If Not @error Then ToolTip("", 1, 1) Sleep(2000) WEnd Link to comment Share on other sites More sharing options...
MHz Posted February 23, 2008 Share Posted February 23, 2008 I would not use InetGet() in a tight loop like that just to test for internet connectivity. You would be drawing a load on the website just for your testing. Look at the sample at the AutoIt Wiki.http://www.autoitscript.com/wiki/Connected Link to comment Share on other sites More sharing options...
Swift Posted February 23, 2008 Author Share Posted February 23, 2008 (edited) That doesnt do what im looking for. Thanks anyway. I tried this..But its not working While 1 $INTERNET_CONNECTION_MODEM = 0x1 $INTERNET_CONNECTION_LAN = 0x2 $INTERNET_CONNECTION_PROXY = 0x4 $INTERNET_CONNECTION_MODEM_BUSY = 0x8 $INTERNET_RAS_INSTALLED = 0x10 $INTERNET_CONNECTION_OFFLINE = 0x20 $INTERNET_CONNECTION_CONFIGURED = 0x40 $ret = DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0) If $ret[0] then ;check type of connection $sX = "" If BitAND($ret[1], $INTERNET_CONNECTION_MODEM) Then $sX = $sX & "MODEM" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_LAN) Then $sX = $sX & "LAN" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_PROXY) Then $sX = $sX & "PROXY" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_MODEM_BUSY) Then $sX = $sX & "MODEM_BUSY" & @LF If BitAND($ret[1], $INTERNET_RAS_INSTALLED) Then $sX = $sX & "RAS_INSTALLED" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_OFFLINE) Then $sX = $sX & "OFFLINE" & @LF If BitAND($ret[1], $INTERNET_CONNECTION_CONFIGURED) Then $sX = $sX & "CONFIGURED" & @LF Else $sX = "No Internet" Endif ToolTip($sX, 1, 1) Sleep(2000) WEnd EDIT: and I dont want to use BETA for it. Edited February 23, 2008 by Swift Link to comment Share on other sites More sharing options...
newcomer11 Posted February 23, 2008 Share Posted February 23, 2008 Hi Swift, you should change "int_ptr" to "int*" (read the history if you're using AUTOIT v3.2.10.0) so the line 10 should be : $ret = DllCall("WinInet.dll","int","InternetGetConnectedState","int*",0,"int",0) Link to comment Share on other sites More sharing options...
MHz Posted February 23, 2008 Share Posted February 23, 2008 This example may help you. It shows whether a connection is available and if Google is responding to a ping request. expandcollapse popupGlobal Const $INTERNET_CONNECTION_MODEM = 0x1 Global Const $INTERNET_CONNECTION_LAN = 0x2 Global Const $INTERNET_CONNECTION_PROXY = 0x4 Global Const $INTERNET_CONNECTION_MODEM_BUSY = 0x8 Global Const $INTERNET_RAS_INSTALLED = 0x10 Global Const $INTERNET_CONNECTION_OFFLINE = 0x20 Global Const $INTERNET_CONNECTION_CONFIGURED = 0x40 $handle_wininet = DllOpen('WinInet.dll') While 1 $ret = DllCall($handle_wininet, "int", "InternetGetConnectedState", "int*", 0, "int", 0) If $ret[0] Then ;check type of connection $sX = "" If BitAND($ret[1], $INTERNET_CONNECTION_MODEM) Then $sX &= "MODEM" & @CRLF If BitAND($ret[1], $INTERNET_CONNECTION_LAN) Then $sX &= "LAN" & @CRLF If BitAND($ret[1], $INTERNET_CONNECTION_PROXY) Then $sX &= "PROXY" & @CRLF If BitAND($ret[1], $INTERNET_CONNECTION_MODEM_BUSY) Then $sX &= "MODEM_BUSY" & @CRLF If BitAND($ret[1], $INTERNET_RAS_INSTALLED) Then $sX &= "RAS_INSTALLED" & @CRLF If BitAND($ret[1], $INTERNET_CONNECTION_OFFLINE) Then $sX &= "OFFLINE" & @CRLF If BitAND($ret[1], $INTERNET_CONNECTION_CONFIGURED) Then $sX &= "CONFIGURED" & @CRLF ;check to see if Google is online If Ping('www.google.com') Then $sX &= 'GOOGLE IS ONLINE' Sleep(3000) EndIf Else $sX = "No Internet" EndIf ToolTip($sX, 1, 1) Sleep(2000) WEnd Func OnAutoItExit() DllClose($handle_wininet) EndFunc Link to comment Share on other sites More sharing options...
SandelPerieanu Posted March 7, 2008 Share Posted March 7, 2008 This example may help you. It shows whether a connection is available and if Google is responding to a ping request. expandcollapse popupGlobal Const $INTERNET_CONNECTION_MODEM = 0x1 Global Const $INTERNET_CONNECTION_LAN = 0x2 Global Const $INTERNET_CONNECTION_PROXY = 0x4 Global Const $INTERNET_CONNECTION_MODEM_BUSY = 0x8 Global Const $INTERNET_RAS_INSTALLED = 0x10 Global Const $INTERNET_CONNECTION_OFFLINE = 0x20 Global Const $INTERNET_CONNECTION_CONFIGURED = 0x40 $handle_wininet = DllOpen('WinInet.dll') While 1 $ret = DllCall($handle_wininet, "int", "InternetGetConnectedState", "int*", 0, "int", 0) If $ret[0] Then ;check type of connection $sX = "" If BitAND($ret[1], $INTERNET_CONNECTION_MODEM) Then $sX &= "MODEM" & @CRLF If BitAND($ret[1], $INTERNET_CONNECTION_LAN) Then $sX &= "LAN" & @CRLF If BitAND($ret[1], $INTERNET_CONNECTION_PROXY) Then $sX &= "PROXY" & @CRLF If BitAND($ret[1], $INTERNET_CONNECTION_MODEM_BUSY) Then $sX &= "MODEM_BUSY" & @CRLF If BitAND($ret[1], $INTERNET_RAS_INSTALLED) Then $sX &= "RAS_INSTALLED" & @CRLF If BitAND($ret[1], $INTERNET_CONNECTION_OFFLINE) Then $sX &= "OFFLINE" & @CRLF If BitAND($ret[1], $INTERNET_CONNECTION_CONFIGURED) Then $sX &= "CONFIGURED" & @CRLF ;check to see if Google is online If Ping('www.google.com') Then $sX &= 'GOOGLE IS ONLINE' Sleep(3000) EndIf Else $sX = "No Internet" EndIf ToolTip($sX, 1, 1) Sleep(2000) WEnd Func OnAutoItExit() DllClose($handle_wininet) EndFunc $google=DllCall("WinInet.dll","int","InternetCheckConnectionA","str",'http://www.google.com',"int",1,'int',0) IF $google[0] Then MsgBox(262144,'','Google is online') Link to comment Share on other sites More sharing options...
Chris86 Posted March 22, 2008 Share Posted March 22, 2008 (edited) $var = Ping("www.google.com",1000) If @error = 0 Then Msgbox(0,"Status","Online, roundtrip was:" & $var) Else Msgbox(0,"Status","An error occured with number: " & @error) EndIf This should work Edited March 22, 2008 by Chris86 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