Jump to content
Sign in to follow this  
WhiteTiger

Checkinet

Recommended Posts

WhiteTiger

func checkinet()
$f_con = DllCall("wininet.dll","Dword","InternetAttemptConnect")
if $f_con <> 0 then 
    DllCall("wininet.dll","dword","InternetAttemptConnect")
    $f_con = DllCall("wininet.dll","Dword","InternetAttemptConnect")
if $f_con <> 0 then 
    Return -1
EndIf
EndIf
$f_open = DllCall("wininet.dll","dword","InternetOpen","Dword","dwAccesType")
if not $f_open = 0 then Return $f_open
EndFunc

This will return 0 if connecton is good , else it wil return a systemError number :-)

i hope some-one might think its usefull :-)

Share this post


Link to post
Share on other sites
masvil

It works here. In which cases it can be better than ping to microsoft or google?

Share this post


Link to post
Share on other sites
NELyon

What are the chances of both google and Microsoft being down?

Works fine here. Nice function :whistle:

Share this post


Link to post
Share on other sites
IcyFerno

ok this is cool, but is you are not connected, it shd display as?


Share this post


Link to post
Share on other sites
MHz

You call "InternetAttemptConnect" 3 times if ok connection?, but then call "InternetOpen" when no connection exists which opens a handle which you may need to close with "InternetCloseHandle". The UDF seems to be incomplete.

Share this post


Link to post
Share on other sites
WhiteTiger

You call "InternetAttemptConnect" 3 times if ok connection?, but then call "InternetOpen" when no connection exists which opens a handle which you may need to close with "InternetCloseHandle". The UDF seems to be incomplete.

nope :-) it checks if there's is a connection , if it inst , it try's to connect , if it still isnt online then it returns an error , else it prepare's a connection , just in case windows doesnt do this automaticly :-)

and thanks for the nice reply's

Share this post


Link to post
Share on other sites
IcyFerno

nope :-) it checks if there's is a connection , if it inst , it try's to connect , if it still isnt online then it returns an error , else it prepare's a connection , just in case windows doesnt do this automaticly :-)

erm, i doubt windows will not be that stupid to attemp a reconnection...


Share this post


Link to post
Share on other sites
WhiteTiger

erm, i doubt windows will not be that stupid to attemp a reconnection...

im sure about 1 thing , windows isnt smart

Share this post


Link to post
Share on other sites
SmOke_N

im sure about 1 thing , windows isnt smart

Smarter than most end-users...

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
IcyFerno

Smarter than most end-users...

lol good comment :applause: :whistle:

Share this post


Link to post
Share on other sites
Richard Robertson

Windows isn't smart. I think Windows needs an implementation of Alice. Then she could help people who have issues. That is what Windows needs.

Share this post


Link to post
Share on other sites
Valik

But with Microsoft's track record, the only thing that would end up with issues would be the ALICE implementation and then the frustration from dealing with an artificially stupid operating system would drive people to other issues.

Share this post


Link to post
Share on other sites
Rick

; $IsCon[0] = 0 not connected, $IsCon[0] = 1 is connec.

$IsCon=DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0)

MsgBox(4096,"",$IsCon[0])

short and sweet

sorry, a type error corrected

Edited by Rick

Who needs puzzles when we have AutoIt!!

Share this post


Link to post
Share on other sites
IcyFerno

thanks for your contribution.

i needed this in my script which requires to check a connection

but i noticed that this is quite slow when my script is at this part

any way to do this faster?

Edited by IcyFerno

Share this post


Link to post
Share on other sites
jaenster

I'm not knowing much about dll's, but it seems to be a much better way to check the inet connection than ping or so...

Nice :lmao:

;) Fully true.. Thanks white tiger


-jaenster

Share this post


Link to post
Share on other sites
WhiteTiger

;) Fully true.. Thanks white tiger

no problem :-) just doing my job (hmm that doesnt sound bad , does it ?)

Share this post


Link to post
Share on other sites
anixon

; 0 = not connected 1 is connected.

$IsCon=DllCall("WinInet.dll","int","InternetGetConnectedState","int_ptr",0,"int",0)

MsgBox(4096,"",$IsCon[0])

short and sweet

Very nice but how do you wrap around a while or do statement that requires the result to the dllcall to be 1 before continuing to run the script? Ant

Share this post


Link to post
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
Sign in to follow this  

×