joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.81k stars 383 forks source link

Read screen content, RAM content, device statuses, send keystrokes and mousemoves to DOSBox-X #2085

Open frank-deng opened 3 years ago

frank-deng commented 3 years ago

Is it possible to read screen, RAM, device status in real-time from DOSBox-X, as well as sending key strokes, mouse moves, joystick actions, etc. to DOSBox-X? And is it appropriate to add a websocket-based interface so as to accomplish them in a more convenient way?

Maybe such feature could be used for automation, usage analysis, etc. For example, playing 2048 game automatically by reading the screen to get the distribution of the numbers, then send keystroke to make the appropriate move; Or read the screen in real-time for usage analysis.

joncampbell123 commented 3 years ago

How about through a named pipe instead?

It would mean connecting to a named pipe and sending/receiving text commands to direct DOSBox-X and read data.

Something like named pipe for datagrams on Windows (like \\pipe\dosbox-x-session) or a Unix domain (AF_UNIX) datagram socket on Linux with a name in the filesystem like ./session.The name would be specified on the command line, of course.

It would allow a means of remote control (from another process on the same machine) that is also unlikely to scare Windows Firewall into asking the user if they want to accept local loopback connections every time DOSBox-X is run :)

JoeC4281 commented 3 years ago

Yes, a named pipe would be great.

I've been communicating from TCC to 4DOS on DosBox-X with files, and via the CLIP:, but a named pipe would be easier, since TCC has this capability built in.

@FILEOPEN can also open named pipes. The pipe name must begin with \.\pipe. @FILEOPEN first tries to open an existing pipe; if that fails it tries to create a new pipe. Pipes are opened in blocking mode, duplex access, byte-read mode, and are inheritable. @FILEOPEN will not return until another process connects to the pipe.