see DOS commands to see details / all parameters
writes DOS command to a file :
fcdm=%a_scriptdir%\doscommands_small.txt
ifnotexist,%fcdm%
runwait,%comspec% /c help >"%fcdm%",,hide,
and in listbox see all DOS commands / click on command ( example 'FINDSTR /?' ) to see details / all parameters
add your own commands to variable 'e1x' , like :
ipconfig /all
netstat -e -s
RESTORE rstrui
etc....
Code: Select all
;- DOS-HELP
;- https://www.autohotkey.com/boards/viewtopic.php?f=10&t=74432
;- if german-help Umlaut in DOS , problem solved from ahk-users KHA and Rohwedder
;- create a text-file > %a_scriptdir%\doscommands_small.txt
;MODIFIED= 20200409
;CREATED = 20200312
#warn
FileEncoding , UTF-8
;- https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
;- https://docs.microsoft.com/en-au/windows/win32/shell/knownfolderid
;- https://docs.microsoft.com/en-au/windows/win32/shell/csidl
setworkingdir,%a_scriptdir%
Gui,2:default
Gui,2: -DPIScale
Gui,2:color,black,black
Gui,2:Font,s12 cYellow,Lucida Console
DetectHiddenWindows On
autotrim,off
transform,s,chr,32
dlm:=";"
wa:=A_screenwidth
ha:=A_screenHeight
xx:=100
;-------------------------
DllCall("AllocConsole")
;DllCall("AttachConsole")
;DllCall("AttachConsole", "UInt", pid)
WinHide % "ahk_id " DllCall("GetConsoleWindow", "ptr")
;WinMinimize % "ahk_id " DllCall("GetConsoleWindow", "uint")
objShell := ComObjCreate("WScript.Shell")
;---------------
gosub,readLB
;---------------
x:=(wa*1)/xx ,y:=(ha*1)/xx,h:=(ha*2.6)/xx,w:=(wa*20)/xx
Gui,2:Add,Edit,x%x% y%y% w%w% h%h% vED0 ,dir
x:=(wa*22)/xx ,y:=(ha*1)/xx,h:=(ha*2.5)/xx,w:=(wa*4)/xx
Gui,2:Add,Button,x%x% y%y% w%w% h%h% gRun default,<GO
x:=(wa*1)/xx ,y:=(ha*4)/xx,h:=(ha*90)/xx,w:=(wa*10)/xx
Gui,2:Add,Listbox,x%x% y%y% w%w% h%h% vLB1 gLB1,%e1x%
x:=(wa*12)/xx,y:=(ha*4)/xx,h:=(ha*90)/xx,w:=(wa*68)/xx
Gui,2:Add,Edit, x%x% y%y% h%h% w%w% vED1 cYellow,
x:=(wa*.1)/xx,y:=(ha*.1)/xx,h:=(ha*97)/xx,w:=(wa*80)/xx
Gui,2:Show, x%x% y%y% w%w% h%h% ,DOS-HELP
return
;----------------------------------------------
2Guiescape:
2Guiclose:
DllCall("FreeConsole")
sleep,200
exitapp
;----------------------------------------------
run:
Gui,2:submit,nohide
GuiControl,2:,ED1,
lb1=%ed0%
if (lb1="ping")
goto ping
objExec := objShell.Exec(ComSpec " /Q /K chcp 1252 ")
objExec.StdIn.WriteLine(lb1 . "`r`nexit")
cl:=""
while, !objExec.StdOut.AtEndOfStream
cl:= objExec.StdOut.ReadAll()
gosub,umlaut
GuiControl,2:,ED1,%Cl%
cl:=""
return
;----------------------------------------------
lb1:
gui,2:submit,nohide
GuiControl,2:,ED1,
h1:=""
h2:=""
stringsplit,h,lb1,%dlm%
lb1=%h2%
if (lb1="ping")
goto ping
objExec := objShell.Exec(ComSpec " /Q /K chcp 1252 ")
objExec.StdIn.WriteLine(lb1 . "`r`nexit")
cl:=""
while, !objExec.StdOut.AtEndOfStream
cl:= objExec.StdOut.ReadAll()
if (lb1="chcp")
GuiControl,2:,ED1,%Cl%
else
Gosub,umlaut
GuiControl,2:,ED1,%Cl%
cl:=""
return
;----------------------------------------------
;----------- ping example ---------------------
ping:
Gui,2:submit,nohide
objExec := objShell.Exec("cmd /c ping -n 3 -w 1000 autohotkey.com")
cl:=""
while,!objExec.StdOut.AtEndOfStream
{
cl.=objExec.StdOut.readline() . "`n"
gosub,umlaut
GuiControl,2:,ED1,%cl%
}
cl:=""
return
;--------------------------------
umlaut:
;- from ahk-user Rohwedder german Umlaut
;cl := StrReplace(cl, "Aktive Codepage: 1252.")
;cl := StrReplace(cl, A_ScriptDir . ">")
cl := StrReplace(cl,chr(8221),chr(246))
cl := StrReplace(cl,chr(8222),chr(228))
cl := StrReplace(cl,chr(353),chr(220))
cl := StrReplace(cl,chr(129),chr(252))
cl := StrReplace(cl,chr(381),chr(196))
cl := StrReplace(cl,chr(225),chr(223))
return
;----------------------------------------------
readLB:
Gui,2:submit,node
;--------------------- DOS commands -----
fcdm=%a_scriptdir%\doscommands_small.txt
;- user KHA save text with german Umlaut
ifnotexist,%fcdm%
{
;runwait,%comspec% /c help >"%fcdm%",,hide,
FileAppend, % RunWaitMany("
(
chcp 1252
help
)"),%fcdm%
}
;-----------------------------------------
i=0
e1x:=""
;- add some other commands to variable e1x
e1x:="
(Ltrim Join|
netstat -an ;netstat -an
netstat -e -s ;netstat -e -s
netstat ;netstat
ipconfig /? ;ipconfig /?
ipconfig ;ipconfig
ipconfig /all ;ipconfig /all
dir /P /Q /L /4 /TAWC ;dir /P /Q /L /4 /TAWC
help ;help
date /t ;date /t
time /t ;time /t
RESTORE rstrui ;rstrui
ping ;ping
ping /? ;ping /?
"
)
fileread,a,%fcdm%
loop,parse,a,`n,`r ;- parse each line
{
i++
if (i<4) ;- remove at least the first 3 lines from help
continue
y1=%a_loopfield%
if y1=
break ;- at last line which is empty , then finish
stringmid,y2,y1,1,3
if (y1="" or y2=" ")
{
y1=
y2=
continue
}
c1=
stringsplit,c,y1,%s%
if (c1="dir" or c1="ver" or c1="path" or c1="chcp")
e1x .= c1 . " " . dlm . c1 . "|"
e1x .= c1 . " /? " . dlm . c1 . " /?|"
}
a=
return
;--------------------------------
;function user KHA
RunWaitMany(cmds) {
shell := ComObjCreate("WScript.Shell") ;- opens cmd.exe
exec := shell.Exec(ComSpec " /Q /K echo off") ;- send commands separated with new lines
exec.StdIn.WriteLine(cmds "`nexit") ;- exit at end
return exec.StdOut.ReadAll() ;- read output commands and returns
}
;================= END SCRIPT ================================================