Jump to content

Recommended Posts

pilky1986

Hello,

I was looking around the net for a simple protable program to test whether you have an internet connection.. in short i couldnt find what i wanted so i wrote one.

After looking on the forum i found some code snippets from others who had started to this kind of thing, but no completed project.

Credits:

Autoit Team / Autoit Program!

ISN AutoIt Studio - '?do=embed' frameborder='0' data-embedContent>>

Post: '?do=embed' frameborder='0' data-embedContent>>

Autoitsnippet: http://www.autoitscript.com/wiki/AutoIt_Snippets#IsInternetConnected

Function (by Guiness): '?do=embed' frameborder='0' data-embedContent>>

I have attached the full code and compilied executable.

All constructive comments / improvement ideas / actual coded example imporovements, welcome.

Screenshots

Version 2

2014_03_09_20h57_22.png

2014_03_09_20h59_47.png

Version 1

2014_03_09_16h14_17.png

2014_03_09_16h14_24.png

2014_03_09_16h14_45.png

2014_03_09_16h14_48.png

Update:

09/03/2014 - v1.3 - Added a sleep() to the program loop to prevent high constant cpu usage - credit: wakillon

09/03/2014 - v1.2 - Added in another test (Microsoft Windows Test #2) using a function written by auto it forum member Guiness

09/03/2014 - v1.1 - Removed unnecessary includes, moved global variables to the top of the code - Credit: wakillon / water

Internet Connection Tester v1.3.zip

Edited by pilky1986

Share this post


Link to post
Share on other sites
wakillon

I have attached the full code and compilied executable.

 

Where ? 


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
pilky1986

Whoops, might help if i clicked upload :-)! thanks

Share this post


Link to post
Share on other sites
water

A good script to check is >microsoftinternetconnectivity tester by Guinness.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
wakillon

Whoops, might help if i clicked upload :-)! thanks

 

Ok, tested and approved  :)

Remarks :

Only GUIConstantsEx.au3 is needed

It's more secure to declare your global variables at the start of the script.

What's the utility of : #include "FormsInternet_Connection_Tester.isf" ?  :huh:


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
water

ISF files are used by ISI360's >ISN AutoIt studio.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
wakillon

ISF files are used by ISI360's >ISN AutoIt studio.

 

i know, but why add it to the Includes list ?


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
water

I think he just forgot to remove it.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-12-03 - Version 1.4.11.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
wakillon

I think he just forgot to remove it.

Yes or may be he used "include" instead of "fileinstall" to include it to the executable...


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
pilky1986

Hello,

Thank you for the feedback.

You are quite right, i should of included the global variables before anything else, i have amended this. I forgot to remove the other #includes, they were in there because i was using them but in the end did not need them. I forgot to tidy that up!!

I will have a look at microsoftinternetconnectivity tester to see if i can integrate this into the program also as another test.

 

Finally with regards to "#include "FormsInternet_Connection_Tester.isf" as water says its part of ISN Autoit Studio, if you remove the include then your script wont compile as the related form/gui coding is not then included. I had a look over ISN Autoit Studio's example project and it appears to be the way the person has designed it to be included in peoples scripts, or at least that is what i have concluded. However, i may be wrong?

If there is a better way of doing this (? Fileinstall) then i shall happily go back and resolve and re-upload. Thanks :)

Share this post


Link to post
Share on other sites
pilky1986

Just noticed that when the program is running (idle, i.e. not testing) it runs at a constant CPU usage of 25%.. struggling to figure out why :unsure:, any thoughts?

2014_03_09_21h02_22.png

Share this post


Link to post
Share on other sites
wakillon

Just noticed that when the program is running (idle, i.e. not testing) it runs at a constant CPU usage of 25%.. struggling to figure out why :unsure:, any thoughts?

2014_03_09_21h02_22.png

 

Add a sleep to your loop

Func _startgui()
    GUISetOnEvent($gui_event_close, "_ExitGUI", $internet_connection_tester)
    GUISetState(@SW_SHOW, $internet_connection_tester)
    While 1
        Switch GUIGetMsg()
            Case $gui_event_close
                ExitLoop
        EndSwitch
        Sleep ( 30 )
    WEnd
EndFunc
Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
pilky1986

 

Add a sleep to your loop

Func _startgui()
    GUISetOnEvent($gui_event_close, "_ExitGUI", $internet_connection_tester)
    GUISetState(@SW_SHOW, $internet_connection_tester)
    While 1
        Switch GUIGetMsg()
            Case $gui_event_close
                ExitLoop
        EndSwitch
        Sleep ( 30 )
    WEnd
EndFunc

 

