bluegaptek Posted April 20, 2016 Share Posted April 20, 2016 Hi, I'm noobs to autoit. Need simple script for ping loop, and if "request timed out" run specific application. Link to comment Share on other sites More sharing options...
AutoBert Posted April 20, 2016 Share Posted April 20, 2016 Buy one (but not here) or try to write your own. But note: not every webserver answers on a ping. For starting have a look in helpfile about: Quote Ping Pings a host and returns the roundtrip-time. Link to comment Share on other sites More sharing options...
bluegaptek Posted April 20, 2016 Author Share Posted April 20, 2016 11 hours ago, AutoBert said: Buy one (but not here) or try to write your own. But note: not every webserver answers on a ping. For starting have a look in helpfile about: I started with example script but can only get return value of 0 = failure. How to return value @error (e.g Host is offline) Link to comment Share on other sites More sharing options...
InunoTaishou Posted April 20, 2016 Share Posted April 20, 2016 What have you tried? Post your script. Link to comment Share on other sites More sharing options...
bluegaptek Posted April 21, 2016 Author Share Posted April 21, 2016 6 hours ago, InunoTaishou said: What have you tried? Post your script. Local $iPing = Ping("192.168.22.1", "250") MsgBox($MB_SYSTEMMODAL, "", "The roundtrip-time took: " & $iPing & "ms.") How to get specific value of error ? Link to comment Share on other sites More sharing options...
InunoTaishou Posted April 21, 2016 Share Posted April 21, 2016 Quote Return Value Success: the roundtrip-time in milliseconds ( greater than 0 ). Failure: 0 if host is not pingable or other network errors occurred and sets the @error flag to non-zero. @error: 1 = Host is offline 2 = Host is unreachable 3 = Bad destination 4 = Other errors Local $iPing = Ping("192.168.22.1", "250") Switch (@Error) Case 1 MsgBox("", "", "Host is offline.") ; I hope it's not, then you have no internet! Case 2 MsgBox("", "", "Host is unreacable.") Case 3 MsgBox("", "", "Bad destination.") Case 4 MsgBox("", "", "Other errors.") Case Else MsgBox($MB_SYSTEMMODAL, "", "The roundtrip-time took: " & $iPing & "ms.") EndSwitch bluegaptek 1 Link to comment Share on other sites More sharing options...
bluegaptek Posted April 21, 2016 Author Share Posted April 21, 2016 1 hour ago, InunoTaishou said: Local $iPing = Ping("192.168.22.1", "250") Switch (@Error) Case 1 MsgBox("", "", "Host is offline.") ; I hope it's not, then you have no internet! Case 2 MsgBox("", "", "Host is unreacable.") Case 3 MsgBox("", "", "Bad destination.") Case 4 MsgBox("", "", "Other errors.") Case Else MsgBox($MB_SYSTEMMODAL, "", "The roundtrip-time took: " & $iPing & "ms.") EndSwitch Hey thanks, this is what I need. But autoit ping return "Host is unreachable" while I don't have internet connection and windows ping show "request timed out" Since I need this to reconnect wifi (fyi: sometimes my wifi status connected but can't reach internet, but by reconnecting I'm able to reach internet again) Is there anyway around to accomplish this ? Link to comment Share on other sites More sharing options...
InunoTaishou Posted April 21, 2016 Share Posted April 21, 2016 You're pinging your router and getting host unreachable (same thing as timed out, means windows tried to send data to the ip but didn't get a reply within the time limit). Sounds like you need to disconnect then reconnect. I usually disable my adapter then re-enable it. I'm sure there's a UDF floating around on the forum somewhere for reconnecting to wifi or disable/enable your network adapter. Link to comment Share on other sites More sharing options...
bluegaptek Posted April 21, 2016 Author Share Posted April 21, 2016 24 minutes ago, InunoTaishou said: 24 minutes ago, InunoTaishou said: You're pinging your router and getting host unreachable (same thing as timed out, means windows tried to send data to the ip but didn't get a reply within the time limit). Sounds like you need to disconnect then reconnect. I usually disable my adapter then re-enable it. I'm sure there's a UDF floating around on the forum somewhere for reconnecting to wifi or disable/enable your network adapter. You're pinging your router and getting host unreachable (same thing as timed out, means windows tried to send data to the ip but didn't get a reply within the time limit). Sounds like you need to disconnect then reconnect. I usually disable my adapter then re-enable it. I'm sure there's a UDF floating around on the forum somewhere for reconnecting to wifi or disable/enable your network adapter. Ok, now I get it, I use windows cmd or batch to reconnect the network adapter. Thank you for the code, really appreciate that. 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