happyuser Posted November 7, 2008 Share Posted November 7, 2008 (edited) Hello I have tried AUTOIT to implement an interface for users of a computing task. I would like to include a progress bar into the interface but I need communicating with the .exe child of my GUI. I have tried to make it write some char to STDOUT and to get them back. I get nothing when reading $STDOUT_CHID. Could you give me some advice or a sample code? Here is what I have programmed : Run("myexe.exe","",@SW_HIDE,2) $m="" while stringlen($m)<5 $m=$m&FileRead($stdout_child,1) WEnd msgbox(0,"",$m) My programm seems to never end. Thank you in advance Edited November 9, 2008 by happyuser Link to comment Share on other sites More sharing options...
Valuater Posted November 7, 2008 Share Posted November 7, 2008 $m="" while stringlen($m)<5 *************** will run forever you want to read or write??? example from help ; Demonstrates StdoutRead() #include <Constants.au3> Local $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $line While 1 $line = StdoutRead($foo) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) Wend While 1 $line = StderrRead($foo) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) Wend MsgBox(0, "Debug", "Exiting...") 8) Link to comment Share on other sites More sharing options...
happyuser Posted November 7, 2008 Author Share Posted November 7, 2008 Thanks Valuater, I have stepped forward a great step. I now know the syntax of StdOutRead. Nevertheless, I cannot realize what I need i.e. a progress bar that will indicate the percentage an external task has achieved. Let me explain : I launch an external task with function "run". I then poll stdout to catch the output of my task (numbers progressing from 1 to 20 every 1/10th of second). I expected that the progress bar included in GUI would follow the progress of the external task. I choose option peek for StdOutRead not to wait for a char in the buffer. Nothing happen until the task is over. At that moment, the bar shows a positive value and the state no longer evoluates. Here is my code : Local $Button_1, $msg GUICreate("My GUI Button") $Button_1 = GUICtrlCreateButton("Run .EXE", 10, 30, 100) $prg=GUICtrlCreateProgress(10,60,200,20) $in=GUICtrlCreateInput("",10,90,200,20) GUISetState() $tst=0 While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 $tst=Run('test.exe','',0,$STDOUT_CHILD) EndSelect if $tst<>0 Then $line = StdoutRead($tst,-1,1) $n=stringlen($line) GUICtrlSetData($prg,$n) GUICtrlSetData($in,$line) EndIf WEnd EndFunc Where do I get stuck during execution of the external task? Thank you for advices. Link to comment Share on other sites More sharing options...
Valuater Posted November 7, 2008 Share Posted November 7, 2008 Where do I get stuck during execution of the external task?Thank you for advices.AFAIK... that's the way it is, it reports back at the "end" of the process8) Link to comment Share on other sites More sharing options...
happyuser Posted November 8, 2008 Author Share Posted November 8, 2008 If I understand well what is said in help file, it should work the way I need, the external task running while its output is monitored by the parent script. Let's read the article relative to StdOutRead :"If StdoutRead is called with a third argument other than zero, StdoutRead will "peek at" the stream rather than actually reading from it, and return the characters that could be read from the stream. When run as a "peek" StdoutRead always returns immediately. Note that any characters are still present on the stream after a peek and will be returned on the next read operation."While waiting for a message from my window, the script should query for output from child allowing to check the progress through periodic output.Would you agree or what did I miss? Link to comment Share on other sites More sharing options...
Valuater Posted November 8, 2008 Share Posted November 8, 2008 I did a search and found some more info...http://www.autoitscript.com/forum/index.ph...st&p=311874http://www.autoitscript.com/forum/index.ph...st&p=596993http://www.autoitscript.com/forum/index.ph...st&p=516178http://www.autoitscript.com/forum/index.ph...st&p=178172Those were some of the best onesgood luck8) Link to comment Share on other sites More sharing options...
happyuser Posted November 8, 2008 Author Share Posted November 8, 2008 (edited) Tank you I check all those ref A day later.. I found that data coming from console output if buffered and delivered by StdoutRead when buffer is full. My task was not enough verbose to fill the buffer and nothing happened til end of task. I have formatted every output of the task in order to fill the buffer (255 char). Now every output triggers the read and the progress bar runs smoothly from 0% to 100%. Edited November 9, 2008 by happyuser 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