Search code examples
pythonbashdosdosbox

Automating DOSbox application


I have a very old DOS application which I would like to automate. Like there are keypresses and such which if automated will help a lot as I might have to run the program over a hundred times manually.

My question seems to be very similar to this one but the solutions offered there are not very useful for me, plus it is over nine years old

Automating old DOS application using Python

Only big difference between this question and mine is that I have no option other than DOSbox for doing this. This application is set up on a lot of computers, and all the people using the application know how to use DOSBox. Migrating to Virtualbox would be a pain and very time-consuming.

I was thinking maybe if I could mechanize this somehow in python using xautomaton or uinput, but I haven't been able to figure out exactly how. The application will be running on Ubuntu primarily.

To give an idea of the application, I am attaching a screenshot:

Screenshot

The solution does not necessarily need to be in python. Any other language would work. Any help is appreciated.


Solution

  • I figured this out. Although this does not use python, to do this, I just captured the windowid of DOSbox and sent all the key presses there using xdotool. Here is an example:

    wid=$(xdotool search --class DOSbox)
    xdotool key --window $wid m t 5 Return Return i
    

    Which will type "mt5", then press enter twice and then type "i"

    The series of keypresses can be stored in a string or a file and called iteratively each time this has to be run. If there is a better method to do this, please feel free to answer.