AutoHotkey Community

It is currently May 27th, 2012, 10:00 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
PostPosted: March 5th, 2008, 5:54 pm 
Offline

Joined: April 17th, 2007, 1:37 pm
Posts: 761
Location: Florida
This utility will allow non-technical users (and lazy advanced users) some easy access to common IP-related tasks via a small GUI.
Image

Thanks to SKAN for helping me with my issue of runwait not passing all my parameters. Thanks to silveredge78 for giving me the idea.

Please note, this is geared towards simplicity and that there is a much less basic IP tool by aCkRiTe here .
External IP address functionality is gathered via WhatIsMyIP.com.

Update 11/10/11:
Fixed external IP functionality (automation URL for what is my IP changed)
Added PC name to 'info' msgbox.
Minor reformat of 'info' msgbox for better readability.

Code:
#SingleInstance, Force
#NoEnv

TempFile=%A_Temp%\ip_temp.txt

Gui, Add, Groupbox, w100 h100,IP Address:
Gui, Add, Text, vIPList x20 yp+15 r4 w85
Gui, Add, Button, gGetIP w50, Refresh
Gui, Add, Button, gIPInfo w30 yp x+2, Info

Gui, Add, Button, gReleaseIP +Section y10, Release IP
Gui, Add, Button, gRenewIP y+0 wp xs, Renew IP
Gui, Add, Button, gFlushDNS y+0 wp xs, Flush DNS
Gui, Add, Button, gGetExternalIP y+0 wp xs, External IP

Gui, Show, ,IP Helper
GoSub, GetIP
Return

RenewIP:
SplashTextOn, , 20,Working, Renewing IP
RunWait %comspec% /c "ipconfig /renew > %TempFile%",,Hide
SplashTextOff
GoSub, GetIP
GoSub, GetDetails
Return

ReleaseIP:
SplashTextOn, , 20,Working, Releasing IP
RunWait %comspec% /c "ipconfig /release > %TempFile%",,Hide
SplashTextOff
GoSub, GetIP
GoSub, GetDetails
Return

FlushDNS:
SplashTextOn, , 20,Working, Flushing DNS
RunWait %comspec% /c "ipconfig /flushdns > %TempFile%",,Hide
SplashTextOff
GoSub, GetDetails
Return

GetExternalIP:
SplashTextOn, , 20,Working, Getting External IP
URLDownloadToFile, http://automation.whatismyip.com/n09230945.asp, %TempFile%
SplashTextOff
FileRead, detail, %A_Temp%\ip_temp.txt
If (StrLen(detail) > 15) ;Yeah, I still need to learn RegEx.
{
   FileDelete, %TempFile%
   FileAppend, ERROR, %TempFile%
}
GoSub, GetDetails
Return

IPInfo:
SplashTextOn, , 20,Working, Getting IP Info
RunWait %comspec% /c "ipconfig.exe > %TempFile%",,Hide
SplashTextOff
GoSub, GetDetails
Return

GetIP:
SplashTextOn, , 20,Working, Getting IP List
IPList=
(
%A_IPAddress1%
%A_IPAddress2%
%A_IPAddress3%
%A_IPAddress4%
)
GuiControl, , IPList,%IPList%
SplashTextOff
Return

GetDetails:
FileRead, detail, %A_Temp%\ip_temp.txt
FileDelete, %A_Temp%\ip_temp.txt
StringReplace, detail, detail, `r`n`r`n,`r`n, all
EnvGet PCName, COMPUTERNAME
detail:= "IP details for " . PCName . ":`r`n" . detail
Msgbox, ,Details, %detail%
Return

GuiClose:
ExitApp

_________________
[Join IRC!]
Image


Last edited by Rhys on November 10th, 2011, 2:16 pm, edited 2 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 16th, 2008, 2:25 am 
Offline

Joined: July 16th, 2008, 2:22 am
Posts: 3
Location: Argentina
Hi, simply for offer my thanks for you great script. Is very useful!

Question, is possible add code for send IP data to clipboard?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 16th, 2008, 3:55 am 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
Since this is bumped up I guess i will say thanks as well.
even though i pm'd you awhile ago asking if i could use it in my "commando" script.

soooo....thanks again

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 16th, 2008, 1:05 pm 
Offline

