PopClip And/Or Keyboard Maestro

Has anyone kicked off a KM workflow from PopClip?

Alternatively simulated it?

PopClip pops up a palette of macros to act on selected text.

1 Like

It is hard to make a popclip addons。Maybe KM can add this feature to do something about text。。seems a good idea!

Actually I just adapted one of their add-ons over lunch and it looks quite easy - so long as you know programming.

But I agree, it’s not as easy as basic Keyboard Maestro usage.

A bridge to KM would be handy.

How or what do you want to do with the selected text? Use as a Snippet, PlainText …?

Keyboard Maestro has palettes that can be activated (shown) in a variety of ways.

Perhaps if you could show us a short video or animated GIF of the workflow you are doing using PopClip, we can offer some ideas of how it could be done in KM.

I think the most different place is that the palettes of popclip appears where you select text. However, the
palette of KM need to call by a short-cuts. That is to say, you must do one more step in KM.

1 Like

So, as @minjie_he says PopClip does the following…

… When you select some text it immediately pops up a bar of actions. A few are built in but many are installable. The main site for them is here.

The built in ones do things like copiying to the clipboard. A simple example of an installable one is changing the text to upper case. Another one would be a Wikipedia search. A third is to do the arithmetic in the selected text. E.g. Replace “2 + 2” by “4”.

You can build your own PopClip extensions very easily - and indeed I cloned the “upper case” one and examined its contents yesterday.

What would be really nice would be to build an extension that connected to a Keyboard Maestro workflow.

As PC extension actions can be shell scripts, (built in interpreter) PHP scripts, likewise Ruby, I don’t think this is beyond the realms of possibility.

I could imagine one of two things:

  1. A second (KM) palette.
  2. A set of PopClip extensions.

Quite possibly Option 1 is better than Option 2.

No, if a trigger for a KM workflow could be text selection then PopClip isn’t needed. However, I can see KM and PC “clashing” in this case, so PC would have to go. PC isn’t essential to me yet. It would just be a shame to have to re-implement the PopClip extensions and functions.

Since KM does NOT have a “Select Text” trigger, I don’t see any way around needing to make one more keystroke to display a KM palette.


Right, so the route left open is a PopClip extension.

I could - when I get a moment - develop a sample one. I presume I can invoke a Keyboard Maestro macro programmatically - via shell script or PHP or something.

It would have to be a sample as a user would want to customise the macro name it invoked, plus perhaps what was passed to the macro. (PopClip is quite sophisticated in what it can pass.)

TBH I’ve not yet got to that bit of the learning curve…

I still think, though, this could be a useful integration.

And before anyone asks I can’t remember what I paid - several years ago - for PopClip.

Yes. In the trigger section of the macro, if you select from the popup menu “Or by script” it will give you the code to trigger a macro in a variety of languages.

Thanks @peternlewis!

I’m happy to report I’ve got a VERY basic PopClip extension working…

It uses a one-line shell script with the following in:

osascript -e “tell application “Keyboard Maestro Engine” to do script “Test One” with parameter “$POPCLIP_TEXT””

That shell variable is what PopClip uses to pass the selected text when it’s invoked.

Right now I’ve got two actions working in the test script:

One uses Display Text with the following in it:

You invoked me, %TriggerValue%%

The trigger value is indeed filled in with the selected text.

The second uses Insert Text By Typing to wrap the input text with "BLAH"s. I’ve tested this with Sublime Text and it wraps the selected text nicely and substitutes back in. Obvious examples where this would be useful include Markdown.

Having got this far anything else is just a SMOP@. :slight_smile:

Seriously, getting the text is quite a big deal. And writing it back modified even nicer.

What a lovely way to spend an evening, getting this demo to work. :slight_smile:

@ Simple / Small Matter Of Programming


Could I impose on you to share the PopClip extenstion? I can't figure out how to create an extension even after reading the PC docs. If I could see what you've got I might be able to adapt it to my needs.

1 Like

Glad you’re interested. I hope I’ve still got the code as between then and now I had to rebuild my system.

An interesting project for the weekend. :slight_smile:


Here's a blog post with all the code in - plus an explanation. (Wrote it today after rewriting my code.)

Invoking Keyboard Maestro From PopClip


Thank you sir!

Martin, I tried to create a Config.plist along the lines you suggest, but when I double click on the .popclipext file, I get a message to choose application:


Habing aborted that try, when I then try, alternatively, to open the .popclipext file with PopClip, I get this message:


Here is a link to the Config.plist file.

Don't double-click; right-click, then choose Show Package Contents.

The option to Show Package Contents does not appear in the contextual menu. It does with other PopClip extensions.

Then whichever .popclipext file does not have a Show Package Contents option available is either not a package file (and therefore not a PopClip extension), or is in a folder that has strict user access control rights. I think the latter is unlikely given that the PopClip "Extensions" folder itself allows you to inspect its files' package contents.

To make the .popclipext file I simply compressed the Config.plist file and the Applescript file into a .zip archive, then changed .zip to .popclipext

Am I missing something about making a package file? (Probably!)

Thanks for your patience.