NELyon Posted January 8, 2008 Share Posted January 8, 2008 (edited) It's official. I'm back using Autoit! After a... 6 Month leave from programming. I stuck around the forums anyway So anyway, this retrieves your external IP address using cleaner (and less) code then _GetIP() It also has a param, $file, in which you can save your IP to an external file instead of the function returning it. It is my first working script in over 6 months, so be gentle! Remember, I may be reinventing the wheel, but my wheel, IMO, gets better traction on those bumpy roads Func _RetrieveIP($file = "") local $ip, $tempfile = @TempDir & "\ip.txt" If $file = "" Then InetGet("http://whatismyip.com/automation/n09230945.asp", $tempfile) If @Error Then return 0 Else $ip = FileRead($tempfile) return $ip EndIf ElseIf $file <> "" Then InetGet("http://whatismyip.com/automation/n09230945.asp", $tempfile) If @error Then return 0 Else FileMove($tempfile, $file) EndIf EndIf FileDelete($tempfile) EndFuncoÝ÷ ØX¥xLZ^jëh×6_RetrieveIP("C:\MyIP.txt") Func _RetrieveIP($file = "") local $ip, $tempfile = @TempDir & "\ip.txt" If $file = "" Then InetGet("http://whatismyip.com/automation/n09230945.asp", $tempfile) If @Error Then return 0 Else $ip = FileRead($tempfile) return $ip EndIf ElseIf $file <> "" Then InetGet("http://whatismyip.com/automation/n09230945.asp", $tempfile) If @error Then return 0 Else FileMove($tempfile, $file) EndIf FileDelete($tempfile) EndFunc Welcome back Autoit! Edited January 8, 2008 by Senton-Bomb Link to comment Share on other sites More sharing options...
Dhilip89 Posted January 8, 2008 Share Posted January 8, 2008 Welcome back!I think this is shorter: http://www.whatismyip.org/ [u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote] Link to comment Share on other sites More sharing options...
NELyon Posted January 8, 2008 Author Share Posted January 8, 2008 (edited) OMG somebody save me from the Autoit Tags. I can't edit my post. That random code sitting at the bottom of my post won't go away, and if i try to remove it, my code gets screwed. EDIT: Forgot to mention: This was developed in Linux with Wine, so it's 100% Wine Compatible @Dhillip This is to return your IP dynamically for use in code, such as for testing a web server. Edited January 8, 2008 by Senton-Bomb Link to comment Share on other sites More sharing options...
Michel Claveau Posted January 8, 2008 Share Posted January 8, 2008 (edited) Hi! You want short code? Try this:$ip=StringMid(InetGet("http://alexissoft.free.fr/ip.php", "ip_temp.txt")&FileRead("ip_temp.txt"),2) Edited January 8, 2008 by Michel Claveau Link to comment Share on other sites More sharing options...
GaryFrost Posted January 9, 2008 Share Posted January 9, 2008 Also look _GetIP in the help file SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
NELyon Posted January 9, 2008 Author Share Posted January 9, 2008 Also look _GetIP in the help fileThe whole point of this code was to retrieve the IP in less code than that very function Thanks anyway! Link to comment Share on other sites More sharing options...
GaryFrost Posted January 9, 2008 Share Posted January 9, 2008 The whole point of this code was to retrieve the IP in less code than that very function Thanks anyway!That's what happens when i skim the thread...lol SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Richard Robertson Posted January 9, 2008 Share Posted January 9, 2008 At least you tried. 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