Rad Posted November 12, 2006 Share Posted November 12, 2006 Explained in the title, not sure how I would determine the IP... Is there a way to read it from your lan driver or whatever? Not really sure. I also thought about trying to search for your IP from a webpage (ex: www.getip.com) but havent tried that (might be an easier way) I searched but it gives me an error - I think because IP is to short or maybe it just returned to many results... Maybe theres even a registry key that stores your IP? But then again I probrably couldnt find that either Link to comment Share on other sites More sharing options...
PaulIA Posted November 13, 2006 Share Posted November 13, 2006 Explained in the title, not sure how I would determine the IP...Is there a way to read it from your lan driver or whatever? Not really sure. I also thought about trying to search for your IP from a webpage (ex: www.getip.com) but havent tried that (might be an easier way)I searched but it gives me an error - I think because IP is to short or maybe it just returned to many results...Maybe theres even a registry key that stores your IP? But then again I probrably couldnt find that eitherTake a look at this and see if it will work for you. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
Rad Posted November 13, 2006 Author Share Posted November 13, 2006 (edited) Thanks that helped alot =) also thanks to JSThePatriot for his code, i fixed it a bit... his must have been outdated If URLDownloadToFile("http://www.whatismyip.com",@tempdir & "\~ip.tmp") Then $IP = FileRead(@tempdir & "\~ip.tmp",FileGetSize(@tempdir & "\~ip.tmp")) FileDelete(@tempdir & "\~ip.tmp") $IP = StringTrimLeft($IP,StringInStr($IP,"<TITLE>WhatIsMyIP.com - ")+stringlen("<TITLE>WhatIsMyIP.com - ")-1) $IP = StringLeft($IP,StringInStr($IP,"</TITLE>")-1) msgbox(0,"",'"' & $IP & '"') Return $ip Else SetError(1) Return -1 EndIf Edit~I was just adding this to my UDF under the name _GetIP... and it highlighted it as a func as I wrote it... There was a func already lol =) Edited November 13, 2006 by Rad Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 13, 2006 Moderators Share Posted November 13, 2006 Thanks that helped alot =) also thanks to JSThePatriot for his code, i fixed it a bit... his must have been outdated If URLDownloadToFile("http://www.whatismyip.com",@tempdir & "\~ip.tmp") Then $IP = FileRead(@tempdir & "\~ip.tmp",FileGetSize(@tempdir & "\~ip.tmp")) FileDelete(@tempdir & "\~ip.tmp") $IP = StringTrimLeft($IP,StringInStr($IP,"<TITLE>WhatIsMyIP.com - ")+stringlen("<TITLE>WhatIsMyIP.com - ")-1) $IP = StringLeft($IP,StringInStr($IP,"</TITLE>")-1) msgbox(0,"",'"' & $IP & '"') Return $ip Else SetError(1) Return -1 EndIf Edit~I was just adding this to my UDF under the name _GetIP... and it highlighted it as a func as I wrote it... There was a func already lol =)Yes, it's in the Inet.au3 include. 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. Link to comment Share on other sites More sharing options...
Cue Posted November 13, 2006 Share Posted November 13, 2006 (edited) There was a func already lol =)_GetIP gets local ip i think, but i guess you know that right. Edited November 13, 2006 by Cue Link to comment Share on other sites More sharing options...
xcal Posted November 13, 2006 Share Posted November 13, 2006 _GetIP gets your IP as seen in the 'net. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
AzKay Posted November 13, 2006 Share Posted November 13, 2006 _GetIP() gets your global ip. # MY LOVE FOR YOU... IS LIKE A TRUCK- # Link to comment Share on other sites More sharing options...
LondonNDIB Posted March 4, 2007 Share Posted March 4, 2007 (edited) _GetIP unfortunately relies on external websites to return your IP... is there not a more reliable method for retrieving this info? The function is already half out-dated. It first checks checkip.dyndns.org which still works, but has a "fail safe" and also checks whatismyip.com, which now fails (its close... it returns your ip with </h1> tagged to the end). But we can see that it relies on a) the website being available and the website not changing. This isn't a good long-term solution. - LD Edited March 4, 2007 by LondonNDIB Link to comment Share on other sites More sharing options...
LondonNDIB Posted March 4, 2007 Share Posted March 4, 2007 But in an effort to make it a little more long-term... here is a replacement for the _GetIP.au3 UDF which fixes the problem with the 2nd check and adds two more checks just in case. They are a little slower, but are only checked if the first 2 fail. expandcollapse popup;=============================================================================== ; ; Function Name: _GetIP() ; Description: Get public IP address of a network/computer. ; Parameter(s): None ; Requirement(s): Internet access. ; Return Value(s): On Success - Returns the public IP Address ; On Failure - -1 and sets @ERROR = 1 ; Author(s): Larry/Ezzetabi & Jarvis Stubblefield ; ;=============================================================================== Func _GetIP() Local $ip, $t_ip If InetGet("http://checkip.dyndns.org/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, "Current IP Address:") + 19) $ip = StringLeft($ip, StringInStr($ip, "<") - 1) $t_ip = StringSplit($ip, '.') If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then Return $ip EndIf EndIf If InetGet("http://www.whatismyip.com/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, "<TITLE>WhatIsMyIP.com - ") + 23) $ip = StringLeft($ip, StringInStr($ip, "<") - 1) $ip = StringStripWS($ip, 8) $t_ip = StringSplit($ip, '.') If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then Return $ip EndIf EndIf If InetGet("http://www.ip-adress.com/", @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, "My IP Address: ") + 14) $ip = StringLeft($ip, StringInStr($ip, @TAB) - 1) $ip = StringStripWS($ip, 8) $t_ip = StringSplit($ip, '.') If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then Return $ip EndIf EndIf If InetGet("http://whatismyipaddress.com/?rnd1=" & Random(1, 65536) & "&rnd2=" & Random(1, 65536), @TempDir & "\~ip.tmp") Then $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp")) FileDelete(@TempDir & "\~ip.tmp") $ip = StringTrimLeft($ip, StringInStr($ip, "Your IP address is ") + 18) $ip = StringLeft($ip, StringInStr($ip, "<") - 1) $ip = StringStripWS($ip, 8) $t_ip = StringSplit($ip, '.') If $t_ip[0] = 4 And StringIsDigit($t_ip[1]) And StringIsDigit($t_ip[2]) And StringIsDigit($t_ip[3]) And StringIsDigit($t_ip[4]) Then Return $ip EndIf EndIf SetError(1) Return -1 EndFunc ;==>_GetIP 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