Reads from the STDOUT stream of a previously run child process.
StdoutRead ( process_id[, peek = false[, binary = false]] )
Parameters
| process_id | The process ID of a child process, as returned by a previous call to Run. |
| peek | [optional] If true the function does not remove the read characters from the stream. |
| binary | [optional] If true the function reads the data as binary instead of text (default is text). |
Return Value
| Success: | Returns the data read. @extended contains the number of bytes read. |
| Failure: | Sets @error to non-zero if EOF is reached, STDOUT was not redirected for the process or other error. |
Remarks
StdoutRead reads from the console standard output stream of a child process, which is normally used by console applications to write to the screen. During the call to Run for the child process you wish to read from the STD I/O parameter must have included the value of $STDOUT_CHILD (2) for this function to work properly (see the Run function).
Related
StderrRead, StdinWrite, StdioClose, Run, RunAs
Example
; 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
While 1
$line = StderrRead($foo)
If @error Then ExitLoop
MsgBox(0, "STDERR read:", $line)
Wend
MsgBox(0, "Debug", "Exiting...")