-
Notifications
You must be signed in to change notification settings - Fork 397
Guide:Clipboard support in DOSBox‐X
Back to the DOSBox-X Wiki Welcome page.
DOSBox-X has support for copying to and pasting from the Windows clipboard in several ways. For example, you can copy to or paste from to the Windows clipboard inside DOSBox-X using a right mouse button click or keyboard shortcut, and you can also use a DOS device or DOS program to communicate bidirectionally with the Windows clipboard. Since the feature to access to the clipboard is currently only available in the Windows platform, this guide will assume you are using a Windows build (32 or 64-bit, either SDL1 or SDL2) of DOSBox-X.
You can use a DOS device (e.g. CLIP$) to easily copy text to and/or paste text from the Windows clipboard in DOSBox-X. If the "dos clipboard device enable" setting in the [dos] section of the DOSBox-X config file (e.g. dosbox-x.conf) is set to "true" or "full", a DOS device (default name: CLIP$) will be added to DOSBox-X to allow bidirectional communications with the Windows clipboard. For example:
DIR >CLIP$
Will redirect the directory listing to the clipboard;
TYPE CLIP$
Will display the content of the clipboard;
EDIT CLIP$
Will open the editor with the clipboard content;
SORT.EXE <CLIP$
Will sort the clipboard content (using DOS’s SORT.EXE tool).
Alternatively, you can set the "dos clipboard device enable" config option to either "read" or "write" to allow only read or write access for security reasons. The DOS device name can also be changed with the "dos clipboard device name" config option if you want to use a different device name from CLIP$.
This bidirectional clipboard access will be deactivated if the secure mode for DOSBox-X is enabled, and it will also not work if booting into a guest OS.
You can also use the right mouse button to easily select, copy or paste text to or from the Windows clipboard in DOSBox-X when the mouse is not locked. With this feature enabled you can right-drag on text in the DOSBox-X window and release the mouse to copy to the clipboard; right-click in the DOSBox-X window to paste from the Windows clipboard. By default this feature is disabled in DOSBox-X, but you can enable it by setting the "clip_key_modifier" config option in the [sdl] section of the DOSBox-X config file to "none" if no keyboard modifier is desired. It is possible to use a keyboard modifier for this feature by editing the same setting so that you can use Alt+Right-click, Ctrl+Right-click, Shift+Right-click, etc. to select, copy and paste text instead.
If you are using the SDL1 build of DOSBox-X, there is no limit on the clipboard size when doing the pasting. Furthermore, the "clip_paste_speed" setting in the [sdl] section of DOSBox-X’s config file can be used to set the speed for pasting each character from the Windows clipboard. The default setting is 20, but if this setting causes lost keystrokes, you can increase the number to slow down the pasting. Conversely, you may experiment with decreasing the number for applications that accept keystrokes quickly.
On the other hand, if you are using the SDL2 build of DOSBox-X, in order to paste long text (>15 characters) into DOSBox-X properly it is recommended to load a keyboard buffer expansion program like keybuf.com before doing the pasting. You only need to load it once. For example, "KEYBUF.COM 1024" will expand the keyboard pasting buffer to 1024 characters, and you can put this command in the [autoexec] section of DOSBox-X’s config file so that the program will be loaded automatically when you start DOSBox-X. There is no need to do this for the SDL1 build of DOSBox-X.
You can also use a keyboard shortcut to paste text from the Windows clipboard into DOSBox-X. In order to achieve this you need to run DOSBox-X’s keyboard mapper editor to assign a key for this feature first. One way to run the mapper editor is to start DOSBox-X.exe with the -startmapper command-line option. You can also select it directly from DOSBox-X’s GUI menu (under "Main"). After the mapper editor is launched, click the "Paste Clipboard" feature and assign a keyboard shortcut to it. For example, you can assign the F6 key (or Alt+F6, Shift+F6, etc) to paste text from the Windows clipboard. Once this is done you can save the mapper and exit to DOSBox-X. Then you will be able to use the saved keyboard shortcut to paste text from the Windows clipboard into DOSBox-X just like pasting it using the right mouse button click.
Similar to pasting text using the right mouse button, for the SDL1 build of DOSBox-X you can change the speed for pasting each character from the Windows clipboard via the "clip_paste_speed" setting in the [sdl] section of DOSBox-X’s config file. On the other hand, for the SDL2 build of DOSBox-X, if you want to paste long text into DOSBox-X, then it is recommended to load a keyboard buffer expansion program (just once) before doing the pasting. Again, there is no need to do this for the SDL1 build of DOSBox-X.
Copying and pasting text to or from the Windows clipboard is also supported via the DOS APIs in DOSBox-X, so DOS programs that can directly access the Windows 3.x/9x clipboard from a DOS window can also be used to copy and paste text to or from the Windows clipboard when running in DOSBox-X. For example, the WCLIP tool by Horst Schaeffer can be used to access the Windows clipboard inside DOSBox-X. Below are some examples of using this program to communicate with the Windows clipboard:
DIR | WCLIP
Will redirect the directory listing to the clipboard;
WCLIP < TEST.TXT
Will send the TEST.TXT file content to the clipboard;
WCLIP RECEIVE
Will display the content of the clipboard.
Like copying and pasting text using a DOS device, this bidirectional clipboard access will be deactivated if the secure mode for DOSBox-X is enabled, and it will also not work if booting into a guest OS.