Jump to content

Simple Check For Internet (unfinished new bug found)


Draygoes
 Share

Recommended Posts

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. :mad:

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.:(:sweating:

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[1], $NETWORK_ALIVE_LAN) Then $iResult &= "LAN connected" & @LF
    If BitAND($aRet[1], $NETWORK_ALIVE_WAN) Then $iResult &= "WAN connected" & @LF
    If BitAND($aRet[1], $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. :)

Edited by Draygoes
Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Link to comment
Share on other sites

This won't tell you that you're connected to the internet, it only tells you if you have a network connection.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

This won't tell you that you're connected to the internet, it only tells you if you have a network connection.

As of this moment I will put a warning at the top of this thread until I can get a better version up and running. Thank you for pointing that out though, this could have caused serious headachs for developers.

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
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

×
×
  • Create New...