Can I use Keyboard Maestro to determine what the type of content in clipboard is?

Hello folks,

I am working on an macro to save the clipboard content to hard drive and then pass the file to Yoink :

Since there will be lots of kinds of content put into clipboard, e.g. PNG, JPG, TXT, RTFD etc. I know I should determine the content type. Then I come up with Clipboard Condition :

It is frustrating that Clipboard Condition currently only supports the function of handling text. So, can I use Keyboard Maestro to determine what the type of content is in clipboard? In my case, if there is any way to automatically save the content of clipboard to hard drive that would be great.


determine the content type

There is often more than one kind of content in the clipboard – applications can scan what is there and choose which type to use.

See, for example:

1 Like

Hi Oscar,

Thanks to @ComplexPoint's very helpful clipboard viewer script, we can create a variable based off the current clipboard content and see if it contains the appropriate file extension or content type for what we want to do. An example for PNG and JPG files:

Save Different Clipboard Content Differently.kmmacros (7.1 KB)


Hi Gglick, thanks for your woking, this macro is tremendous.

Looks like you rewrited ComplexPoint's JXA code with Apple Script. I need a period of time to fully understand your code.

No problem, Oscar. Glad it's proving useful. I can't take credit for rewriting @ComplexPoint's JXA code, though; he was simply thoughtful enough to provide an AppleScript version as well (it's posted right beneath the JXA one in that thread) which I opted to use here, since it returns the data in a more straightforward format when saved to a KM variable.