DOS-HELP

Post your working scripts, libraries and tools
garry
Posts: 2430
Joined: 22 Dec 2013, 12:50

DOS-HELP

24 Apr 2020, 01:51

from german forum / output solved for german umlaut

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 ================================================
Last edited by garry on 01 May 2020, 06:46, edited 1 time in total.
burque505
Posts: 1371
Joined: 22 Jan 2017, 19:37

Re: DOS-HELP

24 Apr 2020, 08:42

@garry, that's nice! Thank you.
Regards,
burque505
User avatar
Cerberus
Posts: 169
Joined: 12 Jan 2016, 15:46

Re: DOS-HELP

25 Apr 2020, 13:35

Interesting: what does the script do? What is it for?
burque505
Posts: 1371
Joined: 22 Jan 2017, 19:37

Re: DOS-HELP

25 Apr 2020, 13:46

:D A picture's worth 1000 words, etc.
You get a command prompt with a list of commands on the left.
dos-help2.PNG
dos-help2.PNG (5.13 KiB) Viewed 515 times
Click one, get this:
dos-help1.PNG
dos-help1.PNG (46.73 KiB) Viewed 515 times
Run commands from the field on the top left (not shown). Output appears in the GUI.
Regards,
burque505
garry
Posts: 2430
Joined: 22 Dec 2013, 12:50

Re: DOS-HELP

25 Apr 2020, 13:49

@burque505 , thank you
A picture's worth 1000 words, etc.
User avatar
elModo7
Posts: 185
Joined: 01 Sep 2017, 02:38
GitHub: elModo7
Location: Spain
Contact:

Re: DOS-HELP

28 Apr 2020, 06:30

Interesting, thanks for sharing!
:beer:

Return to “Scripts and Functions”

Who is online

Users browsing this forum: daywalker, Google [Bot], pgeugene and 24 guests