Read from the STDIN stream of the AutoIt script process.
ConsoleRead ( [peek = false[, binary = false ]])
|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).|
|Success:||Returns the data read. @extended contains the number of bytes read.|
|Failure:||Sets @error to non-zero if EOF is reached, STDIN is not connected for the process or other error.|
RemarksConsoleRead reads from the console standard input stream of the AutoIt script process, which is normally used by console applications to read input from a parent process.
RelatedConsoleWrite, ConsoleWriteError, Run
; Compile this script to "ConsoleRead.exe".
; Open a command prompt to the directory where ConsoleRead.exe resides.
; Type the following on the command line:
; echo Hello! | ConsoleRead.exe
; When invoked in a console window, the above command echos the text "Hello!"
; but instead of dispalying it, the | tells the console to pipe it to the STDIN stream
; of the ConsoleRead.exe process.
If Not @Compiled Then
MsgBox(0, "", "This script must be compiled in order to properly demonstrate it's functionality.")
$data &= ConsoleRead()
If @error Then ExitLoop
MsgBox(0, "", "Received: " & @CRLF & @CRLF & $data)