#include-once #include #include MsgBox(0,0,_ExtIP()) Func _ExtIP() Local $myIP = 0 If _ExtOpenDNSIP($myIP) Then Return $myIP EndIf If _ExtGoogleIP($myIP) Then Return $myIP EndIf If _ExtProvidersIP($myIP) Then Return $myIP EndIf Return 0 EndFunc Func _ExtOpenDNSIP(ByRef $ip) $pid = Run(@ComSpec & " /C " & "nslookup myip.opendns.com resolver1.opendns.com", "", @SW_HIDE, 6) ProcessWaitClose($pid) $str = StdoutRead($pid) $aRXP = StringRegExp($str, "((?:\d{1,3}\.){3}\d{1,3})", 3) If @error Then Return 0 EndIf $ip = $aRXP[UBound($aRXP) -1] Return 1 EndFunc ;==>_ExtOpenDNSIP Func _ExtProvidersIP(ByRef $ip) Local $UA = HttpSetUserAgent("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36") Local $aSites2[3] = ["http://checkip.dyndns.org", "http://www.myexternalip.com/raw", "http://bot.whatismyipaddress.com"] _ArrayShuffle($aSites2) For $i = 0 To UBound($aSites2) - 1 $sRead = BinaryToString(InetRead($aSites2[$i])) $aRXP = StringRegExp($sRead, "((?:\d{1,3}\.){3}\d{1,3})", 3) If Not @error And $aRXP[0] <> "" Then HttpSetUserAgent($UA) $ip = $aRXP[0] Return 1 EndIf Next HttpSetUserAgent($UA) Return 0 EndFunc ;==>_ExtIP Func _ExtGoogleIP(ByRef $ip) Local $UA = HttpSetUserAgent("Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36") $sRead = BinaryToString(InetRead("https://www.google.com/search?q=my+ip+is%3F")) $aRead = _StringBetween($sRead, "div data-hveid", "Your public IP address") If @error Then $UA = HttpSetUserAgent($UA) Return 0 EndIf $aRXP = StringRegExp($aRead[0], "((?:\d{1,3}\.){3}\d{1,3})", 3) If Not @error And $aRXP[0] <> "" Then $UA = HttpSetUserAgent($UA) $ip = $aRXP[0] Return 1 EndIf $UA = HttpSetUserAgent($UA) Return 0 EndFunc ;==>_ExtIP