DCCD Posted October 27, 2008 Share Posted October 27, 2008 hey i wanna check my Internet connection, if Not able to connect to internet, I have to check it again and again "HOW" $ping = Ping("www.google.com") If $ping > 0 then My Script etc... Else I have to check it again and again "HOW" EndIf [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
JRowe Posted October 27, 2008 Share Posted October 27, 2008 (edited) Run the TestConnection function before any of your other code. TestConnection() While $AmIDoneYet = 1 MsgBox(0, "Test App", "Your Internet Is On!") $AmIDoneYet = 0 Wend Func TestConnection() While $AmIConnected <> "True" $ping = Ping("www.google.com") If $ping > 0 then $AmIConnected = "True" EndIf WEnd EndFunc Of course, this will use 100% CPU and run until it connects to the internet, or you close it manually. You'll have to set it to check every 20 seconds or so, can just add a simple Sleep(20000) after the EndIf within the TestConnection function. Or however else you want to do it, but theres your internet connection test function. Edited October 27, 2008 by jrowe [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
DCCD Posted October 27, 2008 Author Share Posted October 27, 2008 thanks, i guess i need beta ver coz i got this My Autoit ver3.2.10.0 [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
JRowe Posted October 27, 2008 Share Posted October 27, 2008 Newp, just means you have to declare the variable. In the messagebox, notice that theres a "^" pointing at where the error occurs, this lets you know where something is going wrong. $AmIDoneYet = 1 TestConnection() While $AmIDoneYet = 1 MsgBox(0, "Test App", "Your Internet Is On!") $AmIDoneYet = 0 Wend Func TestConnection() Local $AmIConnected = "init" While $AmIConnected <> "True" $ping = Ping("www.google.com") If $ping > 0 Then $AmIConnected = "True" EndIf WEnd EndFunc This is just random, stream of consciousness programming, and in no way should your scripts be modeled on this style. I'd recommend going through the AutoIt 1-2-3 lessons, they'd help you alot [center]However, like ninjas, cyber warriors operate in silence.AutoIt Chat Engine (+Chatbot) , Link Grammar for AutoIt , Simple Speech RecognitionArtificial Neural Networks UDF , Bayesian Networks UDF , Pattern Matching UDFTransparent PNG GUI Elements , Au3Irrlicht 2Advanced Mouse Events MonitorGrammar Database GeneratorTransitions & Tweening UDFPoker Hand Evaluator[/center] Link to comment Share on other sites More sharing options...
SoulA Posted October 27, 2008 Share Posted October 27, 2008 Try this.... note that google won't always return a ping response sometimes even if you are connected to the inet and google is up. $ping = Ping("www.google.com") If Not @error Then ;do script here Else Do $ping = Ping("www.google.com") Until Not @error ;do script here EndIf Link to comment Share on other sites More sharing options...
DCCD Posted October 27, 2008 Author Share Posted October 27, 2008 Thanks everybody, Great Works [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
rasim Posted October 27, 2008 Share Posted October 27, 2008 DCCDAnother way:$connect = _GetNetworkConnect() If $connect Then MsgBox(64, "Connections", $connect) Else MsgBox(48, "Warning", "There is no connection") EndIf 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 ahmeddzcom and Imperial 2 Link to comment Share on other sites More sharing options...
tungpheng Posted April 7, 2018 Share Posted April 7, 2018 If _IsInternetConnected() Then msgbox(0,"True","Internet Connected") Else Msgbox(0,"False","Internet Disconected") Endif Func _IsInternetConnected() Local $aReturn = DllCall('connect.dll', 'long', 'IsInternetConnected') If @error Then Return SetError(1, 0, False) EndIf Return $aReturn[0] = 0 EndFunc ;==>_IsInternetConnected That is my func I alsway to check Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 7, 2018 Moderators Share Posted April 7, 2018 tungpheng, The fact that the post above yours is from 10 years ago somehow escaped your notice? Please do not necro-post like this again. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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