How obvious! Thanks :-)

Its been a while since i used autoit, getting back into the swing of things now.

Share this post


Link to post
Share on other sites
wakillon

i have made some simplifications

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Icon=Icon.ico
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseUpx=y
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

;##############################################################################################################################################
;# Project Name: Internet Connection Tester
;#
;# Author: Alex Pilkington
;# Email: alex.pilkington@nhs.net
;#
;# Version: 1.0
;# Creation Date: 09/03/2014
;#
;# Change Log (Version - Date - Comments):
;#
;# v1.0 - 09/03/2014 - Program Created
;#
;##############################################################################################################################################
;##############################################################################################################################################
;###################################################### INITIAL PROGRAM CODING ################################################################
;##############################################################################################################################################
;Include any AUTOIT pre-existing functions/parameters that are called in the program

#Region    ;************ Includes ************
#Include <GUIConstantsEx.au3>
#EndRegion ;************ Includes ************

Opt("TrayIconHide", 1)
Opt("GUIOnEventMode", 1)

Global $result_winintcontest, $colour_winintcontest
Global $result_googledns, $colour_googledns
Global $result_opendns, $colour_opendns
Global $result_googlewww, $colour_googlewww
Global $colour_blue = "0x0000FF"
Global $colour_green = "0x008000"
Global $colour_red = "0xFF0000"

$internet_connection_tester = GUICreate("", 316, 430, -1, -1, -1, -1)
GUICtrlCreateLabel("Internet Connection Tester", 10, 18, 295, 26, 1, -1)
GUICtrlSetFont(-1, 14, 400, 4, "Arial Rounded MT Bold")
GUICtrlSetBkColor(-1, "-2")
$clicktotest = GUICtrlCreateButton("Click To Test", 110, 350, 100, 30, -1, -1)
GUICtrlSetOnEvent(-1, "_ClickToTest")
GUICtrlCreateGroup("", 10, 50, 295, 344, -1, -1)
GUICtrlSetBkColor(-1, "0xF0F0F0")
GUICtrlCreateLabel("Written by: Alex Pilkington  -  Version: 1.0", 10, 404, 238, 15, -1, -1)
GUICtrlSetBkColor(-1, "-2")
GUICtrlCreateGroup("Google DNS", 30, 124, 254, 45, -1, -1)
GUICtrlSetFont(-1, 10, 700, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, "0xF0F0F0")
GUICtrlCreateGroup("Open DNS", 30, 180, 254, 45, -1, -1)
GUICtrlSetFont(-1, 10, 700, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, "0xF0F0F0")
GUICtrlCreateGroup("Google Website", 30, 236, 254, 45, -1, -1)
GUICtrlSetFont(-1, 10, 700, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, "0xF0F0F0")
$mwt = GUICtrlCreateLabel("NOT TESTED", 39, 88, 245, 29, 512, -1)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, "0x0000FF")
GUICtrlSetBkColor(-1, "-2")
GUICtrlCreateGroup("Microsoft Windows Test", 30, 72, 254, 45, -1, -1)
GUICtrlSetFont(-1, 10, 700, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, "0xF0F0F0")
$gdns = GUICtrlCreateLabel("NOT TESTED", 39, 140, 245, 26, 512, -1)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, "0x0000FF")
GUICtrlSetBkColor(-1, "-2")
$odns = GUICtrlCreateLabel("NOT TESTED", 39, 196, 245, 29, 512, -1)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, "0x0000FF")
GUICtrlSetBkColor(-1, "-2")
GUICtrlCreateGroup("Last Test", 30, 295, 254, 45, -1, -1)
GUICtrlSetFont(-1, 10, 700, 0, "MS Sans Serif")
GUICtrlSetBkColor(-1, "0xF0F0F0")
$gwww = GUICtrlCreateLabel("NOT TESTED", 39, 253, 245, 27, 512, -1)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, "0x0000FF")
GUICtrlSetBkColor(-1, "-2")
$lt = GUICtrlCreateLabel("N/A", 39, 309, 245, 31, 512, -1)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, "0x0000FF")
GUICtrlSetBkColor(-1, "-2")
GUISetOnEvent($gui_event_close, "_ExitGUI", $internet_connection_tester)
GUISetState(@SW_SHOW, $internet_connection_tester)

While 1
    Sleep ( 30 )
WEnd

Func _exitgui()
    GUIDelete($internet_connection_tester)
    Exit
EndFunc

Func _isinternetconnected()
    Local $areturn = DllCall("connect.dll", "long", "IsInternetConnected")
    If @error Then Return SetError(1, 0, True)
    Return $areturn[0] = 0
