Updated 2012-06-28 00:32:13 by RLE

clipboard - Manipulate Tk clipboard
clipboard option ?arg arg ...?

Supported subcommands are:
clipboard append ?-displayof window? ?-format format? ?-type type? ?--? data
clipboard clear ?-displayof window?
clipboard get ?-displayof window? ?-type?

A pointer or help discussing X vs Mac vs Windows clipboard processing - particularly the rather complicated X model - seems in order.

Perhaps a pointer to nice cross-platform tool to give a Tk view of the clipboards to which a user has access, with auto-saving and loading of the contents, would be a nice example?

Features of a Tk-based user interface to their system clipboards

In clt postings, Wojciech Kocjan and Sebastian Wangnick, respectively, make several interesting points about the Windows-hosted clipboard. The former summarizes, "You'll need to GetClipboardData() with CF_BITMAP (see win/tkWinClipboard.c in the Tk sources for a nice example), if it succeeds, then you have HBITMAP which you can use to create a Tk photo image." The latter writes, "Tk's access to the windows clipboard is currently restricted to only STRING types. For instance, if you copy a Visio object and then use 'selection get -selection CLIPBOARD', you'll only get the text associated with the graphical object (as if you always did an Edit->Paste Special->Text only). Feature request https://sourceforge.net/tracker/?func=detail&aid=587939&group_id=12997&atid=362997 is pending to lift this restriction (which seems to stem from the old times where Tcl couldn't handle binary data).

You could try yourself to change win/tkWinClipboard.c:TkSelGetSelection and rebuild Tcl/Tk, but to do that you need a compilation environment on your PC.

You would have to use GetObject and GetDIBits on the HBITMAP you'll receive by GetClipboardData, and could then either try to pass this on to the script for decoding, or try to further process the data in C."

ghoest observes that it may not be immediately obvious from the description of clipboard clear that this only clears the clipboard for selected window and doesn't appear to change the clipboard for other windows/application (yeah, so I didn't really appreciate what the description said until going back to read it a second time... silly me). A quick and dirty way to clear other windows clipboards: "clipboard append {}" after a clear... at least on Win7 64bit running Tcl 8.6

See also edit