qwer85 Posted September 26, 2007 Posted September 26, 2007 (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 September 26, 2007 by qwer85
weaponx Posted September 26, 2007 Posted September 26, 2007 (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 September 26, 2007 by weaponx
jvanegmond Posted September 26, 2007 Posted September 26, 2007 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. github.com/jvanegmond
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