ParoXsitiC Posted July 13, 2010 Share Posted July 13, 2010 (edited) I have an old UDF in which he uses the following if statement:Case ProcessExists($iPID) == 0 If StdoutRead($iPID, 0, True) <> 0 Then Return "returned" Else Return "dead" EndIfIt applied back when the help file read this about it StdoutRead:Function ReferenceStdoutRead --------------------------------------------------------------------------------Reads in a number of characters from the STDOUT stream of a previously run child process.StdoutRead ( process_id[, count[, peek = false]] )Parametersprocess_id The process ID of a child process, as returned by a previous call to Run. count The number of characters to read. peek If true the function does not remove the read characters from the stream. Return ValueSuccess: Returns a string of the characters read. Failure: Sets @error to non-zero if EOF is reached, STDOUT was not redirected for the process or other error. RemarksStdoutRead 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 STDOUT flag value (2) for this function to work properly (see the Run function).The optional second parameter tells StdoutRead to read count characters from the stream. If fewer than count characters are available, StdoutRead returns a string of all the characters that are available at that time. If the function is called with no second argument or a second argument of less than zero, StdoutRead assumes you that you wish to read the maximum number of characters and returns a string of all the characters that are available (up to 64kb in a single read).If at any time when this function is called (except for "peeking" as described below) there are no characters to be read from the stream, the StdoutRead function will block (pause) and not return until there are characters to be read from the stream. This means that the AutoIt process will be halted, and there will be no processing of hotkeys, GUI messages, etc. until the child process writes something to the STDOUT stream.If StdoutRead is called with a third argument other than zero, StdoutRead will "peek at" the stream rather than actually reading from it, and return the characters that could be read from the stream. When run as a "peek" StdoutRead always returns immediately. Note that any characters are still present on the stream after a peek and will be returned on the next read operation.When called with a second argument of 0 and a third argument that directs the function to "peek", StdoutRead returns a numeric value of the number of characters that could currently be read from the stream.Streams of child processes run with RunAsSet cannot be read from at this time.-----------------------How can I update the if statement to function exactly the same? Edited July 13, 2010 by ParoXsitiC Link to comment Share on other sites More sharing options...
ParoXsitiC Posted July 13, 2010 Author Share Posted July 13, 2010 (edited) I gonna assume this, until someone tells me no: Case ProcessExists($iPID) == 0 StdoutRead($iPID, true) $StdoutReadIsDone = @error If $StdoutReadIsDone == 0 Then Return "returned" Else Return "dead" EndIf Edited July 13, 2010 by ParoXsitiC Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now