Jump to content

_GetIP


cyanidemonkey
 Share

Recommended Posts

Hi guys,

This is proberly out of date, but when I tried the _GetIP() I got displayed HTML

I found changing:

$ip = StringTrimLeft($ip, StringInStr($ip, "<TITLE>Your ip is ") + 17)

to:

$ip = StringTrimLeft($ip, StringInStr($ip, "<TITLE>Your ip is ") + 139)

fixed it. I guess www.whatismyip.com have changed the HTML a little?

I then modified the way it pulled the IP from the text string...

Func _GetIP()
    Local $ip
    If InetGet("http://checkip.dyndns.org/", @TempDir & "\~ip.tmp") Then
        $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
        FileDelete(@TempDir & "\~ip.tmp")
        $ip = StringReplace($ip, "<html><head><title>Current IP Check</title></head><body>Current IP Address: ", "")
        $ip = StringReplace($ip, "<!-- proxy --></body></html>", "")
        Return $ip
    Else
        SetError(1)
        Return
    EndIf
EndFunc

Hope this is useful, if there is a new way of getting you WAN IP instead of _GetIP, sorry 'bout this post :P

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

I think XML does a better job than HTML for finding specific information

Func GetIP()
    Local $xmldoc = ObjCreate('Microsoft.XMLDOM'), $ip
    If Not IsObj($xmldoc) Then Return -1
    $xmldoc.async = False
    $xmldoc.load ('http://xml.showmyip.com/')
    For $x In $xmldoc.documentElement.childNodes
        If $x.NodeName = "ip" Then
            $ip = $x.text
            ExitLoop
        EndIf
    Next
    $xmldoc = 0
    Return $ip
EndFunc

Writing AutoIt scripts since

_DateAdd("d", -2, _NowCalcDate())
Link to comment
Share on other sites

Hey the xml version looks cool MSLx Fanboy,

when I tried to run it I got an unknown function error for ObjCreate.

Where can I find this?

Cheers.

My AutoIt Scripts.- AutoHost and Password Enabler for Delta Force 2 Demo.| Caffine for Winamp 2.9x and WRS 2.0 | mp3 directory cleaner | CRAP DJ | A:B:J Radio Automation Software | FFMPEG batch conversion automator

Link to comment
Share on other sites

  • Moderators

Do you have the beta version of AutoIt? The address is in my signature for it.

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...