Switching from Pastebot

As Pastebot seems to be abandoned and no longer works reliably with Safari, I’m wondering if I can use KM to replace it in my workflow. It feels close! Here’s how I use it:

  1. Activate clipboard history with a hot key. :white_check_mark:
  2. Use the arrow keys to select a clipboard. :white_check_mark:
  3. Press command-return to show my regex filters and let me pick one with the arrow keys. :cross_mark:
  4. Press return to run the selected filter and paste the results into the app. :cross_mark:

Are 3 and 4 possible? I tried adding a paste at the end of my filter but couldn’t get it to paste the filtered results.

Can you show what you’ve got so we don’t have to re-invent the wheel? Pastebot is a really large program with a lot of features, and I’m not sure what you’ve managed to get working and what’s not working.

Sure. Here’s a simple one to format a phone number that I use frequently. I tried various “To” options but couldn’t get it to work. The Paste action seems to make the filter fail.

This is the first day I’ve ever tried to use filters for the clipboard history, but I think you’re doing it wrong. Try this:

This will successfully change the a’s to x’s in the specified clipboard (ie, the clipboard that you trigger this filter from.) You can fancy up that example to process your phone numbers with regex. This filter places the new version of the clipboard directly ahead of the version that you ran it on. Notice how your search action did NOT put the converted text back into the Trigger Clipboard. I think that was your mistake. My action does work (although I could have specified "Source" instead of "Trigger Clipboard".) But I could be wrong, as today is the first day I'm trying to use this feature.

That's a separate problem. I think you are trying to fit a square peg in a round hole. Filter macros are supposed to just filter things in the Clipboard History window. If you want to filter & paste or do other things, I think you're supposed to do that in a different macro. In your example you just had a "paste" command and you forgot to activate an application before you did the paste, and you didn't insert a pause to ensure the application was ready for the paste. These could be the reasons your attempt is failing. (Check it out and see. I seemed to get it to work that way.) But I think fixing that code is putting a square peg in a round hole, so don't do that.

Basically, I think Filters are for the clipboard history window, and you're trying to get those filters to work on other applications. I think that's the main issue. If you want to write transformations/filters that work on data in other apps, Keyboard Maestro is the perfect tool for that, but filter macros are not. Filter macros are for one thing only, and that's not what you are needing to do here.

I recommend that you take a step back and try to explain what you want to do, and we can find the correct approach to do it. You cannot map "Pastebot filters" to "KM filters." They are not equivalent - they just share the same word: "filters."

Of course, there's a 10% chance I'm wrong, and someone better than me can explain why.

You're filtering the Trigger Clipboard with results going to "Source" i.e. the Trigger Clipboard. Paste uses the System Clipboard.

So the simple fix is to change "to: Source" to "to: System Clipboard".

Unfortunately, that still doesn’t work. As I said, I tried the various “to” options. I wonder if something asynchronous is going on, as I saw someone mention that about dealing with clipboards.

Upload the demo macro you posted the image of -- always helpful so people can check various action options ( and it stops us from typing the regex :wink: ). It also helps to provide sample input and expected output data.

1 Like

Thanks for your response. I should clarify what’s working and what I’m trying to achieve.

The filter itself is working. Running a filter in the Clipboard History Switcher requires clicking the gear or right-clicking the entry, and I’d like to be able to do this mouse-free. Command-return to activate the filter menu would be great, and I’m wondering if a KM macro could do that, as then I could use the arrow keys (or press a letter) to select a filter from the menu.

After running the filter, I’d like the results to be pasted immediately. I see that I can use up-arrow and return to paste it, so it’s not a huge deal, but I do a lot of these so it’d be nice to skip that step.

Sure, here you go:

000-000-0000.kmmacros (1.9 KB)

1 Like

Now we are getting close to a clear requirement. However the Clipboard history window has multiple visible entries. How do you want the macro that does this mouse free to know which entry to work on? Are you planning to use the mouse to indicate which entry to work on? If so, then that kinda defeats the purpose of being mouse-free. But if the entry you want to work on is always the top one, then there would be a mouse-free solution. However you didn't say that the entry you want to work on is always the top one. Is that the case, or not? It's hard to write a solution if we don't know what you want.

If we succeed at writing a macro that does the previous thing, above, then it's easy enough to add to the macro the UP and RETURN keys. However may I point out that the Clipboard History Switcher is not a standard MacOS app with any menus, so it's probably not going to be a reliable macro to automate that. If you are content with unreliable macros, then just add UP and RETURN to the end of the macro that solves the first problem.

OK -- I see what's going on here.

If you add a 1 second "Pause" between the "Search..." and "Paste" actions and keep an eye on the Clipboard History Switcher while running the macro you'll see that the "Paste" action pastes whatever is selected in the Clipboard History Switcher.

Indeed, it seems that when the Clipboard History Switcher is active then the "Paste" action, the app's "Paste" menu item, and ⌘V all paste the Switcher's selected item.

I don't know if this is expected behaviour or not. Anyone?

But an obvious (if annoying because of the flicker) fix is to close the Switcher, do the paste, re-open the Switcher:

("Activate..." is actually a toggle.)

Edit to add:

Perhaps a better alternative is to select the first item in the Switcher list (the System Clipboard item) before you do the "Paste" action -- and we can do that with an AppleScript action:

The script:

tell application "System Events"
	tell process "Keyboard Maestro Engine"
		tell window "Clipboard History Switcher"
			click group 1 of scroll area 1 of group 1
		end tell
	end tell
end tell
3 Likes

Actually, closing the Clipboard History Switcher before pasting is fine; that’s what Pastebot does when you run a filter.

