Sign in to follow this  
Followers 0
Skorn

How to manage StdoutRead with slow ouput

5 posts in this topic

#1 ·  Posted (edited)

Hey all,

I made an app which lets you choose a folder and it uses 7-zip to zip it for you. I have set up Stdoutread to read in the stream from the command ouput and send it to my child window. When I test this with a simple command such as "dir c:" it works great because the output is very fast and it's all captured into a single variable. My problem is when using a program like 7-zip that slowly displays the output as you can see in the example below, it ticks through the percentage slowly, it could take several hours to get to 100% on each file. How do I handle capturing this ouput and properly send it to the child window? I basically would like it to look just like it does in DOS, if possible.

.

Creating archive C:\Apps\test\_Zipped\file2013.zip

Compressing  test2 - Copy.vmdk
Compressing  test2.vmdk
Compressing  test2.vmx   11%

.

This is my function, it works great if you tried to zip a very small set of files.. however if the files were large the output would be blank until the process completed after several hours, you do not get to see the number % as is increases so you don't know what the status is or if it is even working at all.

.

Func Zip()
    
    ; Run Zip command
    $cmplevel = GUICtrlRead($iupdown1, 1)       
    $zipCMD = '""c:\Progra~1\7-Zip\7z.exe" a "' & $rootzippedvmfolder & $rootparentfolder & '.zip" -mx' & $cmplevel & ' -tzip -v10g -xr!caches -xr!*.log "' & $rootpath & '"'
    $runZip = Run(@ComSpec & " /c " & $zipCMD, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) ; 

    While 1
        
        ; Read output from program and check for errors
        $runZipSTD = StdoutRead($runZip)
        If @error Then 
            GUICtrlSetData($OutputWin, @CRLF & "Error or End of File:" & @CRLF & StderrRead($runZip) & @CRLF, 1) ; Send error to output window
            ExitLoop
        EndIf
        
        ; Send ouput of program to output window
        GUICtrlSetData($OutputWin, StringStripCR($runZipSTD) & @CRLF, 1)  
        
        ;  Check if zipping is complete (the program will ouptut "Everything is Ok" when it is done) then send message to output window
        If StringInStr($runZipSTD, "Everything is Ok") Then 
            GUICtrlSetData($OutputWin, @CRLF & "Zip Compression Complete" & @CRLF, 1)  
            Exitloop
        EndIf
    Wend
    
EndFunc

Any help is greatly appreciated.

Thanks,

Tim

Edited by Skorn

Share this post


Link to post
Share on other sites



Bump, anyone else have an idea on this problem? thanks

Share this post


Link to post
Share on other sites

Can you please post your GUI code, or a complete reproducer, so we can properly test rather than having to build around your snippet?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

You'd probably get more responses if you posted a working script.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

this is strange (and interesting at the same time)

it seems that 7z.exe is able to write the output to the DOS screen without using the stdout.
it only sends the whole output, at once to stdout when it has finished the job

there should be a way to grab the output directly from the DOS screen buffer instead of  from stdout, (but I do not know how :think:)


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
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
Sign in to follow this  
Followers 0