Sign in to follow this  
Followers 0
Aassdd

Read text from a dos-like window generated from a C program?

11 posts in this topic

I have a C program and its source (so I know all the vars names). The program does some things and print text on the dos window. How can I read that text?

Share this post


Link to post
Share on other sites



I was just about to post a topic asking the exact same question :)

Can't seem to find anything on it anywhere


Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Look at my Net Send GUI wrapper

http://www.autoitscript.com/forum/index.ph...st&p=343332

#include <Constants.au3>

$computers = ''
    
$foo = Run(@ComSpec & ' /c net view', @ScriptDir, @SW_HIDE, $STDOUT_CHILD)

While 1
    $computers &= StdoutRead($foo)
    If @error Then ExitLoop
WEnd

ConsoleWrite ($computers & @CRLF)

EDIT: added include file

Edited by Zedna

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Let's hope we'll get an answer soon because I need it soon :)

EDIT: Thanks! I'll try it.

How can this help me? :S

Edited by Aassdd

Share this post


Link to post
Share on other sites

Look at my Net Send GUI wrapper

http://www.autoitscript.com/forum/index.ph...st&p=343332

$computers = ''
    
    $foo = Run(@ComSpec & ' /c net view', @ScriptDir, @SW_HIDE, $STDOUT_CHILD)

    While 1
        $computers &= StdoutRead($foo)
        If @error Then ExitLoop
    WEnd

ConsoleWrite ($computers & @CRLF)
Thanks, works perfect :)

Share this post


Link to post
Share on other sites

I want to read that text and write it to a text file, how does that suppose to help me?

Posted Image

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I do but it doesn't print anything in the console

$text = ""
    
    $wnd = Run("C:\Users\Alter\Desktop\**.exe -parameters..", "", @SW_HIDE)

    While 1
        $text &= StdoutRead($wnd)
        If @error Then ExitLoop
    WEnd

ConsoleWrite ($text & @CRLF)

EDIT: Nvm I got it! You really helped me, thanks a million!

Edited by Aassdd

Share this post


Link to post
Share on other sites

I do but it doesn't print anything in the console

$text = ""
    
    $wnd = Run("C:\Users\Alter\Desktop\**.exe -parameters..", "", @SW_HIDE)

    While 1
        $text &= StdoutRead($wnd)
        If @error Then ExitLoop
    WEnd

ConsoleWrite ($text & @CRLF)
What version of AutoIt are you using? There were major changes to StdOutRead() in 3.2.12.1.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I should have used $STDOUT_CHILD

#include <Constants.au3>

$text = ""
    
    $wnd = Run("C:\Users\Alter\Desktop\.., "", @SW_HIDE, $STDOUT_CHILD)

    While 1
        $text &= StdoutRead($wnd)
        If @error Then ExitLoop
    WEnd

ConsoleWrite ($text & @CRLF)
Edited by Aassdd

Share this post


Link to post
Share on other sites

$wnd = Run(@ComSpec & ' /c  your_app.exe -parametres', "C:\Users\Alter\Desktop\", @SW_HIDE, $STDOUT_CHILD)

Look carefully at my previous posts!!! You changed what I posted in Run()

For DOS applications you must use @ComSpec & ' /c to be able to catch it's DOS output.

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
Sign in to follow this  
Followers 0