So the only other thing would be a way to select a filter with the keyboard to make this mouseless.

Assuming the filters are all to do with filtering text, I think I wouldn't use the KM Clipboard History Switcher at all. I would use a couple of Prompt with List Actions and a Switch Case Action.

The first Prompt with List allows you to choose the past clipboard you want using the arrow keys, (as you requested) and hitting Return Key. In my example I have 8 past clipboards but you can make the list longer or shorter.

The second Prompt with List allows you to choose the filter you want to apply (again using the arrows keys followed by hitting the Return Key).

Then a Switch Case Action is used to choose what to do with the chosen text based on the result of the second Prompt.

Finally, the transformed text is pasted into whatever App you were in when you ran the Macro.

In my example I've just used some Keyboard Maestro standard text filters but you could use the Prompt with List to apply the Regex Filters you already have.

Example - Filter Text in Past Clipboards-Animated Image (Mine)

Example - Filter Text in Past Clipboards.kmmacros (6.0 KB)

3 Likes

That will break if a Clipboard entry contains line breaks -- each line will be an entry in the Prompt list.

An alternative would be to build your own list, taking only the first line of any Clipboard. Luckily, "For Each" has a "Clipboard History Collection":

You could limit the number of History items with a counter and "If counter > n, break from loop".

But I suspect that OP -- like me -- would rather work with the context provided by the Switcher window than with a list of text items. And since they are selecting a History item via arrow keys we can target that selection with AS:

tell application "System Events"
	tell process "Keyboard Maestro Engine"
		tell window "Clipboard History Switcher"
			tell scroll area 1 of group 1
				click menu button 1 of item 1 of (get every UI element whose selected is true)
			end tell
		end tell
	end tell
end tell

...to click the cog-wheel of the selected item, popping the menu ready for keyboard navigation.

One possible downside is that each group is referenced by its contents rather than by index, i.e. if you have copied the text "Local variable" (without the quotes) then the AS reference is group "Local variable". So it might be possible to select eg the rich text version History item but transform a more recently copied plain text version of the same string.

1 Like

Thanks, that looks like it should work. How would I execute the AppleScript? I tried making a group for the focused window “Clipboard History Switcher” and then a macro on command-return that runs that AppleScript, but it didn’t work (the switcher just closed with a system beep).

Unfortunately the Switcher is "owned" by Keyboard Maestro Engine -- the Engine is a background app and its windows are never considered to be "frontmost". Nor is the app itself, so you can't limit the Group that way, either.

So a macro for this script will need to be in a globally-available Group, and that means you'll probably need to re-think the hot key you'll use so ⌘↩︎ remains available for normal use. Maybe ⌃⌥⌘↩︎ (if that doesn't conflict with anything on your system).

An alternative would be to have everything in a single macro and use a "Pause Until..." you hit a key. That key isn't "swallowed", so should be something you don't mind going to an app -- a naked ⌘ key might work here, remembering that you'll have to keep it pressed for a beat so KM registers it. For safety you should then wait until it is released, in case it interferes with later actions.

So, changing the list in your OP:

Use a hot key combo to trigger a macro that

  1. Activates the Clipboard History Switcher
  2. Pause until ⌘ is pressed -- that lets you use your arrow keys meantime
  3. Pause until ⌘ is released
  4. Run the AppleScript
  5. Pause until the Clipboard changes -- that'll happen after the selected filter has run and the Clipboard has been set to the new value
  6. Close the Switcher window
  7. Paste

In this case, the Clipboard Filter macro would only be the "Search and Replace" action, without the AS "select the top item" or "Paste" actions (the AS isn't needed because we're closing the Switcher, the "Paste" is in the "main" macro).

Paste Filtered from History.kmmacros (5.0 KB)

Image

1 Like

That works perfectly. I can set the timeout on the first pause to, say, 5 seconds, so that I can use this for non-filtered clipboard management and the macro will silently terminate. Very nice! Thanks again.

I know it’s solved, but may I ask in what way Pastebot does not work with Safari anymore?
I’m using it for years and do not see any problems.

I’m using Safari 26.0.1 but I’m still on Sequoia 15.7.1, so if you’ve updated to Tahoe you might not be seeing this. But Pastebot doesn’t register copies of text in tables. For example, on this Wikipedia page, if I copy the “990” next to Mandarin in the table, it doesn’t show up in Pastebot’s history.

Another longstanding issue that’s less annoying is that Pastebot doesn’t handle files correctly in the Finder. So if I copy a file, it does show up in Pastebot’s history, but pasting it from Pastebot into the Finder doesn’t work.

It’s a great app and I hate to leave it, but it was last updated a year ago and they didn’t respond to my support email, so I think they may have moved on.

1 Like

Thank you for these remarks; interesting.

Indeed I’m one of the curious idiots who updates his macOS very early (no betas though). I can copy and paste the 990 from the mentioned Wikipedia page in Safari without problems.

I can also paste a file from the Pastebot history, but I have to hold ⌥ Option, because [I think] Pastebot tries to work with the text part of a copied item first.

Regarding the devs not reacting:
Tapbots is a small team with multiple apps and have a very good reason for not attending to their products right now. As stated from on of their mastodon account:

We know some of you are wondering where the Ivory update for iOS, iPadOS, and MacOS 26 is. We have some unfortunate news. An immediate family member was diagnosed with cancer over the summer and it has turned our world upside down. We will eventually get through this and focus on development again. Thank you so much for your support through these tough times.

So maybe you don’t need to kick Pastebot from your system just yet. When I filed a bug with them some time ago, it got fixed a few months later. I don’t think the app is abandoned.

2 Likes