Jump to content

Recommended Posts

Posted

Func ResolveIP()
    InetGet("http://whatismyip.com", "incoming.dat", 1, 1)
    $contents = ""

    While @InetGetActive
        Sleep(50)
    Wend
    
   $file = FileOpen ("incoming.dat", 0)

   While 1
      $contents = $contents & FileRead ($file, 1000)
      If @error = -1 Then ExitLoop
    Wend
      
   $invalid = 0
   While StringLeft ($contents, 4) <> "lbIP"
      $contents = StringTrimLeft ($contents, 1)
      $invalid = $invalid + 1
      If $invalid = 5000 Then
         $invalid = 0
         MsgBox (0,"","Error retrieving IP address")
         ExitLoop
      EndIf
   Wend

   If $invalid <> 0 Then
  
   $contents = StringTrimLeft ($contents, 21)
   $letters = ""
  
   While StringLeft ($contents, 5) <> "</h1>"
      $letters = $letters & StringLeft ($contents, 1)
      $contents = StringTrimLeft ($contents, 1)
  Wend
  
   Return $letters
   EndIf
   
EndFunc

all you need to do is something like the following:

$ipaddr = ResolveIP()

and you're done!

Matt :(

Posted (edited)

This is works. But your external IP should be in the one of @IpAddressX macro. So you can simplify function.

<{POST_SNAPBACK}>

External isnt in an macro AFAIK. There is _GetIP (a standard UDF) though.

btw lot of your code can be simplified. ill post it after i edited it.

[edit]

okey this is what is remaining of your code. well nothing really ...

still a nice script :(

its even better to use COM + regexp though but thats a bit complicated :(

Func ResolveIP()
    InetGet("http://whatismyip.com", "incoming.dat", 1)
    If @error Then Return 0
    $contents = FileRead("incoming.dat", FileGetSize('incoming.dat'))
    FileDelete('incoming.dat')
    $contents = StringTrimLeft($contents, StringInStr($contents, "lbIP") + 20)
    $contents = StringLeft($contents, StringInStr($contents, '<') - 1)
    Return $contents
EndFunc;==> ResolveIP()
Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Posted

You can actually make your script a bit faster by using www.whatismyip.org instead, because that site doesn't require any trimming.

Also, a better way of reading the ENTIRE file is like this:

$content=FileRead ($file, filegetsize($file))

It will read the exact number of bytes that the file's size is.

Posted (edited)

This is works. But your external IP should be in the one of @IpAddressX macro. So you can simplify function.

<{POST_SNAPBACK}>

;use @IpAddressX Macro get Ip Address :)
;Thanx w0uter
MsgBox(64,"Your Ip Address Is",@IpAddress1)

:(:(

Also ThanX logikal16, U give me a fresh idea ! :

Edited by sanbin
Posted (edited)

Good ideas, guys... here's the updated script:

Func ResolveIP()
    InetGet("http://www.whatismyip.org", "incoming.dat", 1, 1)
    
    While @InetGetActive
        Sleep(50)
    WEnd
    
    $file = FileOpen ("incoming.dat", 0)
    $contents = FileReadLine($file)
    $wAddress = $contents
    MsgBox(0,"",$wAddress)
    Return $wAddress
EndFunc

It's short enough so that it won't take too long to run, but long enough so that other newbies can see what's going on :(

Edited by logikal16
Posted

Just so you know... there is a _GetIP() UDF included with AutoIt... It checks 2 sites to be sure that the page hasnt been cached in the proxy server.

Look in the help file :).

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Posted

yawn why doesnt anyone read my post.

It checks 2 sites to be sure that the page hasnt been cached in the proxy server.

<{POST_SNAPBACK}>

wrong. :)

it uses the Random to prevent proxy/ISP cache'ing.

the 2 sites are just for backup if one fails.

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

  • 3 years later...
Posted

This change will resolver problem with router and firewall mask!!!

Func ResolveIP()

InetGet("http://www.whatismyip.com/automation/n09230945.asp", "incoming.dat", 1, 1)

While @InetGetActive

Sleep(50)

WEnd

$file = FileOpen ("incoming.dat", 0)

$contents = FileReadLine($file)

MsgBox(0, "IP Address", "Your IP Address is: " & $contents)

$wAddress = $contents

MsgBox(0,"",$wAddress)

Return $wAddress

EndFunc

Posted (edited)

#include <INet.au3>

func _GetExternalIP()
;Spyrorocks' Simple _GetExternalIP() function. Doesn't get much easier than this.
return _INetGetSource ("http://www.whatismyip.org");
endfunc

Oh yeah.

Edited by spyrorocks
Posted

#include <INet.au3>

func _GetExternalIP()
;Spyrorocks' Simple _GetExternalIP() function. Doesn't get much easier than this.
return _INetGetSource ("http://www.whatismyip.org");
endfunc

Oh yeah.

You just owned everyone who posted in this thread :P

But yours relies on external UDF's. Booyah.

Posted

#include <INet.au3>

func _GetExternalIP()
;Spyrorocks' Simple _GetExternalIP() function. Doesn't get much easier than this.
return _INetGetSource ("http://www.whatismyip.org");
endfunc

Oh yeah.

Damn, when i read the sources above i wanted th exactly post the same function :-) but you were faster then me.

*regards* J.

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
  • 1 year later...
Posted

hi,

you don't need to get to a special site like http://www.whatismyip.org

i used the following:

Func ResolveIP()    InetGet("incoming.dat", 1, 1)          
While @InetGetActive         
Sleep(50)     
WEnd          
$file = FileOpen ("incoming.dat", 0)     
$contents = FileReadLine($file)     
$wAddress = $contents       
Return $wAddress EndFunc

You should open 1.

Go now and learn more...

♡♡♡

.

eMyvnE

  • Developers
Posted

hi,

you don't need to get to a special site like http://www.whatismyip.org

i used the following:

Func ResolveIP()    InetGet("incoming.dat", 1, 1)          
While @InetGetActive         
Sleep(50)     
WEnd          
$file = FileOpen ("incoming.dat", 0)     
$contents = FileReadLine($file)     
$wAddress = $contents       
Return $wAddress EndFunc

You are sure this works?

Je weet het zeker dat dit werkt?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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
  • Recently Browsing   0 members

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