EndFunc

Func _pinggoogledns()
    Local $iping = Ping("8.8.8.8")
    If $iping > 0 Then
        $result_googledns = "SUCCESS"
        $colour_googledns = $colour_green
    Else
        $result_googledns = "FAILURE"
        $colour_googledns = $colour_red
    EndIf
EndFunc

Func _pingopendns()
    Local $iping = Ping("208.67.222.222")
    If $iping > 0 Then
        $result_opendns = "SUCCESS"
        $colour_opendns = $colour_green
    Else
        $result_opendns = "FAILURE"
        $colour_opendns = $colour_red
    EndIf
EndFunc

Func _pinggooglewww()
    Local $iping = Ping("www.google.co.uk")
    If $iping > 0 Then
        $result_googlewww = "SUCCESS"
        $colour_googlewww = $colour_green
    Else
        $result_googlewww = "FAILURE"
        $colour_googlewww = $colour_red
    EndIf
EndFunc

Func _clicktotest()
    GUICtrlSetBkColor($clicktotest, 16763904)
    GUICtrlSetData($clicktotest, "Testing...")
    $result_winintcontest = "Error - Not Tested"
    $result_googledns = "Error - Not Tested"
    $result_opendns = "Error - Not Tested"
    $result_googlewww = "Error - Not Tested"
    GUICtrlSetData($mwt, "Testing...")
    GUICtrlSetColor($mwt, $colour_blue)
    GUICtrlSetFont($mwt, 10, 400)
    Local $inc_result = _isinternetconnected()
    If $inc_result = "True" Then
        $result_winintcontest = "CONNECTED"
        $colour_winintcontest = $colour_green
    Else
        $result_winintcontest = "NOT CONNECTED"
        $colour_winintcontest = $colour_red
    EndIf
    GUICtrlSetData($mwt, $result_winintcontest)
    GUICtrlSetColor($mwt, $colour_winintcontest)
    GUICtrlSetFont($mwt, 10, 700)
    GUICtrlSetData($gdns, "Testing...")
    GUICtrlSetColor($gdns, $colour_blue)
    GUICtrlSetFont($gdns, 10, 400)
    _pinggoogledns()
    GUICtrlSetData($gdns, $result_googledns)
    GUICtrlSetColor($gdns, $colour_googledns)
    GUICtrlSetFont($gdns, 10, 700)
    GUICtrlSetData($odns, "Testing...")
    GUICtrlSetColor($odns, $colour_blue)
    GUICtrlSetFont($odns, 10, 400)
    _pingopendns()
    GUICtrlSetData($odns, $result_opendns)
    GUICtrlSetColor($odns, $colour_opendns)
    GUICtrlSetFont($odns, 10, 700)
    GUICtrlSetData($gwww, "Testing...")
    GUICtrlSetColor($gwww, $colour_blue)
    GUICtrlSetFont($gwww, 10, 400)
    _pinggooglewww()
    GUICtrlSetData($gwww, $result_googlewww)
    GUICtrlSetColor($gwww, $colour_googlewww)
    GUICtrlSetFont($gwww, 10, 700)
    GUICtrlSetData($lt, @MDAY & "/" & @MON & "/" & @YEAR & " at " & @HOUR & ":" & @MIN & ":" & @SEC)
    GUICtrlSetFont($lt, 10, 700)
    GUICtrlSetData($clicktotest, "Click To Test")
    GUICtrlSetStyle($clicktotest, 0)
EndFunc

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
TechCoder

Here's another way.......

Share this post


Link to post
Share on other sites
pilky1986

Here's another way.......

 

TechCoder:

Func _online_status()
    Local $status = 0
    If @IPAddress1 <> "127.0.0.1" Then
        Local $oIE = _IECreate("http://www.msftncsi.com/ncsi.txt", 0, 0, 1, 0)
        Local $sText = _IEBodyReadText($oIE)
        If $sText = "Microsoft NCSI" Then
            $status = 1
        EndIf
        _IEQuit($oIE)
    EndIf
    Return $status
EndFunc   ;==>_online_status

I like that TechCoder, its a simplified way of doing what Guiness has done (which is the "Microsoft Windows Test #2", in my script). Nice code! :thumbsup:

Edited by pilky1986

Share this post


Link to post
Share on other sites
pilky1986

Does any one use a VPN here?

I do, and "Microsoft Windows Test #1" always fails when on the VPN (works if not) and the other test are successful, i assume its a limitation of the windows dll function call....

If someone could kindly verify if "Microsoft Windows Test #1" also fails on a VPN that would be greatly appreciated! :thumbsup:

Share this post


