Jump to content

Recommended Posts

Posted

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.

  • Moderators
Posted

@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

"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!

Posted

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.

 

Posted

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.

 

  • Moderators
Posted
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!

  • 2 weeks later...
Posted
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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...