@Rohwedder thank you
I use win-11
if I open DOS window , type DIR , I dont see chinese characters in filename
example OK: writes to textfile F1 UTF-16 LE ,DOS-commands like DIR or VER
for other commands like > PING or SYSTEMINFO ( this show me only chinese characters ) , for these use |CLIP
Code: Select all
;- test : DOS command write to file F1 , then must read with *P1200 , because file F1 is UTF-16 LE
;- only for dos commands like dir/ver > show chinese characters in filename
;- commands like ping or systeminfo > result show only chinese characters
;- so use clip for commands like ping or systeminfo ....
;-
#Warn
#Singleinstance,force
setworkingdir,%a_scriptdir%
Fileencoding,UTF-8
F1:=a_scriptdir . "\DOSoutput11.txt"
;-
;-- DOS-COMMANDS --------- :
;- OK , show chinese characters in file F1 :
cmd:="dir"
cmd:="dir&&ver"
;- Åäöü 夜来香 เย่ไหลเซียง_Ye Lai Xiang$Bkkjay Th$zS6jOzNty1M.txt ;-- <<< get result , DIR
;-
;- here use clip , otherwise see only chinese characters when use PING or SYSTEMINFO
;cmd:="dir&&ver&&systeminfo"
;cmd:="systeminfo&&ver"
;cmd:="dir&&ping autohotkey.com -n 2"
;-------------------------
cmdx:=cmd
Critical, ON
tooltip,DOS Running...
if cmd contains dir
;if (cmd="dir")
{
RunWait, %Comspec% /U /C "(%cmdx%) 2>&1 >%f1%",, Hide ;- file is UTF-16 LE
;RunWait, %Comspec% /U /C "(%cmdx%) >%f1%",, Hide
}
else
RunWait, %Comspec% /C "(%cmdx%) 2>&1 |clip",, Hide ;- OK for all commands , not see chinese characters in filename
if cmd contains dir
;if (cmd="dir")
FileRead,text1, *P1200 %f1%
else
text1:=clipboard
tooltip
msgbox,%text1%
return
;====================================================
2nd example with DOScommandHere for command DIR ( see also chinese characters )
Code: Select all
#Warn
#Singleinstance,force
setworkingdir,%a_scriptdir%
Fileencoding,UTF-8
F1:=a_scriptdir . "\DOSoutput11.txt"
;-- DOS-COMMANDS ----------------------- :
;- OK show chinese characters in file F1 :
cmd:="dir"
cmd:="ver&&dir"
;- Åäöü 夜来香 เย่ไหลเซียง_Ye Lai Xiang$Bkkjay Th$zS6jOzNty1M.txt
;-
;- here use clip otherwise see only chinese characters when use systeminfo or ping
;cmd:="ver&&dir&&systeminfo"
;cmd:="systeminfo&&ver"
;cmd:="ver&&dir&&ping autohotkey.com -n 2"
;--------------------------------------
return
;-----------
esc::exitapp
;----------- start with F9 ---------------------------
$F9::
cmdx:=cmd
Critical, ON
tooltip,DOS Running...
;if cmd contains dir
if (cmd="dir")
{
gosub,a2
RunWait, %Comspec% /U /C dir %aa% 2>&1 >%f1%,, Hide ;- file is UTF-16 LE
}
else
RunWait, %Comspec% /C "(%cmdx%) 2>&1 |clip",, Hide
;if cmd contains dir
if (cmd="dir")
FileRead,text1, *P1200 %f1%
else
text1:=clipboard
tooltip
msgbox,%text1%
return
;------------- DOScommandHERE tmplinshi --------------
A2:
;- tmplinshi / DOScommandhere WIN11 https://www.autohotkey.com/boards/viewtopic.php?p=33858#p33858
dirx:=""
If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass") {
WinHWND := WinActive()
For win in ComObjCreate("Shell.Application").Windows
If (win.HWND = WinHWND) {
dirx := SubStr(win.LocationURL, 9) ; remove "file:///"
dirx := RegExReplace(dirx, "%20", " ")
Break
}
}
;Run, cmd, % dir ? dir : A_Desktop
aa:=dirx ? dirx : A_Desktop
stringreplace,aa,aa,/,\,all
return
;====================================================