Has anyone kicked off a KM workflow from PopClip?
Alternatively simulated it?
PopClip pops up a palette of macros to act on selected text.
Has anyone kicked off a KM workflow from PopClip?
Alternatively simulated it?
PopClip pops up a palette of macros to act on selected text.
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.
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:
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.
See:
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@.
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.
@ 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.
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.
Here's a blog post with all the code in - plus an explanation. (Wrote it today after rewriting my code.)
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.
Brian