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 

IP Address
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
nickromano



Joined: 28 Nov 2007
Posts: 25
Location: USA

PostPosted: Wed Nov 28, 2007 10:02 pm    Post subject: IP Address Reply with quote

I thought this might be useful to someone. It finds the IP address of the computer it is run on.

Code:
UrlDownloadToFile, http://whatismyipaddress.com/, ip.txt
Loop, read, ip.txt
{
  if a_loopreadline contains Your ip address is
  ipaddress = %a_loopreadline%
}
StringTrimLeft, ipaddress, ipaddress, 47
Loop
{
  if ipaddress contains <
    stringtrimright, ipaddress, ipaddress, 1
  else
    break
}
Msgbox, %ipaddress%
Back to top
View user's profile Send private message Visit poster's website AIM Address
freakkk



Joined: 29 Jul 2005
Posts: 122

PostPosted: Wed Nov 28, 2007 10:13 pm    Post subject: Reply with quote

Code:
MsgBox, % A_IPAddress1
Very Happy
_________________
.o0[ corey ]0o.
Back to top
View user's profile Send private message
nickromano



Joined: 28 Nov 2007
Posts: 25
Location: USA

PostPosted: Wed Nov 28, 2007 10:15 pm    Post subject: Reply with quote

haha how did i not know that?
Back to top
View user's profile Send private message Visit poster's website AIM Address
Laszlo



Joined: 14 Feb 2005
Posts: 3941
Location: Pittsburgh

PostPosted: Wed Nov 28, 2007 10:31 pm    Post subject: Reply with quote

These are different things. A_IPAddress1 shows the LAN address, most of the time something like 192.168.1.4, but nickromano's script tells the IP address seen from outside of the LAN, like 24.138.252.79
Back to top
View user's profile Send private message
vapor2



Joined: 11 Sep 2007
Posts: 4

PostPosted: Wed Nov 28, 2007 10:32 pm    Post subject: Reply with quote

nickromano, Your version is useful if you wanted to discover your "Internet" IP address if your host was behind a firewall with NAT.

-V-
_________________
Vapor2
Back to top
View user's profile Send private message
freakkk



Joined: 29 Jul 2005
Posts: 122

PostPosted: Wed Nov 28, 2007 10:38 pm    Post subject: Reply with quote

Laszlo wrote:
These are different things. A_IPAddress1 shows the LAN address, most of the time something like 192.168.1.4, but nickromano's script tells the IP address seen from outside of the LAN, like 24.138.252.79
Ahh yes; I hadn't taken various network setups into consideration Confused
_________________
.o0[ corey ]0o.
Back to top
View user's profile Send private message
maximo3491



Joined: 10 Feb 2007
Posts: 64

PostPosted: Thu Nov 29, 2007 6:32 am    Post subject: Reply with quote

Code:
UrlDownloadToFile, http://checkip.dyndns.org/, %A_Temp%\ip.txt
FileRead, ip, %A_Temp%\ip.txt
RegExMatch(ip, "[\d\.]+", ip)
filedelete, %A_Temp%\ip.txt


This does the same thing but faster without the trimming. The ip is stored within the variable 'ip'.
Back to top
View user's profile Send private message
pinkfloyd232



Joined: 30 Nov 2007
Posts: 2

PostPosted: Fri Nov 30, 2007 4:46 am    Post subject: Reply with quote

neat script. It's basic. but I'll look into this further when completing my false Auto program for runescape. cool Smile
_________________
Current Projects
Finance Manager
FTP Client
Instant Messenger
File Sniffer
Project Organizer
Back to top
View user's profile Send private message
pinkfloyd232



Joined: 30 Nov 2007
Posts: 2

PostPosted: Fri Nov 30, 2007 5:13 am    Post subject: Reply with quote

Try using IfNotExist before UrlDownload, and IfExist after UrlDownload. It'll also speed up the script. Assuming you don't want to delete the text file.
_________________
Current Projects
Finance Manager
FTP Client
Instant Messenger
File Sniffer
Project Organizer
Back to top
View user's profile Send private message
Wibumba (not logged in)
Guest





PostPosted: Fri Nov 30, 2007 9:44 pm    Post subject: Reply with quote

Code:
UrlDownloadToFile, http://www.whatismyip.org/, %A_Temp%\ip.txt
FileRead, ip, %A_Temp%\ip.txt
FileDelete, %A_Temp%\ip.txt


whatismyip.org only displays the address.
Back to top
helfee



Joined: 10 Aug 2007
Posts: 1

PostPosted: Mon Dec 03, 2007 7:57 am    Post subject: Reply with quote

Code:
RunWait, %comspec% /c ipconfig>ip.txt,%temp%,hide
FileRead,ipa,%temp%\ip.txt
FileDelete,%temp%\ip.txt
spot=1
loop
{
pos := RegExMatch(ipa, "((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)",ip,spot)
StringSplit, t, ip,.
if (t1=192 or t1=255)
  {
  spot:=pos+4
  CONTINUE
  }
break
}

MsgBox % ip
Back to top
View user's profile Send private message
Laszlo



Joined: 14 Feb 2005
Posts: 3941
Location: Pittsburgh

PostPosted: Mon Dec 03, 2007 4:45 pm    Post subject: Reply with quote

Don't you expect top get the same as A_IPAddress1..4? In my Vista the MsgBox is empty, though.
Back to top
View user's profile Send private message
DeWild1



Joined: 30 Apr 2006
Posts: 156
Location: Shigle Springs

PostPosted: Fri Dec 07, 2007 4:33 am    Post subject: Reply with quote

if you have access to a web server, make a file "ip.asp"
in the file put this,

Code:
<%

Dim sIPAddress

sIPAddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If sIPAddress="" Then sIPAddress = Request.ServerVariables("REMOTE_ADDR")

Response.Write sIPAddress
%>


The web sites listed here will only let you do it once and may not be reliable.
If you want, you can use mine, http://www.virusSWAT.com/ip.asp
_________________
CPULOCK
virusSWAT
Guaranteed PC
911 PC FIX
Back to top
View user's profile Send private message Visit poster's website
SKAN



Joined: 26 Dec 2005
Posts: 5574

PostPosted: Fri Dec 07, 2007 4:37 am    Post subject: Reply with quote

That is nice! Maybe Titan can consider this for autohotkey.net.

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



Joined: 30 Apr 2006
Posts: 156
Location: Shigle Springs

PostPosted: Fri Dec 07, 2007 5:07 am    Post subject: Reply with quote

Skan wrote:
That is nice! Maybe Titan can consider this for autohotkey.net.

Smile

LOL, I forgot, http://www.autohotkey.com/forum/viewtopic.php?t=19438 , I have never used it but it should work.. Cool


I may be wrong, Chris does not allow PHP and I do not know if asp will work or if it is even allowed.
I am not changing mine, so you're free to use it or do http://zendurl.com/

I only did my own because the first link given, their web page may change, the second one only lets you do it once.
_________________
CPULOCK
virusSWAT
Guaranteed PC
911 PC FIX
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions 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