zagaris123 Posted September 2, 2016 Share Posted September 2, 2016 Hey Guys, I try to read the last row from a cmd window. If the last row coincide with the preset, the cmd window should be closed. I tried with the help file and googled also but I cant find what I need. Sorry for my very bad english. Please help me =) My english is too bad to find the solution by myself. Greez and Thanks alot. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 2, 2016 Moderators Share Posted September 2, 2016 @zegaris123, try something like this: #include <Constants.au3> $net = Run(@ComSpec & " /c ipconfig /all", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($net) If @error Then ExitLoop ElseIf $line <> "" Then ConsoleWrite("STDOUT read:" & $line & @CRLF) EndIf Wend You should be able to modify it easily to capture the line you're after zagaris123 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
zagaris123 Posted September 2, 2016 Author Share Posted September 2, 2016 your script works nice but I cant change it for my purpose. I have a cmd window with title "cmd1". And the last row in this cmd window is "press any key". Once this line appears, the window should be closed. Sorry for this annoying question. Link to comment Share on other sites More sharing options...
Developers Jos Posted September 2, 2016 Developers Share Posted September 2, 2016 3 minutes ago, zagaris123 said: but I cant change it for my purpose. Why not? What is the problem? 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...
zagaris123 Posted September 2, 2016 Author Share Posted September 2, 2016 I dont understand the code. I never worked with StdoutRead etc. And my english is bad too. If I have the right code for my problem I can watch it and learn from it. Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 2, 2016 Moderators Share Posted September 2, 2016 Just now, zagaris123 said: I dont understand the code. I never worked with StdoutRead etc. And my english is bad too. If I have the right code for my problem I can watch it and learn from it. You need to do some reading in the help file then. This is not a forum where you're spoon-fed code; it is meant to be a place where you receive help to better your scripting skills. "I don't understand it" and "I've never done this before" excuses really don't fly. If you just want someone to do it for you, head over to Rent-a-Coder.com and pay someone to do it for you. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Developers Jos Posted September 2, 2016 Developers Share Posted September 2, 2016 Then you have the opportunity to learn both English and what the script does. Have you tried it with your command to see what it does? Jos 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...
ModemJunki Posted September 13, 2016 Share Posted September 13, 2016 On 9/2/2016 at 11:05 AM, JLogan3o13 said: @zegaris123, try something like this: #include <Constants.au3> $net = Run(@ComSpec & " /c ipconfig /all", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($net) If @error Then ExitLoop ElseIf $line <> "" Then ConsoleWrite("STDOUT read:" & $line & @CRLF) EndIf Wend You should be able to modify it easily to capture the line you're after This will work if you are allowing AutoIT to create your cmd1 window. If the cmd1 window is running and AutoIT code is separate it cannot "see" the console text. So, if your cmd window is running and you try to see what is going on in the window with the AutoIT Window Info Tool, for example, you will see no text. If you can launch whatever is creating the window with the Run command you should be able to capture the needed text and act on it. I hope this helps. Always carry a towel. 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