Named Clipboard Switcher: is it possible to add Display and Edit Clipboard options using modifier keys?

Not sure about the "Display as HTML" bit, but activating a Named Clipboard in KM's Settings... window takes a bit of a hack...

As far as I know (and I hope someone corrects me!) there is no easily available list of Named Clipboards. And the Clipboard Filter Trigger returns the Named Clipboard's UUID, not a name.

Named Clipboards appear to be stored in ~/Library/Application Support/Keyboard Maestro/Keyboard Maestro Clipboards.kmchunked. It's a binary file but, luckily, strings can extract some useful info -- including line-pairs where a Clipboard name is followed by the UUID, albeit with some extra junk in there:

`mdLink2u
$DFCE8C45-2347-4DE1-988E-B2682FFE34BC3u
--
Fubar test2u
$05B57846-CBBD-4A04-B6D6-8D099CD440133u

The 2u at the end of the name, the at the beginning of the UUID and the3u` at the end are consistent and can be cleaned up, but some names have one (and maybe more) characters prefixed -- the actual names of the above are "mdLink" and "Fubar test" -- and my best solution to that is to keep trying, chopping of the first character on every failure, until there's a name match...

Enough moaning! Here are "Pick from list" and "Clipboard Filter" macros that open your choice, ready for editing:

Note: These macros require the strings utility, part of "Xcode Command Line Tools". You can get that by:

Apologies to @Ronald for forgetting these aren't included in the vanilla OS install.

Edit Named Clipboard (List).kmmacros (4.6 KB)

Image

Edit Named Clipboard (Contextual).kmmacros (4.2 KB)

Image

They work for me, though I'll confess they haven't been tested extensively. They'll break if you have two Clipboards with the same name. And there will be problems if you use emojis, and maybe accented characters, in your Clipboard names -- I think strings outputs a space for each of those, which might be OK if it's the first character but probably not if it is later in the string...

You might, for example, be able to Paste the Named Clipboard into Text Edit and make your changes there before Copying back to the Named Clipboard. I don't know, I don't use Named Clipboards much and certainly don't edit their contents!

2 Likes

I am extremely grateful for your efforts. Unfortunately, neither macro works, but I found a workaround so please do not spend more time on it.

It was a lot of work for you, so thanks VERY much.

2025-04-11 20:32:08 Execute macro “Edit Named Clipboard (Contextual) $nige_s” from trigger Editor

2025-04-11 20:32:08 Variable “KMVAR_sspData” excluded from environment to ensure the environment is not too large

2025-04-11 20:32:08 Action 16878606 failed: Search Regular Expression failed to match (.)\n%TriggerValue**[ 2*]* :%\n

2025-04-11 20:32:08 Search Regular Expression failed to match (.)\n%TriggerValue[2]:%\n. Macro “Edit Named Clipboard (Contextual) $nige_s” cancelled (while executing Search Variable “Local_cbList” Using Regular Expression (ignoring case)).


2025-04-11 20:32:14 Execute macro “Edit Named Clipboard (List) $nige_s” from trigger Editor

2025-04-11 20:32:20 Action 16878594 failed: Prompt With List returned without an answer

2025-04-11 20:32:20 Prompt With List returned without an answer. Macro “Edit Named Clipboard (List) $nige_s” cancelled (while executing Prompt With List “” from Variable “Local_cbList”).

2025-04-11 20:32:46 Action 16798571 timeout exceeded. Macro “Named Clipboard __Copy to and Display CURRENT Named Clipboard alias” cancelled (while executing Group with Timeout 2 minutes).

Gotta fix it! Pride demands such :wink:

Both worked first time when I tried them on this, different, machine. I'm guessing that, for some reason, your clipboard file is outputting differently to mine and I'd love to find out why.

The Named Clipboards probably contain info best not revealed on a public Forum so I'll drop you a DM. And I won't be too upset if you don't trust me with the info either!

If anyone else would like to have a go with the macros above and report back on success or failure along with OS version etc, that could also help narrow down the problem.

This is masterful sleuthing! I learned a lot just by retracing your explanation.

The (List) macro works here on 10+ named clipboards. Mojave 10.14.6

Most of the data is short text, RTF and an Image. Names are simple alphanumerics.

It correctly returns the correct number of named clipboards and then goes to the correct clipboard in the Preferences:Clipboards tab. Minor: It places a backtick in front of one name, a 0 in front of another and duplicates an intial letter in front of another.

The (Contextual) macro, when the The Failure Aborts Macro on the regex Action is unticked, errors in the Engine.log like this:
Action 16878606 failed: Search Regular Expression failed to match (.)\n%TriggerValue[2]:%\n
2025-04-11 13:07:47 Search Regular Expression failed to match (.
)\n%TriggerValue[2]:%\n in macro “Edit Named Clipboard (Contextual)” (while executing Search Variable “Local_cbList” Using Regular Expression (ignoring case)).

The Local_cbList variable contains the same names as the (List)macro with alternating ids.

I'm surprised it works with one but not the other -- I think the original issue is that the shell script action uses the strings utility which I forgot isn't installed in vanilla macOS. My post has been edited to correct that.

These are from the original strings output, and I could see no way of telling if a clipboard name had eg an extra a prefixed or was indeed called aClipboard.

Actually there is a way -- compare all the names to those scraped from Settings "Clipboards" pane:

tell application "Keyboard Maestro"
	show preference pane "Clipboards"
end tell

tell application "System Events"
	tell process "Keyboard Maestro"
		tell window 1
			tell scroll area 1
				return name of every group
			end tell
		end tell
	end tell
end tell

I was avoiding that route because it requires KM Editor to be running and Settings open. But that's how we're going to edit the Named Clipboard anyway -- D'oh!

1 Like