Umlaut in DOS

Stelle Fragen zur Programmierung mit Autohotkey

Moderator: jNizM

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

Umlaut in DOS

12 Mar 2020, 15:01

unten ein kleiner script , DOS-commands-help
Probleme mit der Darstellung der deutschen Buchstaben ( umlaut , ß .. )
Problem in diesem Teil ( ? )

Code: Select all

;--------------------- DOS commands -----
fcdm=%a_scriptdir%\doscommands_new2.txt
ifnotexist,%fcdm%
   runwait,%comspec% /c help >"%fcdm%",,hide,
;-----------------------------------------

Code: Select all

#warn
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
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*50)/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*1)/xx,h:=(ha*50)/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*53)/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
;----------------------------------------------
;----------------------------------------------
lb1:
gui,2:submit,nohide
GuiControl,2:,ED1,
objExec := objShell.Exec(ComSpec " /c  " . lb1 . "`n")
cl:=""
while, !objExec.StdOut.AtEndOfStream
    cl:= objExec.StdOut.ReadAll()
GuiControl,2:,ED1,%Cl%
cl:=""
return
;----------------------------------------------
;----------------------------------------------
readLB:
;--------------------- DOS commands -----
fcdm=%a_scriptdir%\doscommands_new2.txt
ifnotexist,%fcdm%
   runwait,%comspec% /c help >"%fcdm%",,hide,
;-----------------------------------------
i=0
e1x:=""
fileread,a,%fcdm%
   loop,parse,a,`n,`r           ;- parse each line
   {
   i++
   if (i<3)                     ;- remove at least the first two lines from help
     continue
   y1=%a_loopfield%
   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 . "|"
   e1x .= c1 . " /?|"
   }
a=
return
;================= END SCRIPT ================================================
esc::exitapp
KHA
Posts: 403
Joined: 21 Aug 2018, 11:11

Re: Umlaut in DOS

12 Mar 2020, 16:35

Einfach den Zeichensatz auf 1252 stellen
So klappt es bei mir.

Code: Select all

FileAppend,  % RunWaitViele("
(
chcp 1252
help

)"), doscommands_new2.txt

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()
}

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

Re: Umlaut in DOS

13 Mar 2020, 05:39

@KHA, vielen Dank , Text-Datei wird richtig abgespeichert
habe noch Problem im Edit-Feld (ED1) , DOS wird kopiert und im Edit angezeigt

Variable 'CL' noch encoden
Beispiel , fast gut :

Code: Select all

lb1:
gui,2:submit,nohide
GuiControl,2:,ED1,
objExec := objShell.Exec(ComSpec " /c  " . lb1 . "`n")
cl:=""
while, !objExec.StdOut.AtEndOfStream
    cl:= objExec.StdOut.ReadAll()
cl:=ConvertString(cl, "CP865")    ; deutsch ss ok  / bestimmte Umlaut fehlt oder falsch 
GuiControl,2:,ED1,%cl%
cl:=""
return
;----------------------------------------------

ConvertString(ByRef String, Encoding) {
   VarSetCapacity(Buffer, StrLen(String), 0)
   Loop, Parse, String
      NumPut(Asc(A_LoopField), Buffer, A_Index - 1, "UChar")
   Return StrGet(&Buffer, Encoding)
}
comp /?

Code: Select all

Vergleicht den Inhalt von zwei Dateien oder Dateistzen.

COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]] [/M]

  data1      Gibt den Speicherort und Namen der ersten zu vergleichenden Datei(en) an.
  data2      Gibt den Speicherort und Namen der zweiten zu vergleichenden Datei(en) an.
  /D         Zeigt Unterschiede im Dezimalformat an.
  /A         Zeigt Unterschiede in ASCII-Zeichen an.
  /L         Zeigt Zeilennummern für Unterschiede an.
  /N=number  Vergleicht nur die erste angegebene Anzahl von Zeilen in jeder Datei.
  /C         Ignoriert beim Dateivergleich die Groß-/Kleinschreibung von ASCII-Buchstaben.
  /OFF[LINE] aberspringt keine Dateien, deren Offlineattribut festgelegt ist.
  /M         Es werden keine weiteren Dateien für den Vergleich angefordert.

