Applications can make text available on the clipboard in multiple formats, for the benefit of consumers that may or may not support the richest representation. In order to figure out what my application should (and could) be consuming, I want to inspect the formats provided by some common applications. But how do I get a list of these formats?
Microsoft documents the C++ function EnumClipboardFormats
, which does exactly what I'm after. Can I access this functionality (or equivalent) from java, and how do I use it? And is there a system-independent (or at least Linux and OS X) counterpart?
To be more precise, I'm looking for a way to enumerate and then fetch the contents of the clipboard when it contains rich text in different formats, e.g. text/plain
, text/html
, text/rtf
, and whatever else is in there. I won't be dealing with exotic types like collections of files moved via the clipboard. I'm looking for a solution (or solutions) for both Windows and OS X, and hopefully Linux.
Due diligence: This question asks more or less the same thing, but does not have a (correct) answer. I've browsed around the clipboard-related features of the java awt
toolkit, but they seem to be organized around specific "flavors" (formats) that the consumer is able to use-- not around what's available.
I have also asked how to do this in python, but (after doing my own research for some time) I've pretty much concluded that python doesn't provide access to rich text formats.