DOS-HELP

Veröffentliche deine funktionierenden Skripte und Funktionen

Moderator: jNizM

garry
Posts: 3771
Joined: 22 Dec 2013, 12:50

DOS-HELP

09 Apr 2020, 05:11

danke für eure Hilfe , hatte Probleme mit Darstellung der Umlaut ( deutsch )
hier ein GUI , DOS-HELP / WIN-10 / deutsch
Liste wird automatisch erstellt , paar zusätzliche Befehle angefügt für Listbox ( variable e1x )
Ein Edit für Direkteingabe

Code: Select all

;- DOS-HELP
;- Umlaut in DOS , Problem von den ahk-usern KHA and Rohwedder gelöst
;- erstellt ein 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 ,<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()
gosub,umlaut
GuiControl,2:,ED1,%Cl%
cl:=""
return
;----------------------------------------------

;----------------------------------------------
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 zeigt Umlaut in Edit richtig
;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 speichert Text richtig mit Umlaut
ifnotexist,%fcdm%
  {
   ;runwait,%comspec% /c help >"%fcdm%",,hide,
  FileAppend,  % RunWaitViele("
  (
  chcp 1252
  help
  )"),%fcdm%
  }
;-----------------------------------------
i=0
e1x:=""
;- add 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 , thenfinish
   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 
RunWaitViele(Befehle) {
    shell := ComObjCreate("WScript.Shell")
    ;- Öffnet cmd.exe mit deaktivierter Textanzeige
    exec := shell.Exec(ComSpec " /Q /K echo off")
    ;- Sendet die Befehle, die ausgeführt werden sollen, getrennt durch Newline
    exec.StdIn.WriteLine(Befehle "`nexit")         ;- Immer ein Exit am Ende!
    ;- Liest die Ausgaben aller Befehle und gibt sie zurück
    return exec.StdOut.ReadAll()
}
;================= END SCRIPT ================================================
esc::exitapp

Return to “Skripte und Funktionen”

Who is online

Users browsing this forum: No registered users and 14 guests