Joined: April 17th, 2007, 1:37 pm
Posts: 761
Location: Florida
@Altober - I'm happy you found it useful - If you'd like the IP info added to the clipboard, add the red line below into the 'GetDetails' sub:
Code:
GetDetails:
FileRead, detail, %A_Temp%\ip_temp.txt
FileDelete, %A_Temp%\ip_temp.txt
StringReplace, detail, detail, `r`n, , all
Clipboard:=detail ;This will put the data into the clipboard
Msgbox, ,Details, %detail%
Return
@tidbit - Thanks!

_________________
[Join IRC!]
Image


Last edited by Rhys on September 24th, 2008, 1:53 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 16th, 2008, 10:47 pm 
Offline

Joined: July 16th, 2008, 2:22 am
Posts: 3
Location: Argentina
Rhys wrote:
@Altober - I'm happy you found it useful - If you'd like the IP info added to the clipboard, add the red line below into the 'GetDetails' sub:
Code:
GetDetails:
FileRead, detail, %A_Temp%\ip_temp.txt
FileDelete, %A_Temp%\ip_temp.txt
StringReplace, detail, detail, `r`n, , all
Clipboard:=detail ;This will put the data into the clipboard
Msgbox, ,Details, %detail%
Return


Many Thanks, Rhys.

Finally, after I learned a little about AutoHotkey, I added a button to copy all the data to the clipboard, and another button that causes appears radio buttons by each IP, so that the user can copy each one in individual way (with balloon TrayTip notice).
It, is ONLY for private use, by no means I will divulge your script modified.

Thanks, again.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 17th, 2008, 4:29 am 
Offline

Joined: June 26th, 2006, 6:14 pm
Posts: 1379
Location: USA
Altober wrote:
It, is ONLY for private use, by no means I will divulge your script modified.

ahhh...just put the following at the beginning...

Code:
; origional code by Rhys on ahk forum
; see the following post:
; http://www.autohotkey.com/forum/viewtopic.php?t=29332
; modified by Altober


if someone didn't want you to use their codez, they shouldn't post it on the forum. that is the wonderful thing about open source. you are normally allowed to modify and use as you wish....however, it is only respectful to provide link to the origional code as well as notify the author.

_________________
Image
ʞɔпɟ əɥʇ ʇɐɥʍ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 17th, 2008, 7:00 am 
Offline

Joined: July 16th, 2008, 2:22 am
Posts: 3
Location: Argentina
ahklerner wrote:
Code:
; origional code by Rhys on ahk forum
; see the following post:
; http://www.autohotkey.com/forum/viewtopic.php?t=29332
; modified by Altober

if someone didn't want you to use their codez, they shouldn't post it on the forum. that is the wonderful thing about open source. you are normally allowed to modify and use as you wish....however, it is only respectful to provide link to the origional code as well as notify the author.


Of course, is not my idea to steal absolutely nothing.
I have a lot of respect by the people that works, and decides to share its work with the others.

I did not publish my modifications because not yet I have finished it.

At any rate, already had placed the name of the author (Rhys) in the first line of the code. : D

Thanks.


Report this post
Top
 Profile  
Reply with quote  
PostPosted: September 18th, 2008, 8:47 pm 
How do I turn this code into an exe file?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: September 23rd, 2008, 11:46 pm 
Offline

Joined: April 17th, 2007, 1:37 pm
Posts: 761
Location: Florida
You can read TFM, or download a compiled version from here.

Edit: dead link, removed.

_________________
[Join IRC!]
Image


Last edited by Rhys on August 2nd, 2009, 2:01 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 24th, 2008, 12:05 am 
Offline

Joined: December 6th, 2007, 6:24 pm
Posts: 54
:shock:

Great script, :roll: how did you know I was lazy ?

Thanks for Sharing !


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Thank you
PostPosted: March 30th, 2009, 3:09 pm 
Just wanted to leave you a thank you note. I used the get external ip code from your script to kludge together a auto re-login script for OpenVPN. It checks the external IP address every 30 minutes and if it's not that of the vpn then restarts and relogs-in.

-Dd


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 22nd, 2010, 10:04 pm 
Offline

Joined: January 22nd, 2010, 9:23 pm
Posts: 1
This is a great script. Thank you so much for sharing it and tweaking it.

What would be the code for also displaying the computer name, and where would it be inserted into the script? Thank you.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 10th, 2011, 2:13 pm 
Offline

