Jump to content

StdoutRead not working for me


Recommended Posts

Hello

i am trying to run image magick then get the result of the compare process 

 

#include <AutoItConstants.au3>
#include <Array.au3>

; Compare
$iPID = Run("magick compare -metric RMSE 1.jpg 2.jpg NULL:","", @SW_SHOW, $STDOUT_CHILD)

; Wait until the process has closed using the PID returned by Run.
ProcessWaitClose($iPID)

; Read the Stdout stream
$ScreenOutput = StdoutRead($iPID)

MsgBox(0,0,$ScreenOutput)

 

i have 2 questions:

1- why the console (logs) is always writing the result even that i didn't used  console write function 

2- why msg box is empty ? 

Edited by fraizor
Link to comment
Share on other sites

Please provide more information:

  • Post the output you get when you run "magick" in a DOS window
  • @SW_SHOW isn't a valid flag  for the Run statement
  • Check for error after each function. Run sets @error
  •  Check the length of $ScreenOutput using StringLen to make sure the string is empty

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Hello

thank you for fast response 

1- 

image.png.b89576d7c6b1c7ca2d11505883daf050.png

 

2- Okay what i should use ? i don't really care if it is showed or hidden 

 

3- sorry i don't know how to do that .. can you please edit my example to teach me how ? 

 

4- string len returns 0

Link to comment
Share on other sites

52 minutes ago, water said:

Please provide more information:

  • Post the output you get when you run "magick" in a DOS window
  • @SW_SHOW isn't a valid flag  for the Run statement
  • Check for error after each function. Run sets @error
  •  Check the length of $ScreenOutput using StringLen to make sure the string is empty

Actually the strange thing that it is working but in an unexpected way !

 

it is showing the correct output in the console , but not showing in msgbox ! 

image.thumb.png.350883d2a266e1908f0a8d5d46c8b61e.png

 

Link to comment
Share on other sites

Modified Script: 

#include <AutoItConstants.au3>

; Compare
Global $iPID = Run("magick compare -metric RMSE 1.jpg 2.jpg NULL:", "", Default, $STDOUT_CHILD)
If $iPID = 0 Then Exit ConsoleWrite("Error running Magick! @error=" & @error & ", @extended=" & @extended & @CRLF)

; Wait until the process has closed using the PID returned by Run.
Global $iWait = ProcessWaitClose($iPID)
If $iWait = 0 Then Exit ConsoleWrite("Error returned by ProcessWaitClose! @error=" & @error & ", @extended=" & @extended & @CRLF)

; Read the Stdout stream
Global $sScreenOutput = StdoutRead($iPID)
If @error Then Exit ConsoleWrite("Error returned by StdOutRead! @error=" & @error & ", @extended=" & @extended & @CRLF)

MsgBox(0, 0, $sScreenOutput)

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

4 minutes ago, water said:

Modified Script: 

#include <AutoItConstants.au3>

; Compare
Global $iPID = Run("magick compare -metric RMSE 1.jpg 2.jpg NULL:", "", Default, $STDOUT_CHILD)
If $iPID = 0 Then Exit ConsoleWrite("Error running Magick! @error=" & @error & ", @extended=" & @extended & @CRLF)

; Wait until the process has closed using the PID returned by Run.
Global $iWait = ProcessWaitClose($iPID)
If $iWait = 0 Then Exit ConsoleWrite("Error returned by ProcessWaitClose! @error=" & @error & ", @extended=" & @extended & @CRLF)

; Read the Stdout stream
Global $sScreenOutput = StdoutRead($iPID)
If @error Then Exit ConsoleWrite("Error returned by StdOutRead! @error=" & @error & ", @extended=" & @extended & @CRLF)

MsgBox(0, 0, $sScreenOutput)

 

Thank you @water

 

actually now i get the issue 

 

for some reason the imagemagick is returning the result in form of error ! 

 

image.thumb.png.48968f1eee14558f226f5f819f6af46e.png

 

 

even in CMD i tried to write the output to a file but it have me empty file , when i write the error to a file it will show the result there in output.err
image.png.830db5d3ee87d1cf99d36418dd2c6f0a.png
 

Link to comment
Share on other sites

Replace $STDOUT_CHILD with $STDERR_MERGED to get both streams when you read Stdout.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

:) 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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...