Jump to content

StdOutRead


arnett
 Share

Recommended Posts

This code prints the output right (the second MessageBox):

Run("python GetText.py", "", "", $STDOUT_CHILD)
$line = StdoutRead($PID)
MsgBox(0, "", "")
$line2 = StdoutRead($PID)
MsgBox(0, "Debug223132", $line2)

But this doesnt:

Run("python GetText.py", "", "", $STDOUT_CHILD)
;$line = StdoutRead($PID)
MsgBox(0, "", "")
$line2 = StdoutRead($PID)
MsgBox(0, "Debug223132", $line2)

Can anyone please tell me why?

Arnett.

Link to comment
Share on other sites

I bet the first one does not work too, because you're missing to define $PID. If you had done this, the first one would work because the first msgbox adds a delay to the execution and the result is available on the second call. Without the msgbox there seems to be not enough time that the stdout buffer has been filled by the executable. Stick to the examples in the help-file and do a loop. "StdoutRead sets @error to non-zero if EOF is reached", means the process has finished flushing data to stdout.

#include <CONSTANTS.AU3>
$iPID = Run("python GetText.py", "", "", $STDOUT_CHILD)
Local $line, $timer = TimerInit() 
While 1 
$line = StdoutRead($iPID) 
If @error Then ExitLoop 
if TimerDiff($timer) > 5000 Then ExitLoop ; timeout Wend 
MsgBox(0, "STDOUT read:", $line)
Edited by KaFu
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...