I'd like to get a list of all the types currently present in the clipboard. E.g.
['public.rtf', 'public.html', ...]
Is this possible? I've been hacking at this and trying to use JavaScript for Application but I'm not sure if I'm going in the right direction. I can apparently get a list of types but can't figure out how to write out what I have (I keep getting "can't convert type").
function getItems() {
return $.NSPasteboard.generalPasteboard.pasteboardItems
}
// this gets SOMETHING but I don't know what - just that it's not undefined
const to = getItems().firstObject.types.firstObject;
Eventual goal: if there are objects of a certain type on the clipboard then don't blow it away. In my macro (used hundreds of times a day) insert-by-pasting is faster than insert-by-typing, but if there is OneNote data in the clipboard then there's no way to preserve it with insert-by-pasting. So, I want to use the fast version if any other app has pasted to the keyboard, but the slow version that preserves the clipboard fully if OneNote has pasted. So I need to see if a specific type ("com.microsoft.OneNote-2010-Internal") is in the general pasteboard.
(The KM script editing environment is pretty limited too - I'm definitely open if someone has a recommendation for an improved editor. E.g. no line numbers to compare to error messages, no autocompletion or mouseover type inspection.)