Sign in to follow this  
Followers 0
qwer85

StdoutRead problem...

3 posts in this topic

#1 ·  Posted (edited)

Why my script doesn't work?

#include <Constants.au3>
#include <GUIConstants.au3>

GUICreate("CMD Console", 400, 400)
GUISetState(@SW_SHOW)
$myedit=GUICtrlCreateEdit ("", 10, 10, 380, 380)

$var = Run("cmd", "c:", @SW_HIDE, 2)

While 1
    $line = StdoutRead($var)
    If @error Then ExitLoop     ; This line doesn't function. Why?
    GUICtrlSetData($myedit, $line & @CRLF)
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
    Sleep(100)
Wend

ProcessClose("cmd.exe")
Edited by qwer85

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe...

#include <Constants.au3>
#include <GUIConstants.au3>

GUICreate("CMD Console", 400, 400)
GUISetState(@SW_SHOW)
$myedit = GUICtrlCreateEdit ("", 10, 10, 380, 380)

$var = Run("cmd", "c:", @SW_HIDE, 2)

Sleep(500)
$line = StdoutRead($var)
If @error Then MsgBox(0,"","ERROR")    ; This line doesn't function. Why?
GUICtrlSetData($myedit, $line & @CRLF)
ProcessClose("cmd.exe")

While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Edited by weaponx

Share this post


Link to post
Share on other sites

qwer85, StdoutRead will not set an error flag until the cmd.exe proces has been ended. Currently in your script, the cmd.exe keeps running forever. When you close cmd.exe through task manager you see that your GUI will close and your script will exit. :)

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