Sign in to follow this  
Followers 0
arnett

StdOutRead

3 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

The first one is working, the code is big, so I put only part of it here...

Share this post


Link to post
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
Sign in to follow this  
Followers 0