zagaris123

Read last row in CMD Window.. Need Help

8 posts in this topic

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.

Share this post


Link to post
Share on other sites



@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

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites

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.

 

Share this post


Link to post
Share on other sites
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.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

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

 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
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.

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