AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Global IP ?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
jaco0646
Guest





PostPosted: Mon Mar 13, 2006 2:48 am    Post subject: Global IP ? Reply with quote

There's probably an easy way to do this that I'm missing: how can I get my global IP address? %A_IPAddress1% only returns the local. Is there a command line program that retrieves it perhaps? IPconfig.exe only returns the local as well.

I could use 'URLDownloadToFile' to check a webpage for it, but that's a last resort.
Back to top
ggirf14



Joined: 01 Nov 2005
Posts: 96
Location: Ottawa

PostPosted: Mon Mar 13, 2006 3:19 am    Post subject: Reply with quote

What is global IP address???
Are you looking for your MAC address?, Your "public" network card address?

The following will get you at the root of C a file called "output" with the info about all of your network cards.

Run, cmd.exe
Sleep, 100
Send, ipconfig /all > c:\outputfile.txt {enter}
Sleep, 3000
Send, exit {enter}
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Mon Mar 13, 2006 3:55 am    Post subject: Reply with quote

Dear jaco0646, Smile

The following lines of AHK code will retrieve the "External IP Address"

1) You should be connected to the Internet else it will show 0.0.0.0
2) It consumes mere 505 bytes of Bandwidth

Code:
MyExternalIP=0.0.0.0
TmpFile=%WinDir%\TEMP\IPAddress.TMP
UrlDownloadToFile,http://www.whatismyip.org/,%TmpFile%
FileReadLine,MyExternalIP,%TmpFile%,1
FileDelete,%TmpFile%
Msgbox,64,External IP Address,%MyExternalIP%


I hope this of some help!

Regards, Smile
_________________
Back to top
View user's profile Send private message
jaco0646
Guest





PostPosted: Mon Mar 13, 2006 3:55 am    Post subject: answer Reply with quote

I found my answer here. Apparently my last resort is my only resort.
Back to top
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Mon Mar 13, 2006 4:11 am    Post subject: Reply with quote

But jaco0646, did you try my code?!
_________________
Back to top
View user's profile Send private message
jaco0646
Guest





PostPosted: Mon Mar 13, 2006 4:13 am    Post subject: ... too slow Reply with quote

Goyyah, you beat me to it! Laughing 'URLDownloadToFile' is indeed the only answer I could find. Thanks for the web link; your code works perfectly!
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Mon Mar 13, 2006 9:15 am    Post subject: Reply with quote

I found a similar script (at a time I forget to write down where I get these tips) in this forum and kept it as I find it convenient.
It is basically the same as Goyyah's one, but since it uses a different address, I give it here (Internet resources are never permanent...):
Code:
;----------------------------------------------------------------
;--- Ctrl+Alt+I: show IP address
^!i::
   ipFile = %TEMP%\IP
   ; Use Netikus service, simple and straight to the point...
   URLDownloadToFile http://www.netikus.net/show_ip.html, %ipFile%
   If ErrorLevel = 1
   {
      MsgBox 16, IP Address, Your public IP address could not be detected.
   }
   Else
   {
      FileReadLine ip, %ipFile%, 1
      MsgBox 64, IP Address, Your public IP address is: %ip%`n`nYour private IP address is: %A_IPAddress1%
   }
   FileDelete %ipFile%
Return

_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Mon Mar 13, 2006 5:13 pm    Post subject: Reply with quote

Dear PhiLho, Smile

PhiLho wrote:
Internet resources are never permanent...


Very true ... Thanks for the URL!

The original post is Get current external IP Address
I googled and viewed more than 50 links before I could post it there!

Regards, Smile
_________________
Back to top
View user's profile Send private message
skygt



Joined: 15 Mar 2006
Posts: 47
Location: Lille, France

PostPosted: Wed Mar 15, 2006 9:38 pm    Post subject: Reply with quote

instead of ipconfig try:

ipconfig all
or
ipconfigall

it shows more than 1 ip adresse

Hope it helps!

if you have a router you can type a local ip adresse in the browser
and should see somewhere a link showing all your ip adresses
Back to top
View user's profile Send private message MSN Messenger
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Thu Mar 16, 2006 11:46 am    Post subject: Reply with quote

That's ipconfig /all (see second post), and it doesn't show the "global" (public, known by Internet servers) IP address.
I am not sure about your second trick, even less if you run some Web server... Perhaps it works with some routers.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
skygt



Joined: 15 Mar 2006
Posts: 47
Location: Lille, France

PostPosted: Thu Mar 16, 2006 5:39 pm    Post subject: Reply with quote

Oh ok sorry then
At least i tryed helping
And yes some routers can let you look at all your stuff
Like Linksys and D-link
Back to top
View user's profile Send private message MSN Messenger
jaco0646



Joined: 07 Oct 2006
Posts: 664
Location: MN, USA

PostPosted: Sat Oct 28, 2006 4:12 pm    Post subject: bad URL Reply with quote

This URL no longer works for me: http://www.whatismyip.org/ It generates the following error message:

Error: blank User-Agent header is not allowed! Please ask the author of your IP address checking client to specify their client's name in the User-Agent header

I have no idea what the error means; but I thought it might be of interest to Chris as far as how the UrlDownloadToFile command functions and possibly changing it to avoid this. Can AHK specify a "User-Agent header?"

The second URL is still working: http://www.netikus.net/show_ip.html

What was that about Internet resources... ? Laughing Rolling Eyes
_________________
http://autohotkey.net/~jaco0646/
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Sat Oct 28, 2006 4:18 pm    Post subject: Re: bad URL Reply with quote

jaco0646 wrote:
This URL no longer works for me: http://www.whatismyip.org/


Both the URL's work properly for me!
Windows 2000 SP6 Internet Explorer 6

Smile
_________________
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Sat Oct 28, 2006 4:37 pm    Post subject: Re: bad URL Reply with quote

Goyyah wrote:
Both the URL's work properly for me!
Windows 2000 SP6 Internet Explorer 6Smile
IE 6 has a valid user agent, that's why it works...
I doubt UrlDownloadToFile can be changed to give a UA. Using cURL can be an alternative. Or just use a less picky service...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 6264

PostPosted: Sat Oct 28, 2006 4:43 pm    Post subject: Re: bad URL Reply with quote

PhiLho wrote:
IE 6 has a valid user agent, that's why it works...


Thanks! I should not have used the browser to check it! Surprised
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group