我去啊!!!!我怎么总是遇到这种神一样的BUG,字符串连接“&”无效!?!?
本帖最后由 wsycharles0o 于 2011-7-25 12:13 编辑直接看代码里面那段.....
运行的时候要随便输点东西进去execute
通常ipconfig就可以
第一次合并没问题,把CMD标题显示出来了
之后所有的指令回显全都无效,就是字符串合并的问题,$echo自从第一次赋值就没变过....我彻底无语了.....#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <String.au3>
HotKeySet("{F7}","quit")
Func quit()
ProcessClose("cmd.exe")
Exit 0
EndFunc
Global $PT=0
$HDL=Run(@ComSpec,"",@SW_HIDE,$STDIN_CHILD+$STDOUT_CHILD+$STDERR_CHILD)
$GUIID=GUICreate("CMDshell",600,750)
$DISP=GUICtrlCreateEdit("",10,10,580,700,$Es_READONLY+$WS_VSCROLL)
;;GUICtrlSetStyle($DISP,$WS_VSCROLL)
GUICtrlSetBkColor($DISP,0x000000)
GUICtrlSetColor($DISP,0xFFFFFF)
$CMDS=GUICtrlCreateInput("commands...",10,720,530,20)
GUICtrlSetBkColor($CMDS,0x000000)
GUICtrlSetColor($CMDS,0xFFFFFF)
$BUTN=GUICtrlCreateButton("Execute",540,720,50,20)
GUICtrlSetBkColor($BUTN,0x000000)
GUICtrlSetColor($BUTN,0x00FF00)
GUISetBkColor(0x000000)
GUISetState()
Global $echo=""
While 1
$guimsg=GUIGetMsg()
Switch $guimsg
Case $GUI_EVENT_CLOSE
quit()
Case $BUTN
StdinWrite($HDL,GUICtrlRead($CMDS)&@CRLF)
EndSwitch
Sleep(1)
$msg=StdoutRead($HDL)
MsgBox(0,0,$msg)
If $msg <> "" Then
MsgBox(0,"$",S($echo,$msg));;这里就是BUG
$echo=S($echo,$msg);;不管怎样都无效!换成"$echo&=$msg"无效,换成"$echo=$echo&$msg"无效,写成自定义函数无效,用UDF"_StringInsert"还是无效,我是遇到神一样的BUG了么?
MsgBox(0,1,$echo)
GUICtrlSetData($DISP,$echo)
$msg=""
EndIf
WEnd
Func S($s1,$s2)
Return($s1&$s2)
EndFunc
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>
#include <String.au3>
#Include <GuiEdit.au3>
HotKeySet("{F7}","quit")
Func quit()
ProcessClose("cmd.exe")
Exit 0
EndFunc
Global $PT=0
$HDL=Run(@ComSpec,"",@SW_HIDE,$STDIN_CHILD+$STDOUT_CHILD+$STDERR_CHILD)
$GUIID=GUICreate("CMDshell",600,750)
$DISP=GUICtrlCreateEdit("",10,10,580,700,$Es_READONLY+$WS_VSCROLL)
;;GUICtrlSetStyle($DISP,$WS_VSCROLL)
GUICtrlSetBkColor($DISP,0x000000)
GUICtrlSetColor($DISP,0xFFFFFF)
$CMDS=GUICtrlCreateInput("commands...",10,720,530,20)
GUICtrlSetBkColor($CMDS,0x000000)
GUICtrlSetColor($CMDS,0xFFFFFF)
$BUTN=GUICtrlCreateButton("Execute",540,720,50,20)
GUICtrlSetBkColor($BUTN,0x000000)
GUICtrlSetColor($BUTN,0x00FF00)
GUISetBkColor(0x000000)
GUISetState()
Global $echo=""
While 1
$guimsg=GUIGetMsg()
Switch $guimsg
Case $GUI_EVENT_CLOSE
quit()
Case $BUTN
StdinWrite($HDL,GUICtrlRead($CMDS)&@CRLF)
EndSwitch
Sleep(1)
$msg=StdoutRead($HDL)
ConsoleWrite($msg&@CRLF)
;~ MsgBox(0,0,$msg)
If $msg <> "" Then
;~ MsgBox(0,"$",S($echo,$msg));;这里就是BUG
$echo=S($echo,$msg);;不管怎样都无效!换成"$echo&=$msg"无效,换成"$echo=$echo&$msg"无效,写成自定义函数无效,用UDF"_StringInsert"还是无效,我是遇到神一样的BUG了么?
;~ MsgBox(0,1,$echo)
_GUICtrlEdit_AppendText($DISP,$msg)
;~ GUICtrlSetData($DISP,$echo)
$msg=""
EndIf
WEnd
Func S($s1,$s2)
Return($s1&$s2)
EndFunc 回复 2# 3mile
能解释一下为什么我那样写不行么? 好像是GUICtrlSetData遇到特殊字符会发生截断 好像是GUICtrlSetData遇到特殊字符会发生截断
lainline 发表于 2011-7-25 21:00 http://www.autoitx.com/images/common/back.gif
楼上正解 学习了,谢谢大家解答啊!
页:
[1]