Verwenden Sie zum Vergleichen von Dateistzen Platzhalter im data1-Parameter und data2-Parameter.
KHA
Posts: 403
Joined: 21 Aug 2018, 11:11

Re: Umlaut in DOS

13 Mar 2020, 13:16

Ich bin jetzt kein DOS experte, soweit ich weiß verwendet die Eingabeaufforderung den Zeichensatz OEM 850, will man das ändern, muss man den Zeichensatz auf 1252 stellen.
Also ungefähr so:

Code: Select all

#warn
FileEncoding , UTF-8

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
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*50)/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*1)/xx,h:=(ha*50)/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*53)/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
;----------------------------------------------
;----------------------------------------------
lb1:
gui,2:submit,nohide
GuiControl,2:,ED1,
 


;objExec := objShell.Exec(ComSpec " /c  " . lb1 . "`n")
;Zeile umgeschrieben
objExec := objShell.Exec(ComSpec " /Q /K chcp 1252 ") 
objExec.StdIn.WriteLine(lb1 . "`nexit")

cl:=""
while, !objExec.StdOut.AtEndOfStream
    cl:= objExec.StdOut.ReadAll()

 ;------> Falls notwendig
cl := StrReplace(cl, "Aktive Codepage: 1252.")
cl := StrReplace(cl, A_ScriptDir . ">")


GuiControl,2:,ED1,%Cl%
cl:=""
return
;----------------------------------------------
;----------------------------------------------
readLB:
;--------------------- DOS commands -----
fcdm=%a_scriptdir%\doscommands_new2.txt
ifnotexist,%fcdm%
   runwait,%comspec% /c help >"%fcdm%",,hide,
;-----------------------------------------
i=0
e1x:=""
fileread,a,%fcdm%
   loop,parse,a,`n,`r           ;- parse each line
   {
   i++
   if (i<3)                     ;- remove at least the first two lines from help
     continue
   y1=%a_loopfield%
   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 . "|"
   e1x .= c1 . " /?|"
   }
a=
return
;================= END SCRIPT ================================================
esc::exitapp
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: Umlaut in DOS

13 Mar 2020, 14:30

@KHA, es funktioniert , danke für Korrektur
eigenartigerweise zeigt es bei einigen Befehlen Umlaut falsch, bei den anderen aber nicht ...
Last edited by garry on 14 Mar 2020, 08:14, edited 1 time in total.
Rohwedder
Posts: 7655
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Umlaut in DOS

14 Mar 2020, 05:15

Hallo,
so vielleicht?

Code: Select all

#warn
FileEncoding , UTF-8

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
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*50)/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*1)/xx,h:=(ha*50)/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*53)/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
;----------------------------------------------
;----------------------------------------------
lb1:
gui,2:submit,nohide
GuiControl,2:,ED1,
 


;objExec := objShell.Exec(ComSpec " /c  " . lb1 . "`n")
;Zeile umgeschrieben
objExec := objShell.Exec(ComSpec " /Q /K chcp 1252 ") 
objExec.StdIn.WriteLine(lb1 . "`nexit")

cl:=""
while, !objExec.StdOut.AtEndOfStream
    cl:= objExec.StdOut.ReadAll()

 ;------> Falls notwendig
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))

GuiControl,2:,ED1,%Cl%
cl:=""
return
;----------------------------------------------
;----------------------------------------------
readLB:
;--------------------- DOS commands -----
fcdm=%a_scriptdir%\doscommands_new2.txt
ifnotexist,%fcdm%
   runwait,%comspec% /c help >"%fcdm%",,hide,
;-----------------------------------------
i=0
e1x:=""
fileread,a,%fcdm%
   loop,parse,a,`n,`r           ;- parse each line
   {
   i++
   if (i<3)                     ;- remove at least the first two lines from help
     continue
   y1=%a_loopfield%
   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 . "|"
   e1x .= c1 . " /?|"
   }
a=
return
;================= END SCRIPT ================================================
esc::exitapp
garry
Posts: 3770
Joined: 22 Dec 2013, 12:50

Re: Umlaut in DOS

14 Mar 2020, 08:14

@Rohwedder, funktioniert alles ,vielen Dank für Deine viele Arbeit

Return to “Ich brauche Hilfe”

Who is online

Users browsing this forum: No registered users and 71 guests