Check Size of Clipboard ⇢ Data-Types on the Clipboard

Sometimes by mistake I hit CMD+V to paste into Notes, when in fact I want to paste the text instead (CMD+OPTION+SHIFT+V), for example if I select a group of file/folders in Finder and I then want to paste the names only. So if those files/folders are large files, Notes freezes.

Is there a way for KM to check the size of the clipboard in MB?
According to this, it seems that the =>, =, etc, are related to the text length, not file size?

Checking the size of the clipboard is not going to work for things like files and folders, because it simply holds references to those items.

However – you can test for data-types on the clipboard and proceed from there.

@ComplexPoint has a very comprehensive macro for this on the forum:

A simpler JXA script would be something like this:

(() => {
    'use strict';

    ObjC.import('AppKit');

    return ObjC.deepUnwrap(
        $.NSPasteboard.generalPasteboard
        .pasteboardItems.js[0].types
    ).join('\n');
})();

Result for several items copied from the Finder:

public.file-url
public.utf16-external-plain-text
public.utf8-plain-text

@ComplexPoint's script result for the same items:

{
  "public.file-url as propertyList": "file:///Users/myUserName/Downloads/Clipboard%20View%20(all%20textually%20representable%20data%20as%20JSON).kmmacros",
  "public.file-url as string": "file:///Users/myUserName/Downloads/Clipboard%20View%20(all%20textually%20representable%20data%20as%20JSON).kmmacros",
  "public.file-url as data": "file:///Users/myUserName/Downloads/Clipboard%20View%20(all%20textually%20representable%20data%20as%20JSON).kmmacros",
  "public.utf8-plain-text as string": "Clipboard View (all textually representable data as JSON).kmmacros\rDeltaWalker-2.6.4_x64.dmg\rMemoDate_c.zip\rmuCommander-1.2.0-2.dmg",
  "public.utf8-plain-text as data": "Clipboard View (all textually representable data as JSON).kmmacros\rDeltaWalker-2.6.4_x64.dmg\rMemoDate_c.zip\rmuCommander-1.2.0-2.dmg"
}
3 Likes

If you always, or nearly always, want to paste as text, you could just give in to your habit and set Cmd-V to trigger "Paste and Match Style".

You could create a macro for this in a macro group that is only active for the Notes application (amongst other ways).