Joined: April 17th, 2007, 1:37 pm
Posts: 761
Location: Florida
@jeffaxelrod, if you haven't given up on me, I have updated the original script to show the PC name when you click the 'info' button. Relevant code is highligted in red below.

Code:
#SingleInstance, Force
#NoEnv

TempFile=%A_Temp%\ip_temp.txt

Gui, Add, Groupbox, w100 h100,IP Address:
Gui, Add, Text, vIPList x20 yp+15 r4 w85
Gui, Add, Button, gGetIP w50, Refresh
Gui, Add, Button, gIPInfo w30 yp x+2, Info

Gui, Add, Button, gReleaseIP +Section y10, Release IP
Gui, Add, Button, gRenewIP y+0 wp xs, Renew IP
Gui, Add, Button, gFlushDNS y+0 wp xs, Flush DNS
Gui, Add, Button, gGetExternalIP y+0 wp xs, External IP

Gui, Show, ,IP Helper
GoSub, GetIP
Return

RenewIP:
SplashTextOn, , 20,Working, Renewing IP
RunWait %comspec% /c "ipconfig /renew > %TempFile%",,Hide
SplashTextOff
GoSub, GetIP
GoSub, GetDetails
Return

ReleaseIP:
SplashTextOn, , 20,Working, Releasing IP
RunWait %comspec% /c "ipconfig /release > %TempFile%",,Hide
SplashTextOff
GoSub, GetIP
GoSub, GetDetails
Return

FlushDNS:
SplashTextOn, , 20,Working, Flushing DNS
RunWait %comspec% /c "ipconfig /flushdns > %TempFile%",,Hide
SplashTextOff
GoSub, GetDetails
Return

GetExternalIP:
SplashTextOn, , 20,Working, Getting External IP
URLDownloadToFile, http://automation.whatismyip.com/n09230945.asp, %TempFile%
SplashTextOff
FileRead, detail, %A_Temp%\ip_temp.txt
If (StrLen(detail) > 15) ;Yeah, I still need to learn RegEx.
{
   FileDelete, %TempFile%
   FileAppend, ERROR, %TempFile%
}
GoSub, GetDetails
Return

IPInfo:
SplashTextOn, , 20,Working, Getting IP Info
RunWait %comspec% /c "ipconfig.exe > %TempFile%",,Hide
SplashTextOff
GoSub, GetDetails
Return

GetIP:
SplashTextOn, , 20,Working, Getting IP List
IPList=
(
%A_IPAddress1%
%A_IPAddress2%
%A_IPAddress3%
%A_IPAddress4%
)
GuiControl, , IPList,%IPList%
SplashTextOff
Return

GetDetails:
FileRead, detail, %A_Temp%\ip_temp.txt
FileDelete, %A_Temp%\ip_temp.txt
StringReplace, detail, detail, `r`n`r`n,`r`n, all
EnvGet PCName, COMPUTERNAME
detail:= "IP details for " . PCName . ":`r`n" . detail

Msgbox, ,Details, %detail%
Return

GuiClose:
ExitApp

_________________
[Join IRC!]
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 18th, 2011, 4:31 am 
Offline

Joined: February 9th, 2006, 10:22 pm
Posts: 37
I just want to grab the ip and computer name.
The only problem is that I am getting 4 message box like prompts. The first one is perfect but then the next prompts are only giving labels.
I think it has to do with the 'r 'n creating new lines?? Maybe??
I'm not sure what the all stands for in line
StringReplace, detail, detail, `r`n`r`n,`r`n, all

Code:
#SingleInstance, Force
#NoEnv

F2::

TempFile=%A_Temp%\ip_temp.txt
GoSub, GetExternalIP

GetExternalIP:
URLDownloadToFile, http://automation.whatismyip.com/n09230945.asp, %TempFile%
FileRead, detail, %A_Temp%\ip_temp.txt
GoSub, GetDetails

GetDetails:
FileRead, detail, %A_Temp%\ip_temp.txt
FileDelete, %A_Temp%\ip_temp.txt
StringReplace, detail, detail, `r`n`r`n,`r`n, all
EnvGet PCName, COMPUTERNAME
detail:= "IP details for " . PCName . ":`r`n" . detail
Msgbox, ,Details, %detail%


Return


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], sks, specter333 and 22 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group