cmd回显老是乱码,求解
在GUICtrlCreateEdit中回显时,中文总是会乱码!!!求解,用的是win7的系统.. 帮顶!!!!!!!!!! 回复 1# 515276542什么意思 windows CMD本身的BUG,我也遇到过
可能要写个正则,以“>”为分界,直接省略后面所有的乱码 回复 3# netegg 就是这样 是否64位系统运行时点击右键选 运行脚本(X64) 回复 6# lainline
是的,正是64位。那我试下先 回复 6# lainline
还是有诶,不过好像没有之前那么严重... 这个问题俺也碰上了,希望能有高人解决 本帖最后由 happytc 于 2011-8-1 08:08 编辑
在GUICtrlCreateEdit中回显时,中文总是会乱码!!!求解,用的是win7的系统..
515276542 发表于 2011-7-24 16:40 http://www.autoitx.com/images/common/back.gif
乱码问题,应该转一下后,就会大为减少的,象下面这样:
$Pid = Run(@ComSpec & " /c " & $Prompt, @WorkingDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While True
$Stream &= StdoutRead($Pid)
If @error Then ExitLoop
Wend
While True
$Stream &= StderrRead($Pid)
If @error Then ExitLoop
WEnd
$Stream = DllCall('user32.dll','Int','OemToChar','str',$Stream,'str','')
$Stream = $Stream
ConsoleWrite($Stream)
其实我发现象我上面这样写的,乱码倒不是多大问题,问题更严重的是回显得不全
运行Systeminfo命令,很少能回显全部文本的
大家有什么方法可以解决? 看看是不是字体格式不是UTF8 本帖最后由 3mile 于 2011-8-1 20:27 编辑
借用4楼兄弟的另一个问题贴
http://www.autoitx.com/forum.php?mod=viewthread&tid=26341&fromuid=7639113
命令框输完命令"回车"即可
#include <ButtonConstants.au3>
#include <GUIButton.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <GUIImageList.au3>
#include <GuiEdit.au3>
#include <WinAPIEx.au3>
HotKeySet("{F7}", "quit")
Func quit()
ProcessClose("cmd.exe")
Exit 0
EndFunc ;==>quit
Global $PT = 0
$HDL = Run(@ComSpec, "", @SW_HIDE, $STDIN_CHILD + $STDERR_MERGED)
$GUIID = GUICreate("CMDshell", 600, 750)
$DISP = GUICtrlCreateEdit("", 10, 10, 580, 700, $Es_READONLY + $WS_VSCROLL + $WS_HSCROLL + $ES_OEMCONVERT)
GUICtrlSetLimit(-1, 1024 * 1024)
GUICtrlSetFont(-1, 9, 200, 0)
GUICtrlSetBkColor($DISP, 0x000000)
GUICtrlSetColor($DISP, 0x00FF00)
$CMDS = GUICtrlCreateEdit("commands...", 10, 720, 530, 20)
GUICtrlSetBkColor($CMDS, 0x000000)
GUICtrlSetColor($CMDS, 0xFFFFFF)
$BUTN = GUICtrlCreateButton("历史", 540, 720, 50, 20);,$BS_DEFPUSHBUTTON)
GUICtrlSetFont(-1, 8, 800, Default, "微软雅黑")
GUICtrlSetBkColor($BUTN, 0x000000)
GUICtrlSetColor($BUTN, 0x00FF00)
GUISetBkColor(0x000000)
$Dummy = GUICtrlCreateDummy()
GUISetState()
Local $Key = [["{Enter}", $Dummy]]
GUISetAccelerators($Key)
_GUICtrlEdit_SetSel($CMDS, 0, -1)
While 1
$guimsg = GUIGetMsg()
Switch $guimsg
Case $GUI_EVENT_CLOSE
quit()
Case $BUTN
ShellExecute("out.txt")
;~ StdinWrite($HDL, _GUICtrlEdit_GetText($CMDS) & @CRLF)
;~ _GUICtrlEdit_SetSel($CMDS,0,-1)
Case $Dummy
Local $aResult = DllCall("user32.dll", "hwnd", "GetFocus")
If $aResult = GUICtrlGetHandle($CMDS) Then
If _GUICtrlEdit_GetText($CMDS) = "cls" Then _GUICtrlEdit_SetText($DISP, "")
If _GUICtrlEdit_GetText($CMDS) = "exit" Then quit()
StdinWrite($HDL, _GUICtrlEdit_GetText($CMDS) & @CRLF)
_GUICtrlEdit_SetSel($CMDS, 0, -1)
EndIf
EndSwitch
$msg = StdoutRead($HDL)
If $msg <> "" Then
If _GUICtrlEdit_GetLineCount($DISP) > 500 Then
$hFile = FileOpen("out.txt", 1)
FileWrite($hFile, _GUICtrlEdit_GetText($DISP))
FileClose($hFile)
_GUICtrlEdit_SetText($DISP, "")
EndIf
_GUICtrlEdit_AppendText($DISP, $msg)
;~ $array = StringSplit($msg, @CRLF)
;~ _ArrayDisplay($array)
;~ For $i = 1 To $array
;~ If $array[$i] = "" Then ContinueLoop
;~ _GUICtrlEdit_AppendText($DISP, _WinAPI_OemToChar($array[$i]) & @CRLF)
;~ Next
$msg = ""
EndIf
WEnd
回复 12# 3mile
这个壳还是不错的,挺好看! 3mile大哥....谢谢分享 3mile大哥....谢谢分享
页:
[1]
2