Jump to content

Reading dos text


 Share

Recommended Posts

THis is my fist day using AutoIt and it is GREAT!! I am wrinting a simple script to run an old dos program. All is working well, except I do not know how, if it is possible, to read the active screen and parse the information read. Any suggestions?

Thanks,

Jerry

Link to comment
Share on other sites

Welcome to the forum.

It really depends on the program. Some are more like a command prompt. Others use graphic interfaces that are hard to read via AutoIt. Here is a sample code to try if your DOS app is more like a cmd window:

;open a hidden 'DOS' window and 'dir' root
$PID = Run(@ComSpec & " /c " & 'dir c:\ /A:H', "", @SW_HIDE, 2)
$Out = ""

While 1
    ;read one line from 'DOS' window
    $line = StdoutRead($PID)
    
    ;exit this loop if it is the last line from that window
    If @error Then ExitLoop
    
    ;look for a string in the current line
    If StringInStr($line, "boot.ini") Then MsgBox(0, "", "Found boot.ini")
    
    ;concatenate all line into one variable
    $Out &= $line
WEnd

MsgBox(0, "", $Out)

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

Link to comment
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
 Share

  • Recently Browsing   0 members

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