Sign in to follow this  
Followers 0
ajenkins

Stdout to ctrledit immediately

5 posts in this topic

I have stdout sent to my edit box, but it shows up after the process is finished. Is there a way to show it during the process? Basically I want a window on my gui showing exactly what the console would if it was running normal. Is there any way to make a running console readout box?

$somefolder = FileSelectFolder("Select Encode Folder", "")

$Afiles = _FileListToArray($somefolder)


for $i = 1 to $Afiles[0]
    $file = $Afiles[$i]
    $CMD = '"' & $ffmpeg & '" -i "' & $file & '" "' & stringtrimright($file , 4) & '_output.mp4"'
Global $stream
$pid = Run(@ComSpec & ' /c "' & $CMD & '"', $somefolder, @SW_SHOW, 0x8)
Do
    Sleep(10)
    $stream &= StdoutRead($pid)
Until @error
GUICtrlSetData($Log, $stream)

GUICtrlSetData($Progress1, ($i/$Afiles[0]) * 100)
Next

Share this post


Link to post
Share on other sites



I have it working some, but when there is a error with one file then the output to my edit box stops scrolling for the rest of the files. can anyone help?

$somefolder = FileSelectFolder("Select Encode Folder", "")
$Afiles = _FileListToArray($somefolder)

for $i = 1 to $Afiles[0]
    $file = $Afiles[$i]
    $CMD = '"' & $ffmpeg & '" -i "' & $file & '" "' & stringtrimright($file , 4) & '_output.mp4"'
Global $stream
$pid = Run(@ComSpec & ' /c "' & $CMD & '"', $somefolder, @SW_SHOW, 0x8)
GUICtrlSetData($Log, "")

Do
    Sleep(500)
    $stream &= StdoutRead($pid)
    GUICtrlSetData($Log, $stream)
    _GUICtrlEdit_SetLimitText($Log, 200)
    _GUICtrlEdit_Scroll($Log, $SB_SCROLLCARET)
Until @error Or Not ProcessExists($pid)

GUICtrlSetData($Progress1, ($i/$Afiles[0]) * 100)
Next

Share this post


Link to post
Share on other sites

What types of errors are halting the script?

Also, what @error condition are you checking for in the Do loop? Because the only error that will find is in the _GUICtrlEdit_Scroll function, and I don't believe that function sets @error.

What is the purpose of the _GUICtrlEdit_SetLimitText in your loop, I don't believe it is necessary.


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

thanks for the help, i set the limit of the edit box, because it seemed to be holding the entire console read, and each file wil run for 14+hours. But if its not needed i will be happy to remove it. From your @error question it seems i don't get the cunstruction of the loop. From the code in the first post i found that simply moving the guictrlsetdata($log,$stream) into the loop made the stdout functio immediately. But i wanted it to scroll like the console does, so i added the editscroll code. It didn't work.with the code anywhere else, can you show me the mistakes so i don't repeat them in the future?

Share this post


Link to post
Share on other sites

This is what I have now, it works. Is there any more mistakes I made?

Func a()

$somefolder = FileSelectFolder("Select Encode Folder", "")
$Afiles = _FileListToArray($somefolder)

for $i = 1 to $Afiles[0]
    $file = $Afiles[$i]
    $pid = Run($ffmpeg & ' -i "' & $file & '" "' & stringtrimright($file , 4) & '_output.mp4"', $somefolder, @SW_SHOW, 0x8)
    $stream = ""
While 1
    Sleep(500)
    $stream &= StdoutRead($pid)
    If @error Then ExitLoop
    GUICtrlSetData($Log,$stream)
    _GUICtrlEdit_Scroll($Log, $SB_SCROLLCARET)
WEnd

GUICtrlSetData($Progress1, ($i/$Afiles[0]) * 100)
Next
EndFunc

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