Beispiel mit 'teadinker's CMDRET , logfile mit UMLAUT scheint OK ausgenommen z.B. chinese characters , aber in EDIT war alles OK ( benütze Button PRINT , siehe Beispiel )
oder kurz ... :
Code: Select all
;----------------------------------------------
;cmdx=chcp 65001&dir ;- this don't show chinese characters in EDIT
;cmdx:="ping autohotkey.com -n 4"
;--------------------------------------
F2=%a_desktop%\robocopyHelp.txt
;cmdx=chcp 65001&robocopy /? >%f2% ;- robocopy helpfile OK
;--------------------------------------
;/*
;- this example shows chinese characters in EDIT / but not in LOGFILE , UMLAUT OK
;- use button PRINT
;----------
logfile =%a_desktop%\%a_now%_Robocopy_Log.txt
excludex =%logfile%
;----------
source =C:\Users\GARRY\Desktop\FAV_TEST\CMD_RET_DOS ;-- <<<<<<
destination=F:\TESTXX ;-- <<<<<<
;----------
cmdx=chcp 65001&robocopy %source% "%destination%" /XO /E /TEE /UNICODE /UNILOG+:%logfile% /XD %excludex%
;*/
;============== GUI test for robocopy ===========
#warn
#noenv
name1:="DOS_TEST"
global name1
e:=""
;CPX:="cp" . DllCall("GetOEMCP", "UInt") ;- get CODEPAGE e.g. CP850 [ use this for DOS commands ]
cpx:="cp65001"
setworkingdir,%a_scriptdir%
Gui,1:default
Gui,1: -DPIScale
Gui,1:Color,Black,Black ; GUI black / EDIT is BLACK
wa:=A_screenwidth,ha:=A_screenHeight,xx:=100
;- maybe change fontsize
;============ GUISIZEx DPIx 4Kx 3840*2160 is 100% ============
if (wa=3840)
Gui,1:Font,s12 cYellow,Lucida Console
;============ GUISIZEx DPIx FHD 1920*1080 is 100% ============
else if (wa=1920)
Gui,1:Font,s10 cYellow,Lucida Console
else
Gui,1:Font,s8 cYellow,Lucida Console
;=============================================================
x:=(wa*1)/xx,y:=(ha*1)/xx,w:=(wa*70)/xx,h:=(ha*60)/xx
;Gui, Add, Edit, x%x% y%y% w%w% h%h% vED1 +0x0400 ;- here the output
Gui, Add, Edit, x%x% y%y% w%w% h%h% vED1 ;- here the output
x:=(wa*1)/xx,y:=(ha*63)/xx,w:=(wa*65)/xx,h:=(ha*6)/xx
Gui, Add, Edit, x%x% y%y% w%w% h%h% vED2,%cmdx% ;- add CMDx command above
x:=(wa*67)/xx,y:=(ha*63)/xx,w:=(wa*5)/xx,h:=(ha*2.2)/xx
Gui, add, Edit, x%x% y%y% w%w% h%h% vED3,
x:=(wa*67)/xx,y:=(ha*66)/xx,w:=(wa*5)/xx,h:=(ha*2.2)/xx
Gui,add,button, x%x% y%y% w%w% h%h% gPrintx, PRINT
x:=(wa*2)/xx,y:=(ha*2)/xx,w:=(wa*75)/xx,h:=(ha*75)/xx
Gui, Show,x%x% y%y% w%w% h%h%,%name1%
gosub,a0
GuiControl,1: Focus,ED2
;send,^{end}
return
;-------------------------
Guiclose:
Exitapp
esc::exitapp
;-------------------------
;- ENTER here DOS commands
~$enter::
CPX:="cp" . DllCall("GetOEMCP", "UInt")
gosub,a0
return
;=========================================================
AddOutputInGui(output) {
Control, EditPaste, %output%`r`n, Edit1,%name1% ;- display output in 1st EDIT
}
;=========================================================
A0:
Gui,1:submit,nohide
ed2a:="cmd /c " . ed2
;CmdRet(ED2a, Func("AddOutputInGui"),CPX)
xxc:=cmdret(ED2a, Func("AddOutputInGui"),CPX)
e .="`r`n===============================`r`n" . ed2 . " =`r`n-------------------------------`r`n" . xxc . "`r`n===============================`r`n"
e := RegExReplace(e, "((^)|\R)\h*(?=\R|$)(?(2)\R)") ;- remove empty lines
gosub,clear
return
;-------------------------
CLEAR:
Gui,1:submit,nohide
Guicontrol,1:,ED2,
Guicontrol,1:,ED3,ENDED
GuiControl,1: Focus,ED2
ifexist,%f2%
run,%f2%
return
;-------------------------
printx:
f1=%a_desktop%\%a_now%_DOS_SCREEN_OUTPUT.txt
Gui,1:submit,nohide
if e<>
{
fileappend,%e%,%f1%,utf-8
run,%f1%
e:=""
}
return
;================= function from user teadrinker ========================================
;- https://www.autohotkey.com/boards/viewtopic.php?p=369467#p369467
CmdRet(sCmd, callBackFuncObj := "", encoding := "CP0")
{
static HANDLE_FLAG_INHERIT := 0x00000001, flags := HANDLE_FLAG_INHERIT
, STARTF_USESTDHANDLES := 0x100, CREATE_NO_WINDOW := 0x08000000
hPipeRead:=""
hPipeWrite:=""
sOutput:=""
DllCall("CreatePipe", "PtrP", hPipeRead, "PtrP", hPipeWrite, "Ptr", 0, "UInt", 0)
DllCall("SetHandleInformation", "Ptr", hPipeWrite, "UInt", flags, "UInt", HANDLE_FLAG_INHERIT)
VarSetCapacity(STARTUPINFO , siSize := A_PtrSize*4 + 4*8 + A_PtrSize*5, 0)
NumPut(siSize , STARTUPINFO)
NumPut(STARTF_USESTDHANDLES, STARTUPINFO, A_PtrSize*4 + 4*7)
NumPut(hPipeWrite , STARTUPINFO, A_PtrSize*4 + 4*8 + A_PtrSize*3)
NumPut(hPipeWrite , STARTUPINFO, A_PtrSize*4 + 4*8 + A_PtrSize*4)
VarSetCapacity(PROCESS_INFORMATION, A_PtrSize*2 + 4*2, 0)
if !DllCall("CreateProcess", "Ptr", 0, "Str", sCmd, "Ptr", 0, "Ptr", 0, "UInt", true, "UInt", CREATE_NO_WINDOW
, "Ptr", 0, "Ptr", 0, "Ptr", &STARTUPINFO, "Ptr", &PROCESS_INFORMATION)
{
DllCall("CloseHandle", "Ptr", hPipeRead)
DllCall("CloseHandle", "Ptr", hPipeWrite)
throw Exception("CreateProcess is failed")
}
DllCall("CloseHandle", "Ptr", hPipeWrite)
VarSetCapacity(sTemp, 4096), nSize := 0
while DllCall("ReadFile", "Ptr", hPipeRead, "Ptr", &sTemp, "UInt", 4096, "UIntP", nSize, "UInt", 0) {
sOutput .= stdOut := StrGet(&sTemp, nSize, encoding)
;sOutput .= stdOut := StrGet(&sTemp, nSize)
;sOutput .= stdOut := StrGet(&sTemp, nSize, CPX)
( callBackFuncObj && callBackFuncObj.Call(stdOut) )
}
DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION))
DllCall("CloseHandle", "Ptr", NumGet(PROCESS_INFORMATION, A_PtrSize))
DllCall("CloseHandle", "Ptr", hPipeRead)
Return sOutput
}
;================= END SCRIPT ========================================================================
;- PRINT button text copy
/*
Neue Datei 7468 多线程系统代理下载tube1080p视频_20210307161300.ahk
100%
Neues Verz. 1 C:\Users\GARRY\Desktop\FAV_TEST\CMD_RET_DOS\Neuer Ordner\
Neue Datei 5 Kühlschrank_Bär etc.txt
100%
Neues Verz. 0 C:\Users\GARRY\Desktop\FAV_TEST\CMD_RET_DOS\Neuer Ordner\Neuer Ordner\
------------------------------------------------------------------------------
Insgesamt KopiertÜbersprungenKeine Übereinstimmung FEHLER Extras
Verzeich.: 3 3 0 0 0 0
Dateien: 15 15 0 0 0 0
Bytes: 9.58 m 9.58 m 0 0 0 0
Zeiten: 0:00:04 0:00:04 0:00:00 0:00:00
Geschwindigkeit: 2078308 Bytes/Sek.
Geschwindigkeit: 118.921 Megabytes/Min.
Beendet: Dienstag, 11. Mai 2021 22:49:35
===============================
*/