Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby emendelson » 2012-6-30 @ 13:10

With apologies to Qbix, who wrote that something like this would mislead people into thinking that DOSBox was for applications, not only for games:

Here is a kludgy, unofficial, unsupported, and probably very buggy system for printing from DOSBox to the current Windows printer. It supports DOS games that can output PCL, PostScript, or ASCII text to a printer - provided that those games can "print to a file." It also makes it possible to "print" PDF files from DOSBox. It doesn't matter if your Windows printer supports PCL or PostScript - this system takes PCL or PostScript output, and converts it so that it prints to any Windows printer, including primitive GDI printers.

Also, this system makes it possible to send text to the Windows clipboard and receive text from the Windows clipboard.

To use it, place the contents of the linked ZIP file into the same directory with your copy of DOSBox.exe. The contents of the ZIP file are: the DOSBoxPrinter.exe executable and two folders (PrintApps and PrintOut).

Optional: create a shortcut to DOSBoxPrinter.exe in which you add to DOSBoxPrinter.exe the same command-line parameters that you use when launching DOSBox.

Run DOSBoxPrinter.exe. It will launch the copy of DOSBox.exe in the same directory, with the no-console switch, and DOSBox will mount as drive P: the PrintOut folder that you copied from the ZIP file. If you add any command-line parameters to DOSBoxPrinter.exe, the same command-line parameters will be used when the DOSBoxPrinter program launches DOSBox.exe. The DOSBoxPrinter.exe program will continue running until you exit DOSBox. If you want to quit it at any time, right-click on the gray icon that appears in the taskbar tray while the program is running.

To print from a DOS game that supports PCL output, set the output print file in the game to "P:\OUTPUT.PCL".

To print from a DOS game that supports PostScript output, set the output print file in the game to "P:\OUTPUT.PS".

To print from a DOS game that only prints ASCII output, set the output print file in the game to "P:\OUTPUT.TMP" (notice: TMP, not TXT). If your game (like EDIT.COM) only supports LPT1, etc., but lets you enter a four-character port name, then try P:\@ instead of LPT1.

