Another sample script that uses CMDret...
(watch for wordwrap...)
Code:
; ---------------------------------------------------------------------------------------------
;
; CMDret - Example - IP Tools
;
; 2005 Apps4Apps
; Http://www.Apps4Apps.filetap.com
;
; NO WARRANTY. USE IT AT YOUR OWN RISK.
;
; ---------------------------------------------------------------------------------------------
;
#NoTrayIcon
SetBatchLines, 5ms
Gui, Add, Edit, x6 y7 w420 h300 +HScroll vTbox, Welcome. `n`nPlease view documentation for additional info on use of this script.
Gui, Add, Button, x6 y317 w140 h20 gButton1, Ping Address
Gui, Add, Button, x6 y337 w140 h20 gButton2, Tracert Address ; sample 1,2
Gui, Add, Button, x146 y317 w140 h20 gButton3, IPCONFIG (all)
Gui, Add, Button, x146 y337 w140 h20 gButton4, IPCONFIG (simple)
Gui, Add, Button, x286 y317 w140 h20 gButton5, IPCONFIG Release
Gui, Add, Button, x286 y337 w140 h20 gButton6, IPCONFIG Renew
Gui, Add, Edit, x0 y0 w100 h10 +HScroll -0x10000000 vmyvar , CMD ; Invisible Edit control
Gui, Show, h366 w434, CMDret - Example - IP Tools
menu, tray, Icon
; -----------------------------------------------------------
; Added variables to minimize typing ;)
; RunCMD1 - AHK usage, RunCMD2 - Generic Usage
; tempCMD - temporary variable to store console text in. Added to reduce
; the chance of the Edit control's title changing (CMDret uses
; the control's title to find the control)
; -----------------------------------------------------------
RunCMD1 = CMDret.exe "CMDret - Example - IP Tools"
RunCMD2 = CMDret.exe "CMDret - Example - IP Tools" "CMD" "Edit" "AutoHotkeyGUI"
tempCMD =
lastCMD =
Return
; -----------------------------------------------------------
; Ping Address
; -----------------------------------------------------------
Button1:
; *********************
InputBox, tracethis, Tracert, Address to Ping:,, 200, 120,,,,, %tracethis%
if ErrorLevel = 1
{
}
else if tracethis =
{
}
else
{
GuiControl,, Tbox, %lastCMD% ; clear Edit1
SetTimer, RefTxt, 250
RunWait, CMDret.exe "CMDret - Example - IP Tools" "p=" "ping %tracethis%",,Hide
SetTimer, RefTxt, Off
Gosub, RefTxt
lastCMD=
}
Return
; -----------------------------------------------------------
; Tracert Address
; -----------------------------------------------------------
Button2:
InputBox, tracethis, Tracert, Address to Trace:,, 200, 120,,,,, %tracethis%
if ErrorLevel = 1
{
}
else if tracethis =
{
}
else
{
GuiControl,, Tbox, %lastCMD% ; clear Edit1
SetTimer, RefTxt, 250
RunWait, CMDret.exe "CMDret - Example - IP Tools" "p=" "TRACERT %tracethis%",,Hide
SetTimer, RefTxt, Off
Gosub, RefTxt
lastCMD=
}
Return
; -----------------------------------------------------------
; IPCONFIG /ALL
; -----------------------------------------------------------
Button3:
GuiControl,,Tbox,
RunWait, %RunCMD2% "%COMSPEC%" "/C IPCONFIG /ALL",, Hide
GuiControlGet, tempCMD,,myvar
GuiControl,,Tbox, IPCONFIG Info (all): `r`n`r`n%tempCMD% ; (2)
Return
; -----------------------------------------------------------
; IPCONFIG
; -----------------------------------------------------------
Button4:
GuiControl,,Tbox,
RunWait, %RunCMD2% "%COMSPEC%" "/C IPCONFIG",, Hide
GuiControlGet, tempCMD,,myvar
GuiControl,,Tbox, IPCONFIG INFO (simple): `r`n`r`n%tempCMD% ; (2, 2)
Return
; -----------------------------------------------------------
; IPCONFIG /release
; -----------------------------------------------------------
Button5:
GuiControl,,Tbox,
RunWait, %RunCMD2% "%COMSPEC%" "/C IPCONFIG /release",, Hide
GuiControlGet, tempCMD,,myvar
GuiControl,,Tbox, Results: `r`n`r`n%tempCMD%
Return
; -----------------------------------------------------------
; IPCONFIG /renew
; -----------------------------------------------------------
Button6:
GuiControl,,Tbox,
RunWait, %RunCMD2% "%COMSPEC%" "/C IPCONFIG /renew",, Hide
GuiControlGet, tempCMD,,myvar
GuiControl,,Tbox, Results: `r`n`r`n%tempCMD%
Return
; -----------------------------------------------------------
; Refresh
; -----------------------------------------------------------
RefTxt:
GuiControlGet, tempCMD,,myvar
if tempCMD =
{
}
else
{
if lastCMD <> %tempCMD%
{
StringLen, lastLen, lastCMD
StringTrimLeft, updCMD, tempCMD, %lastLen%
ControlSend, Edit1, {CtrlDown}{END}{CTRLUP}, CMDret - Example - IP Tools
Control, EditPaste, %updCMD%, Edit1, CMDret - Example - IP Tools
ControlSend, Edit1, {CtrlDown}{END}{CTRLUP}, CMDret - Example - IP Tools
lastCMD = %tempCMD%
lastLen=
}
}
Return
; -----------------------------------------------------------
GuiClose:
ExitApp
; -----------------------------------------------------------