Sign in to follow this  
Followers 0
shein

Wrapper around DOS .exe

4 posts in this topic

Hello,

I have an old DOS executable which operates in a 80x24 character window using only text (let's call it "blackbox"). The input consists of single characters at a time, such as "1" to select the first option on a menu, "AK6[return]" as an input string etc. There is no mouse input. The output is not in any sequential form but contains text as well as codes for jumping to a certain screen location etc. I don't have the source code of blackbox.

I want to write a wrapper which invokes the DOS executable for a large number of different inputs and then captures the output automatically for each input. I can see how to feed the input to blackbox using AutoIt, but I don't see any way to read the characters in a specific place on the output screen. The closest I see is a function to read the value of an individual pixel, but it seems overkill to try to reconstruct text from that :-)

I'm not sure that AutoIt can do what I need. I've read the documentation so I hope you don't mind my asking. Any ideas (ideally a sample script)? If AutoIt can't do it, can you think of a tool that can? I've already tried perl and the Term::VT102 module, but blackbox doesn't respect the Unix stdin/stdout model, so that doesn't work.

Thanks,

Soren

Share this post


Link to post
Share on other sites



Hello,

I have an old DOS executable which operates in a 80x24 character window using only text (let's call it "blackbox"). The input consists of single characters at a time, such as "1" to select the first option on a menu, "AK6[return]" as an input string etc. There is no mouse input. The output is not in any sequential form but contains text as well as codes for jumping to a certain screen location etc. I don't have the source code of blackbox.

I want to write a wrapper which invokes the DOS executable for a large number of different inputs and then captures the output automatically for each input. I can see how to feed the input to blackbox using AutoIt, but I don't see any way to read the characters in a specific place on the output screen. The closest I see is a function to read the value of an individual pixel, but it seems overkill to try to reconstruct text from that :-)

I'm not sure that AutoIt can do what I need. I've read the documentation so I hope you don't mind my asking. Any ideas (ideally a sample script)? If AutoIt can't do it, can you think of a tool that can? I've already tried perl and the Term::VT102 module, but blackbox doesn't respect the Unix stdin/stdout model, so that doesn't work.

Thanks,

Soren

One way you could do it is to Send Alt SPACE E S to select all the text, then SEND Alt E y to copy the text to the clipboard.

Then in your script you can set this text to a variable using ClipGet, convert the variable to an array using stringsplit, pad each element of the array to 80 characters as needed with spaces and you have a representation of the screen in your array.

So then the characters on line 5 at positions 40 to 45 are StringMid($screenArray[5],39,5).


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

This works only on english locale. In german, it would be: Send Alt SPACE B A (Bearbeiten, Alles markieren).

SEND Alt E y is not neccessary. A simple ENTER does the job.

Here a running script to show language independent usage:

Opt("WinTitleMatchMode", 4)
HotKeySet("{F2}", "StartCMDwindow")
Func StartCMDwindow()
    $cmd = "set /P answer=are you ready to clone the database? Enter Y or N"
    Run(@ComSpec & " /c " & $cmd, "", @SW_SHOW)
EndFunc   ;==>StartCMDwindow

While 1
    If WinWaitActive("[CLASS:ConsoleWindowClass]", "", 1) Then ExitLoop
    MsgBox(0, "", "Press F2 to start CMD window", 3)
WEnd
Send("!{space}{down 6}{right}{down 3}{enter 2}")
MsgBox(0, "", ClipGet())
Thanks Hubertus72 that is much better. I forgot Enter would do the job, and I didn't think about language differences :P

This doesn't work with all DOS programs. I tried and old Borland C compiler and the send sequence activates the program's menu not the console window's menu. So in this case it is necessary to right click on the title bar instead, and then send {down 7} instead of {down 6}.


Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

Thanks both. The basic idea works very well. I'm still working on making my loop as robust as possible -- sometimes the DOS executable takes a while to produce its result, and the screen may look different depending on the state of the calculations. I've not found anything better than Sleep()ing for 1000 milliseconds at a time and then checking the state of the DOS window.

Thanks again,

Soren

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