Sign in to follow this  
Followers 0
CyRus@Home

How to run a dos-prog and read text from cmd-window

7 posts in this topic

#1 ·  Posted (edited)

Hi,

i am a newbie in programming autoit. I want to program a script that opens a dos-program from a CD, the dosprogram waits for entering data,after pressing enter, the program will response with data, now autoit should filter that Data (i need only some Letters of the responsed Letters) and send it to a Infobox in windows (or anything similar) to read this code.

Could please someone tell me how to do that ?

UPDATE :

Now i'm able to open the program with this script :

$drive = StringMid(@ScriptDir,1,1)

Run($drive & ":\start.exe")

But what do i have to do, to read the text which is displayed in the dos window,and show this seperately in a Windows MsgBox.

Thanks in advance

CyRus

Edited by CyRus@Home

Share this post


Link to post
Share on other sites



Hi,

i am a newbie in programming autoit. I want to program a script that opens a dos-program from a CD, the dosprogram waits for entering data,after pressing enter, the program will response with data, now autoit should filter that Data (i need only some Letters of the responsed Letters) and send it to a Infobox in windows (or anything similar) to read this code.

Could please someone tell me how to do that ?

UPDATE :

Now i'm able to open the program with this script :

$drive = StringMid(@ScriptDir,1,1)

Run($drive & ":\start.exe")

But what do i have to do, to read the text which is displayed in the dos window,and show this seperately in a Windows MsgBox.

Thanks in advance

CyRus

Don't know if "WinGetText()" works on a dos window, but it's worth a shot

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

I think i'm not finished yet, what's wrong with this code ?

#include <Constants.au3>

Dim $text

$drive = StringMid(@ScriptDir,1,1)

$stream = RunWait($drive & ":\data.exe")

While 1

$textline = StdoutRead($stream)

$text = $text & @CRLF & $textline

If @error Then ExitLoop

Wend

MsgBox(0, "your data is", $text)

The Dos-Program waits for entering my Data,but after pressing enter,the MsgBox opens with no text in it.

Edited by CyRus@Home

Share this post


Link to post
Share on other sites

I think i'm not finished yet, what's wrong with this code ?

#include <Constants.au3>

Dim $text

$drive = StringMid(@ScriptDir,1,1)

$stream = RunWait($drive & ":\data.exe")

While 1

$textline = StdoutRead($stream)

$text = $text & @CRLF & $textline

If @error Then ExitLoop

Wend

MsgBox(0, "your data is", $text)

The Dos-Program waits for entering my Data,but after pressing enter,the MsgBox opens with no text in it.

StdoutRead requires the PID of the process it is to work with

StdoutRead ( process_id[, count[, peek = false]] )

Run will return the PID... RunWait does not

Run ( "filename" [, "workingdir" [, flag[, standard_i/o_flag]]] )


[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

StdoutRead requires the PID of the process it is to work with

StdoutRead ( process_id[, count[, peek = false]] )

Run will return the PID... RunWait does not

Run ( "filename" [, "workingdir" [, flag[, standard_i/o_flag]]] )

mmmhhh, and how do i solve this problem ?

If i try it with the standard run-function, autoit waits not for entering data ?!

Share this post


Link to post
Share on other sites

mmmhhh, and how do i solve this problem ?

If i try it with the standard run-function, autoit waits not for entering data ?!

I'm probably not the best person to advise you on this function as I've only worked with it once or twice. Here is a little sample from one script where I "read" the output of the process and let AutoIt make the input for me.

While 1
    $CMDoutput &= StdoutRead($ProcessID)
    If StringInStr($CMDoutput, "HIT ENTER TO CONTINUE") Then
        StdinWrite($ProcessID, "{ENTER}")
        $CMDoutput = ""
        ExitLoop
    EndIf
    Sleep(10)
WEnd
maybe an input box would work for you

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I'm probably not the best person to advise you on this function as I've only worked with it once or twice. Here is a little sample from one script where I "read" the output of the process and let AutoIt make the input for me.

While 1
    $CMDoutput &= StdoutRead($ProcessID)
    If StringInStr($CMDoutput, "HIT ENTER TO CONTINUE") Then
        StdinWrite($ProcessID, "{ENTER}")
        $CMDoutput = ""
        ExitLoop
    EndIf
    Sleep(10)
WEnd
maybe an input box would work for you
I have no clue how to do that,sorry :P

Who can help me ?? :)

Edited by CyRus@Home

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