Search the Community
Showing results for tags 'check internet connection'.
Found 2 results
EDIT: Warning... Brewman said it the best: "Your last script will only tell you if your computer is connected to a network, it won't tell you if your network is connected to the internet." This was proven when my internet connection went out before I even got that warning and the script all to happily announced that I was connected. Oh well... back to the drawing board. And this time I plan to test it during the night when I can reset my router whenever I need as a fair test of what happens during an outage. For now, it may still be of some use to others. I will leave the script below in tact even once the other version is completed because you never know. One mans trash and all that... This is in general help and support as well, but I thought that it wouldnt hurt to post it here too. There are plenty of reasons to check for an active connection, and this is a pretty different way of getting it done. While 1 $connect = _GetNetworkConnect() If $connect Then MsgBox(64, "YES!!!", $connect) Exit Else Sleep( 3000 ) EndIf WEnd Func _GetNetworkConnect() Local Const $NETWORK_ALIVE_LAN = 0x1 ;net card connection Local Const $NETWORK_ALIVE_WAN = 0x2 ;RAS (internet) connection Local Const $NETWORK_ALIVE_AOL = 0x4 ;AOL Local $aRet, $iResult $aRet = DllCall("sensapi.dll", "int", "IsNetworkAlive", "int*", 0) If BitAND($aRet, $NETWORK_ALIVE_LAN) Then $iResult &= "LAN connected" & @LF If BitAND($aRet, $NETWORK_ALIVE_WAN) Then $iResult &= "WAN connected" & @LF If BitAND($aRet, $NETWORK_ALIVE_AOL) Then $iResult &= "AOL connected" & @LF Return $iResult EndFunc And of course, I will give credit where it is due. I may have modified this code to my needs, but most of it belongs to rasim, and the original solution can be found here. I truly hope that someone finds some use for this.
Please Note This Has Been Solved! I am leaving this here for anyone with the same problem. Solution in this post. Sorry for the vague title, but it was the best that I could come up with considering. Suddenlink has been switching our connection on and off for the last few days as they make upgrades. In some of these cases, its been a few hours. So, I decided to modify one of the example scripts in an attempt to get the script to display a msgbox upon finding an internet connection. I leave the volume on full, this way I know exactly when the connection comes back. The problem with this is that when I glanced at the computer after 30 more mins, I found that we DID have a connection, yet the script had not displayed the Msg. I do not feel that I need to tell you guys how out of touch with Autoit I am, so this is a problem that I cannot even fathom the issue of. In my mind, the script looks perfect. Anyway, I will defer to the wonderful genus that is this community to see what the issue is. I will upload the code as is. If you could present the fixed code, along with an explanation of what I did wrong I would be very grateful. Fix or not, I just thank you for taking the time to read this. #include <MsgBoxConstants.au3> Example() Func Example() Local $dData = InetRead("http://www.autoitscript.com/autoit3/files/beta/update.dat") Local $iBytesRead = @extended Local $sData = BinaryToString($dData) If $sData = "" Then Sleep( 1000 ) Example() EndIf MsgBox(0, "YAY!!!", "Internet Connection Back!") EndFunc As you can see, I was hoping that if it returned an empty string then the code would simply restart the function. But, should it show anything other than a blank string I figured that it would pass the EndIf and display the Msg. Somehow I got this wrong. I noticed one possible issue in the above code, and that was in the variable. I accidentally read the wrong variable it would seem. However, fixing that still did not result in a working script. EDITED CODE #include <MsgBoxConstants.au3> Example() Func Example() Local $dData = InetRead("http://www.autoitscript.com/autoit3/files/beta/update.dat") Local $iBytesRead = @extended Local $sData = BinaryToString($dData) If $dData = "" Then Sleep( 1000 ) Example() EndIf MsgBox(0, "YAY!!!", "Internet Connection Back!") EndFunc