Link to post
Share on other sites
TechCoder

May be 'simplified', however, as stated in that post, my 'vote' is for the way guiness presented it - reads the dll the same as MS products - i.e., doesn't consume more resources and is 'equivalent' for many purposes.

When I get some time I'm going to study your multi-methods a bit more for one project I have (my program is faster than MS and works great for special purposes) and see if there is some 'combo' that makes for a better fit, though, lacking additional tests, I would say that a choice between the dll method and the 'fast' one that mirrors what Windows does (only with your own timer) seems to be the best.

Oh, on the VPN - sorry, can't help you, but I understand/feel that pain - being behind a router that is still running, but no internet connection is what caused me to research and get that function going.

BTW, I posted on this as I like your GUI idea (though would like to see it smaller - like 150 px high or something - would make a neat horizontal or vertical 'light' bar maybe?)

Share this post


Link to post
Share on other sites
pilky1986

May be 'simplified', however, as stated in that post, my 'vote' is for the way guiness presented it - reads the dll the same as MS products - i.e., doesn't consume more resources and is 'equivalent' for many purposes.

When I get some time I'm going to study your multi-methods a bit more for one project I have (my program is faster than MS and works great for special purposes) and see if there is some 'combo' that makes for a better fit, though, lacking additional tests, I would say that a choice between the dll method and the 'fast' one that mirrors what Windows does (only with your own timer) seems to be the best.

Oh, on the VPN - sorry, can't help you, but I understand/feel that pain - being behind a router that is still running, but no internet connection is what caused me to research and get that function going.

BTW, I posted on this as I like your GUI idea (though would like to see it smaller - like 150 px high or something - would make a neat horizontal or vertical 'light' bar maybe?)

 

I think most projects are driven out of necessity / curiosity. Like yourself, i have written this for a specific purpose, as i have a need to demonstrate to end users whether they have an internet connection. I built it in this way so that a user could run the app and test to see if they have an internet connection. As you said, they may have a LAN connection but not a WAN.

I like your thought about a smaller version, although personally i wouldn't have a need for it, so to be honest i doubt i would code a GUI for it :(

However, i think i could take this further by using a scoring method, based on each test to take away any interpretation required by the user. I think to be safe you would want to use a three-pronged approach to analysis which would require more tests than what is currently built in, probably pinging more DNS servers and potentially using more in-built windows functions, perhaps even checking TCP connections.

Depending on the outcome of further VPN testing, i will probably add in a message pop-up to notify the user that if test #1 fails and if they are on a VPN that this test is expected to fail (assuming the testing concludes this)

What was your project TechCoder?

Share this post


Link to post
Share on other sites
TechCoder

project is a commercially available product (sorry, can't/won't discuss that publicly, though the snippet is now 'open source'... - funny enough, 'clearly' explained at )'>)

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  

  • Similar Content

    • Rskm
      By Rskm
      Hi, for a script of mine, I wish to keep a time frame on till how the program will work.. basically, I want the program to read the date and if the read date < 'a particular date', the program continues, else it exit. I don't want to read the time from the computer as the program can be fooled by resetting the pc time. is there a way to read time from internet - so that the user cannot fool the program by date reset? thanks
    • ur
      By ur
      I have an aws cloud machine where I kept all the build process to create some set of zip files and uploading them to OneDrive.
      Once it is completed, I have another local machine in our environment which is a acting as a local share server also.
      Is there anyway to notify this machine(without public IP) to start downloading these files.
      I have written an AutoIT exe to download these files and copy them to respective locations.But don't know how to notify this from the remote machine.
       
      Any suggestion??
       
    • Nareshm
      By Nareshm
      Its Possible To auto Login with autoit script ?
    • hcI
      By hcI
      Hello everyone !
      While writing a sample of code to test ping to my internet box, I got stuck..
      While the code is Pinging with let say.. 5000ms of timeout, I need to update a progress bar from 0 to 5000 ms at the same time but I don't know how could I do this..
      Is there a way or something that could get around the pause of the ping like in InetGet -> InetGetInfo?
    • Pintu
      By Pintu
      Good evening guys,
      i'm having a problem, not about the code (i'm only thinking about it at the moment) but about the way i can do it.
      I have a webpage (photo N.1) it has some elements in it.
      I need only the table (photo N.2), looking at the code and with _IEFunctions i can easy find the table but how i can i "copy" it?
      As i said it's really easy to found with a script but what should i do then? Copy the source? And how can i display it to the user?
      In my head i'd like to display it inside a GUI, is that possible?
       
      Thanks in advance
       
      Edit: Posted 2 times same photo. Now should be OK

       

×