kid1232 Posted December 24, 2018 Share Posted December 24, 2018 Hi everyone. First, thank you for read my question. My English is bad, to I hope you can understand my problem I have a small project, there are some Run command and get response back. (adb and fastboot command) Now I am using this script to do my work $DOS = Run(@ScriptDir & "\Tools\" & $Command, @ScriptDir & "\Tools\", @SW_HIDE, 0x8) // $STDERR_MERGED While 1 Sleep(50) $Message &= StdoutRead($DOS) If @error Then ExitLoop WEnd It still work, but I thinking about performance. I think I will find other way to run from one CMD process only (Old solution open an cmd process when 1 command run) So I try this way (my friend help me) #include <AutoItConstants.au3> Global $iPID Example() Func Example() $iPID = Run(@ComSpec, @SystemDir, @SW_MINIMIZE, $STDIN_CHILD + $STDERR_MERGED) Local $input = "" While True $input = InputBox("Send", "Command") If @error == 1 Or Not ProcessExists($iPID) Then ExitLoop _writeCommand($iPID, $input) _checkStd() WEnd EndFunc ;==>Example Func _checkStd() Sleep(100) Local $sOutput = "" While 1 $sOutput = StdoutRead($iPID) If @error Then ExitLoop ElseIf $sOutput Then ConsoleWrite('Stdout: ' & $sOutput & @CRLF) EndIf WEnd EndFunc ;==>_checkStd Func _writeCommand($pid, $commands) StdinWrite($pid, $commands & @CRLF) EndFunc ;==>_writeCommand But there is a bigger bug: Script can not detect when command return finish or not to continue next command And I have an idea but still not know how to solve it: StdoutRead only return when command finish. Some command need about 60secs to finish but response every second, i want it can return every second or anything like that Thank you for read my post! Link to comment Share on other sites More sharing options...
Developers Jos Posted December 24, 2018 Developers Share Posted December 24, 2018 Moved to the appropriate forum. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
water Posted December 24, 2018 Share Posted December 24, 2018 If performance is an issue then please check the help file for StdOutRead. The example waits until the process started by Run has ended and then reads StdOut with a single statement. That's as fast as possible kid1232 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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