crazycrash Posted May 10, 2018 Share Posted May 10, 2018 Hi I am trying to read the comandline output of a exe so I can execute certain other tasks depending on the output read. However I can't get the stream during execution / I only get it when the started exe is terminated. Is there any way to capture the output while the program is running? Just like it is displayed in the cmd window? Thanks! #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> #RequireAdmin Local $consoleOutputHandle = Run(@ScriptDir & "/test.exe", @ScriptDir, @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) Local $consoleContent Sleep(5000) For $i = 1 To 10 ;Miniloop just to test - Messagebox only returns content wen test.exe is terminated ;$consoleContent &= StdoutRead($consoleOutputHandle, false, false) MsgBox(0,"",StdoutRead($consoleOutputHandle, False, False)) Sleep(1000) Next Link to comment Share on other sites More sharing options...
JohnOne Posted May 10, 2018 Share Posted May 10, 2018 Difficult to say without knowing more about test.exe why Sleep(5000)? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Subz Posted May 10, 2018 Share Posted May 10, 2018 Example #include <AutoItConstants.au3> Local $sContent = "" Local $hPID = Run(@ComSpec & " /c @Echo Off & For /L %x In (1, 1, 1000000) Do Echo %x", "", @SW_SHOW, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sContent = StdoutRead($hPID) If @error Then ExitLoop If StringStripWS($sContent, 8) = "" Then ContinueLoop ConsoleWrite(StringReplace($sContent, @CRLF, "") & @CRLF) WEnd Link to comment Share on other sites More sharing options...
crazycrash Posted May 10, 2018 Author Share Posted May 10, 2018 Thanks, it seems it has to do with the exe then. The exe is a cc miner which can be found here: https://github.com/fireice-uk/xmr-stak/releases Any tips on how to capture the output whilst it is running would be great. StdoutRead($hPID) Only gives me a result with the entire console output if I terminate xmr-stak.exe. During execution it comes back empty. However I need autoit to control it during runtime. Cheers Link to comment Share on other sites More sharing options...
crazycrash Posted May 11, 2018 Author Share Posted May 11, 2018 Found the issue, it was indeed with the exe, the stdout was buffered, changed that and it works just fine. Cheers 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