Jump to content

Recommended Posts

Posted

Hi,

I scripted a GUI for a DOS-app which collects some parameters and starts the app.

This app works for several minutes and has a screen output of the percentage that is done.

I didn't manage to read this output. But I think it isnt's a standard output because on commandline the redirection with > file.txt won't work, too.

Here a simple version of the script I use

$var = Run(@Comspec & " /c ...", "" , @SW_HIDE, 2+4)
$s_Msg = ""
$s_Err = ""
While 1
$s_Msg &= StdoutRead($var)
If @error Then ExitLoop
$s_Err &= StdoutRead($var)
If @error Then ExitLoop
Wend
MsgBox(0, "Stdout:", $s_Msg)
MsgBox(0, "Stderr:", $s_Err)

The msgboxes will show the correct ouput but not until all is done :whistle:

Is is it possible to get the ouput in real-time?

Thx in advance!

Regards,

Buffo

Posted

if you use an IDE editor that has console output like SciTE then you can do the following with out having to hit ok on the msgbox every iteration of the loop

#include <Constants.au3>

$var = Run(@Comspec & " /c dir c:\*.*", "" , @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
$s_Msg = ""
$s_Err = ""
While 1
    $line = StdoutRead($var)
    If @error Then ExitLoop
    ConsoleWrite("StdoutRead: " & $line & @LF)
    $s_Msg &= $line
WEnd


While 1
    $line = StderrRead($var)
    If @error Then ExitLoop
    ConsoleWrite("StderrRead: " & $line & @LF)
    $s_Err &= $line
Wend
MsgBox(0, "Stdout:", $s_Msg)
MsgBox(0, "Stderr:", $s_Err)

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Posted

Yes, I use Scite and I even tried to write to console but nothing happens :whistle:

I tried different "count" parameters in the StdOutRead And StdOutErr statements and I set "Peek" to true but nothing will work.

Nearly half of the output will be the StdOutRead, the remaining half will be StdOurErr (but only after it's done...)

Any ideas?

Thx a lot.

Regards,

Buffo

Posted

Yes, I use Scite and I even tried to write to console but nothing happens :whistle:

I tried different "count" parameters in the StdOutRead And StdOutErr statements and I set "Peek" to true but nothing will work.

Nearly half of the output will be the StdOutRead, the remaining half will be StdOurErr (but only after it's done...)

Any ideas?

You may try my workaround for this problem here: http://www.autoitscript.com/forum/index.php?showtopic=22224

This is not perfect, but did the job.

Posted (edited)

Thx for your reply :whistle:

At once I tried out your workaround but it didn't work, too ;)

This test code I used:

$app = _DConsoleRun(@Comspec & ' /c app.exe')
While ProcessExists($app)
ConsoleWrite(_DConsoleRead() & @LF)
WEnd
_DConsoleFree()

But nothing is written in console. Any ideas?

Regards,

Buffo

Edited by Buffo
Posted

Thx for your reply :whistle:

At once I tried out your workaround but it didn't work, too ;)

But nothing is written in console. Any ideas?

Regards,

Buffo

Try to run script without redirecting output to Scite (just run from explorer), and don't use ConsoleWrite. Like this:

$app = _DConsoleRun(@Comspec & ' /c app.exe')
While ProcessExists($app)
  MsgBox (0, "title", _DConsoleRead())
WEnd
_DConsoleFree()
Posted

@gafrost: Thx for your efforts :whistle: It's a pity you couldn't help ;)

Is there any one who has more experience and could help me? Please get in touch with me. Thx a lot!

Regards,

Buffo

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
×
×
  • Create New...