itljl 发表于 2008-9-28 18:15:09

为什么StdoutRead第一次读取是空白?

下面是帮助的第一次,第一次循环的时候,msgbox显示的是空字符串,第二次才读出来?请教一下能不能第一次就读出来?

; Demonstrates StdoutRead()
#include <Constants.au3>

Local $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Local $line
While 1
    $line = StdoutRead($foo)
    If @error Then ExitLoop
    MsgBox(0, "STDOUT read:", $line)
Wend

顽固不化 发表于 2008-9-28 18:29:22

读取速度大于执行速度,

kakinkgb 发表于 2008-9-28 19:02:22

啊,不要循环读,等他运行完毕,一次就能读出来

itljl 发表于 2008-9-28 19:08:21

各位试验一下,根本不是你们说的那么会事,就算你用runwait

kakinkgb 发表于 2008-9-28 19:50:40

#include <Constants.au3>
$run = Run(@ComSpec & " /c label", @SystemDir, @SW_HIDE,$STDOUT_CHILD)
ProcessWaitClose($run)
$text=StdoutRead($run)
MsgBox(0, "STDOUT read:", $text)

liongodmien 发表于 2008-9-28 21:18:17

原帖由 itljl 于 2008-9-28 19:08 发表 http://www.autoitx.com/images/common/back.gif
各位试验一下,根本不是你们说的那么会事,就算你用runwait

是不能用RunWait()的,要不然就什么都不会回显
页: [1]
查看完整版本: 为什么StdoutRead第一次读取是空白?