Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Get current external IP Address


  • Please log in to reply
21 replies to this topic
Zane
  • Members
  • 12 posts
  • Last active: Apr 20 2010 08:19 AM
  • Joined: 31 Dec 2005
Hi, first of all let me say a big congrats for AutoHotkey: for extrabusy people like I'm, it's the best thing after....the pc itself 8)

I'd like to build up a hotstring: when I write /ip it should be replaced with my actual Internet IP ("Internet IP", since I've 5 NIC installed).

Any idea?

Thanks!
Gianluigi "Zane" Zanettini - MegaLab.it

freakkk
  • Members
  • 182 posts
  • Last active: Dec 16 2014 06:23 PM
  • Joined: 29 Jul 2005
:*:/ip::
Send, %A_IPAddress1%
return
From Variables page:

A_IPAddress1 through 4 : The IP addresses of the first 4 network adapters in the computer.

It would take some more work to retreive #5-- but anythings possible :D

corrupt
  • Members
  • 2558 posts
  • Last active: Nov 01 2014 03:23 PM
  • Joined: 29 Dec 2004
Hi and welcome :)

("Internet IP", since I've 5 NIC installed).

Ok... I'll bite. Why would you need to have 5 NIC installed in a single machine? Is the machine acting as a router for 4 different subnets?...and with 5 installed... why wouldn't you already know which card to query the IP address from based on the card that you picked to connect to the internet?

TheLeO
  • Members
  • 264 posts
  • Last active: Jan 02 2012 01:51 AM
  • Joined: 11 Jun 2005
bah,, dudes..
%A_IPAddress1% Retrieves the internal ip...
for example my rooter ip is 192.168.0.2 > my moms pc is. 192......3
.. however my current (dinamic) external ip is 84.9.148.149 .....
I usually use
www.whatismyip.com
to find my one out,,.. I dont know whether there is an ahk solution. :?
::
I Have Spoken
::

Zane
  • Members
  • 12 posts
  • Last active: Apr 20 2010 08:19 AM
  • Joined: 31 Dec 2005
First of al thankyou for your valuable help...and happy new year :D

"A_IPAddress1 through 4" always retrives local addresses: any other idea?
Gianluigi "Zane" Zanettini - MegaLab.it

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
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

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%


TheLeo & Zane : Hope this works for you both :-)
kWo4Lk1.png

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
Oops! I was wrong abouth the Bandwidth... It is 1544 bytes

Sorry!
kWo4Lk1.png

Greg
  • Members
  • 245 posts
  • Last active: Jun 02 2006 05:39 PM
  • Joined: 22 Dec 2005
As a hotkey replace:

:*:/ip::
MyExternalIP=0.0.0.0 
TmpFile=%WinDir%\TEMP\IPAddress.TMP 
UrlDownloadToFile,http://www.whatismyip.org/,%TmpFile% 
FileReadLine,MyExternalIP,%TmpFile%,1 
FileDelete,%TmpFile% 
Send, %MyExternalIP%

*goyyah's code untested*

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005
:*:/ip:: 
MyExternalIP=0.0.0.0 
TmpFile=%WinDir%\TEMP\IPAddress.TMP 
UrlDownloadToFile,http://www.whatismyip.org/,%TmpFile% 
FileReadLine,MyExternalIP,%TmpFile%,1 
FileDelete,%TmpFile% 
Send, %MyExternalIP%

Hotstrings and Auto-replace does not work in Windows 98 (and thats the OS I have). So I put the code that I could test...

Zane has to tell whether Greg`s modification Works
kWo4Lk1.png

Zane
  • Members
  • 12 posts
  • Last active: Apr 20 2010 08:19 AM
  • Joined: 31 Dec 2005
:C*:/ip::
MyExternalIP=0.0.0.0
TmpFile=%WinDir%\TEMP\IPAddress.TMP
UrlDownloadToFile,http://www.whatismyip.org/,%TmpFile%
FileReadLine,MyExternalIP,%TmpFile%,1
FileDelete,%TmpFile%
Send, %MyExternalIP%

Thank you so much guys!! It works like a charm!

It is somehow "slow" but it's more than acceptable!

Thanks again!
Gianluigi "Zane" Zanettini - MegaLab.it

ge0
  • Members
  • 4 posts
  • Last active: Jul 07 2008 03:07 PM
  • Joined: 24 Dec 2007
haven't any way to retrieve it by using the gateway from each adapter?
For sure it has another more consistent solution, but that's good for now.
BTW, how to detect if it's connected to internet?

ge0
  • Members
  • 4 posts
  • Last active: Jul 07 2008 03:07 PM
  • Joined: 24 Dec 2007
Oh i think i found a solution to my problem, i'm using Hstart to get console output into a file, and so i can read what ping returns:
;;;;;;;;;;;start of detection
tmpping=c:\tmpping.txt
loop
{
	runwait,hstart /NOCONSOLE /WAIT "%comspec% /c ping www.google.com.br > %tmpping%"
	FileGetSize,fsize,%tmpping%
	if fsize<250
	{
		sleep 60000	;wait 1 minute, because its offline
		continue
	}
	filereadline,connected,%tmpping%,10
	stringsplit,pckt,connected,`,
	plen:=strlen(pckt1)
	plen--
	packet:=substr(pckt1,plen)
	if packet>0
		break
}
filedelete %tmpping%
;;;;;;;;;;;;;;end of detection
ExternalIP=0.0.0.0
TmpFile=%A_WinDir%\TEMP\IPAddress.TMP
UrlDownloadToFile,http://www.whatismyip.org/,%TmpFile%
FileReadLine,ExternalIP,%TmpFile%,1
FileDelete,%TmpFile%
msgbox % externalip

exitapp
thanks SKAN for the external ip code

SKAN
  • Administrators
  • 9115 posts
  • Last active:
  • Joined: 26 Dec 2005

haven't any way to retrieve it by using the gateway from each adapter?


I rememeber that Titan posted something like "retrieving IP address directly from router". Unable to track it down. :(

thanks SKAN for the external ip code


That was my first contribution in Ask-for-Help. Since then, many variants using different providers have been posted. Please search for them.

Getting users IP adress/Hosting a connection posted by Conquer
:)
kWo4Lk1.png

ChemistryX
  • Guests
  • Last active:
  • Joined: --
Start iMacros with AHK, see http://del.icio.us/imacros

What is my current IP address? What was my last IP address?
"Displays the current IP address and saves it to a text file."

127.nULL
  • Guests
  • Last active:
  • Joined: --
Is there way to get yougr Public IP address while connected, via any windows interface?, IGNORING the router barrier?