To create a PDF file instead of printing, change the output file name to PCLTOPDF.PCL, PSTOPDF.PS, or TXTTOPDF.TMP (depending on the kind of output your game supports). The PDF file will be created in a folder on your desktop named PDF, and will have an arbitrary name based on the current date and time. The PDF folder will be created if needed. (If your game, like EDIT.COM, only supports LPT1 etc., but lets you enter a four-character port name, then try P:\# instead of LPT1.)

To give the PDF output files a filename that includes the name of the game from which you created them, enter this command before running the game:
Code: Select all
echo Name of My Game>p:\app-id.fil

The output PDF file will have a filename that looks like "Name of My Game 20120630124567.pdf". Delete p:\app-id.fil or replace it before running a different game.

When printing or creating a PDF file from ASCII output, the program tries to guess whether you are in North America (in which case it prints or creates a PDF with the letter page size) or elsewhere (in which case it prints or creates a PDF in the A4 page size). If it gets this wrong, please let me know. (When creating a PDF file from PostScript or PCL output, the program creates a PDF file with the page size specified in the DOS game.)

To send plain ASCII text to the Windows clipboard, copy to a file named P:\CLIPOUT.TMP. The contents of the file will be transferred to the Windows clipboard and the CLIPOUT.TMP file itself will be deleted.

If you use upper-ASCII characters (accented letters, etc), and you are in North America, use this filename instead: P:\CLIP437.TMP. If you are in Europe or any other region where the DOS codepage is 850, then use P:\CLIP850.TMP.

EDIT: For a memory-resident program that you can use to capture part or all of the screen so that it can be sent to the Windows clipboard (by being written to one of the three CLIP???.TMP filenames listed above) see a later post in this thread: viewtopic.php?t=32697#p316189

To get the contents of the Windows clipboard into DOSBox, either (1) run 4DOS and then run the 4DOS batch file P:\GETCLIP.BTM or (2) perform the following actions:
Code: Select all
echo .>p:\getclip.tmp
[wait a second or two]
p:
rescan
type p:\clip.txt


EDIT: Or, in the current version of the program, simply press the {PAUSE} key on the keyboard to type the contents of the Windows clipboard into DOSBox at the current cursor location.

The program tries to handle upper-ASCII (accented etc.) characters correctly. If this fails, please let me know.

To view the name of the current default Windows printer, either (1) run 4DOS and then run the 4DOS batch file P:\WHICHPTR.BTM or (2) perform the following actions:
Code: Select all
echo .>p:\whichptr.tmp
[wait a second or two]
p:
rescan
type p:\defptr.txt
del p:\defptr.txt


This system comes with no support of any kind, but I'll try to fix any bugs that get reported here.

The download is here:

https://dl.dropbox.com/u/271144/DOSBoxPrinter.zip
Last edited by emendelson on 2013-7-28 @ 19:04, edited 4 times in total.
emendelson
Oldbie
 
Posts: 644
Joined: 2010-2-14 @ 02:00

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby emendelson » 2012-6-30 @ 19:56

Update. The system now includes an option to select a specific Windows printer when printing from DOSBox. The printer can be any printer supported by Windows; it does not need to support PCL or PostScript. To use this option, set the output file in your DOS game to P:\SELECT.PCL for games that support PCL output, P:\SELECT.PS for games that support PostScript output, or P:\SELECT.TMP for games that print only ASCII output.
Last edited by emendelson on 2013-2-13 @ 05:08, edited 1 time in total.
emendelson
Oldbie
 
Posts: 644
Joined: 2010-2-14 @ 02:00

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby Joey_sw » 2012-7-01 @ 04:18

your current clipboard implementation doesn't really useful.

if you manage to do it like windows VDM (command prompt), it can be 'pasted' as you running the dos apps.

usually i run clipper-based apps on VDM,
and hit {Alt}+Space to invoke the menu,
click "Edit",
click "Paste"

as long the clipper apps doesn't expect the user to hit {Esc} or Function Keys {F#} or Arrow/Directional Keys or other Control Keys (Ctrl or Alt, Shift, etc...),
I could simulate the series of keypress into a text-clipboard, and paste it like above.

I often use that to entry batch of records.
-fffuuu
User avatar
Joey_sw
Oldbie
 
Posts: 532
Joined: 2011-8-17 @ 12:03

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby Dominus » 2012-7-01 @ 05:59

Hevhe, that's what you get when doing something like this for dosbox... ;)

But can't you send the clipboard directly to Dosbox? On OSX I'd script it roughly like 'get clipboard'(not sure how that can be done in Apple script, never done it before), then activate dosbox and send keypresses content of clipboard. Can't this be done with auto-it or autohotkey on Windows?
User avatar
Dominus
DOSBox Moderator
 
Posts: 7285
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby Joey_sw » 2012-7-01 @ 06:39

usualy autohotkey commnand can do it:
Send %Clipboard%

but,
somehow CR+LF in clipboard content will interpreted as double {Enter}-key by the autohotkey scripts,
thats why i stick on "Edit"+"Paste" menu that exist since win9x...
-fffuuu
User avatar
Joey_sw
Oldbie
 
Posts: 532
Joined: 2011-8-17 @ 12:03

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby Dominus » 2012-7-01 @ 07:41

Joey_sw, dosbox is not anywhere near the command prompt. Since dos had no clipboard this is not going to work as you want.
It will always be a kludgy workaround to do this.
User avatar
Dominus
DOSBox Moderator
 
Posts: 7285
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby emendelson » 2012-7-01 @ 12:31

Dominus wrote:Hevhe, that's what you get when doing something like this for dosbox... ;)

But can't you send the clipboard directly to Dosbox? On OSX I'd script it roughly like 'get clipboard'(not sure how that can be done in Apple script, never done it before), then activate dosbox and send keypresses content of clipboard. Can't this be done with auto-it or autohotkey on Windows?


Your wish is my command. The current version of DOSBoxPrinter.exe will paste the current contents of the Windows clipboard into DOSBox when you press the {PAUSE} key. (I tried Ctrl-Shift-V and Ctrl-Alt-V and Shift-Alt-V, but they all left the keyboard in a strange state in DOSBox.)

The problem with this (and the reason I didn't do it earlier) is that it only works with lower ASCII characters, so if there are any upper-ASCII characters (accented characters, diacritics, etc.) in the keyboard buffer, they may produce unexpected results. This problem doesn't occur with the method I provided earlier, where you read a file in DOSBox to get the contents of the Windows clipboard. EDIT: It now works with upper-ASCII characters also.

The only way to solve this would be parse every character in the clipboard buffer and replace any upper-ASCII character with an Alt-### string, and that's more than I'm willing to try.

(Incidentally, this is not easy at all under AppleScript in OS X, but it's certainly possible in AutoIt.)
Last edited by emendelson on 2013-7-28 @ 19:07, edited 1 time in total.
emendelson
Oldbie
 
Posts: 644
Joined: 2010-2-14 @ 02:00

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby Dominus » 2012-7-01 @ 12:43

Thanks for goung through all that trouble. I hope people appreciate it!
User avatar
Dominus
DOSBox Moderator
 
Posts: 7285
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby emendelson » 2012-7-01 @ 13:59

Dominus wrote:Thanks for going through all that trouble. I hope people appreciate it!


I've received so much help on this forum from you, ripsaw8080, TeaRex, h-a-l-9000, wd, HunterZ, ykhwong, and others, that it's a pleasure to offer something that may be even minimally useful to someone.
emendelson
Oldbie
 
Posts: 644
Joined: 2010-2-14 @ 02:00

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby emendelson » 2012-7-04 @ 00:44

I've now updated this so that the feature that uses the Pause key to paste the Windows clipboard into DOSBox supports extended ASCII characters, not just lower-ASCII characters. Everything else is the same.
emendelson
Oldbie
 
Posts: 644
Joined: 2010-2-14 @ 02:00

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby RetroComp » 2013-2-13 @ 03:38

Hi emendelson

emendelson wrote:Here is a kludgy, unofficial, unsupported, and probably very buggy system for printing from DOSBox to the current Windows printer. It supports DOS games that can output PCL, PostScript, or ASCII text to a printer - provided that those games can "print to a file." It also makes it possible to "print" PDF files from DOSBox. It doesn't matter if your Windows printer supports PCL or PostScript - this system takes PCL or PostScript output, and converts it so that it prints to any Windows printer, including primitive GDI printers.

Also, this system makes it possible to send text to the Windows clipboard and receive text from the Windows clipboard.


Can you share the .au3 font file from your print solution, too?
I want to see how you implemented the "listener" to detect folder changes.
(Well, if you cannot share it, I will understand. No questions.)

I'm thinking about to join your work with this (barely documented) open source solution to emulate, convert and print old dot matrix "epson esc/p" files:
http://sourceforge.net/projects/txtprint/?source=navbar

The txtprint is built in xHarbour, and its implementation of "ESC/P" encoding is about 60% and the output is reasonable (and free...)
(This is a good tip.)

I´m learning a little bit of Harbour language right now to improve the txtprint. Basically, to add an option to choose the codepage before printing.

If I get some advance, I will share too.

Thank you for your efforts and the creation of dosboxprinter.
[]s Retrocomp.
User avatar
RetroComp
Newbie
 
Posts: 2
Joined: 2013-2-05 @ 19:13

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby emendelson » 2013-2-13 @ 04:59

For complicated reasons, I don't want to post the full code, but the file-watcher is easy. Define the directory that you want to watch and the file that you want to watch for, and then use this code:

Code: Select all
... launch DOSBox here...

$procname = "dosbox.exe"
While 1
   If Not ProcessExists($procname) Then
      Exit
   EndIf
If FileExists($prtfile) Then
... etc., etc.
EndIf
If FileExists($somethingElse) Then
... etc., etc.,
EndIf
Sleep(500)
Wend


$prtfile is defined as a specific file in the watched directory (which you define in relation to the folder from which the executable is run). You can similarly specify other files to watch for, and include them all in the same while/wend block. As written this checks for the existence of the files once every 500 milliseconds.

That should be all you need, and it's extremely simple.
emendelson
Oldbie
 
Posts: 644
Joined: 2010-2-14 @ 02:00

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby emendelson » 2013-7-25 @ 02:08

It took me a long time to figure out something that should have been obvious, but it's easy to enhance this system to copy text from inside DOSBox (in text mode) to the Windows clipboard.

Start by downloading this file:

https://dl.dropboxusercontent.com/u/271 ... nipper.zip

It contains three patched versions of Tom Kihlken's SNIPPER.COM utility, originally written for PC Magazine. Copy them to the C: or any other drive that you use with the DOSBox Printer. If you only want to copy plain ASCII text from DOSBox to the Windows clipboard, run SNIPDBP.COM. If you expect to want to copy text that includes upper-ASCII (accented etc.) characters, and you are in North America, run SNIP437. COM; if you are in Western Europe, run SNIP850.COM instead.

Now, when you want to copy some text to the Windows clipboard, press Alt-W in DOSBox. Use the arrow keys to move the block cursor to the point where you want to START copying; press Enter, then use the arrow keys to select the block of text that you want to copy. When you are done, press the letter F (or press Enter, and choose F from the menu). You will be prompted to enter a filename, but use the default filename shown. After a second or two, the text you copied should be available in the Windows clipboard.

These programs are patched to save the selected text to a file, as described in the first post in this thread. The point of the programs is to make it possible to send text to the Windows clipboard without interfering with whatever program is running in DOSBox.

EDIT: Corrected mistyped filenames.
Last edited by emendelson on 2013-7-28 @ 13:04, edited 2 times in total.
emendelson
Oldbie
 
Posts: 644
Joined: 2010-2-14 @ 02:00

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby pope5 » 2013-7-28 @ 13:00

where do I find the programs CLIPDBP.COM resp. CLIP437.com or CLIP850.com?

Thank you for any help.
pope5
Newbie
 
Posts: 2
Joined: 2013-7-27 @ 11:39

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby emendelson » 2013-7-28 @ 13:03

Sorry, I mistyped the names in my post - use the files in the zip file - SNIPDBP.COM, SNIP437.COM, SNIP850.COM.
emendelson
Oldbie
 
Posts: 644
Joined: 2010-2-14 @ 02:00

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby Robert_Tang » 2014-7-22 @ 07:28

Can I copy content from excel to doxbox window with this tool?
Robert_Tang
Newbie
 
Posts: 8
Joined: 2014-7-14 @ 04:25

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby Dominus » 2014-7-22 @ 07:42

Seriously? After I just told you to try it in the other thread?
User avatar
Dominus
DOSBox Moderator
 
Posts: 7285
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby Robert_Tang » 2014-7-22 @ 08:03

Hi,Dominus
Sorry, I don't catch your meaning. And I am a newbie. Could you tell me the other thread in detail. Step by step will be appreciated!
Thank you!
Robert_Tang
Newbie
 
Posts: 8
Joined: 2014-7-14 @ 04:25

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby Dominus » 2014-7-22 @ 08:13

You want to know something you could have tested already.
User avatar
Dominus
DOSBox Moderator
 
Posts: 7285
Joined: 2002-10-03 @ 09:54
Location: Vienna

Re: Printing & clipboard-exchange - kludgy workaround for DOSBox under Windows

Postby Solarstorm » 2014-7-22 @ 08:20

SCNR
Image
User avatar
Solarstorm
Member
 
Posts: 193
Joined: 2013-9-14 @ 11:38
Location: Heidelberg, Germany


Return to DOSBox Development

Who is online

Users browsing this forum: No registered users and 4 guests