86: Micro-Automations

1 Like

Hi, Rosemary & David, regarding the automation of the preference panes I’ve found this article in LinkedIn that shows how to use callback URL to call some of them. It even includes a z-shell script to check which ones are available.

1 Like

Long time listener, first time posting.
This episode was so good, I never actually looked at PopClip because I thought it only did what selecting text does on iOS, but plugins can open up a whole world.
Moving my first steps with that app, I am wondering how to accomplish 2 things:

  1. Not only send some text to Drafts, but also have Drafts immediately perform an action when it receives it (this way, I can pick up some text and having it sent via POST to a database, I already have a Drafts action for this, but triggering it from PopClip would round the square for me).
  2. Trigger a Keyboard Maestro action with the selected text as parameter (in order to also perform a complex POST action to that database).

Anyone already used PopClip to trigger Drafts actions or KM macros?

Google was my friend, at least for the 2nd question regarding Keyboard Maestro…

Update 2
I was able to achieve both things :slight_smile::

  1. For executing the Drafts action from PopClip, since I don’t want to actually create a Drafts note but only use Drafts as a jumping point for my existing POST script with the current PopClip selection, I didn’t need to include a script in my new PopClip extension, it was enough to add a URL key in the Config.plist file with this format: drafts://x-callback-url/runAction?text={popclip text}&action=My%20Action%20With%20Spaces.
  2. For Keyboard Maestro, I basically followed the instruction of the blog post I linked above.

Both things work like a charm and will save me lots of time every day, so for me this was one of the best episodes ever. Thanks again for opening my eyes!

1 Like

I’m so glad you enjoyed it! I never liked the idea of the PopClip popup for copy/cut - my fingers are on the keyboard for that already! But smile-ifying an Amazon link? Heck yes!

1 Like

Yes, it was the reason I only superficially looked at PopClip in the past: we’re automators, we never leave our keyboards, right? But for me these two things were the perfect scenario of different Mac automation tools working together.

1 Like

Interesting episode this one. I have a question along with a few points.

1. FastScripts

Having been a MarsEdit user up to the point SquareSpace dropped XML-RPC support, I’ve been a fan of Daniel Jalkut’s work. As a result I’ve looked at FastScripts a handful of times in the past. But I’ve never been able to identify what this would offer me over Keyboard Maestro, the Apple standard Scripts menu, and even Services (for keyboard shortcuts). Therefore I was intrigued to hear that @RosemaryOrchard used it in combination with software like Keyboard Maestro.

I’d be interested in hearing from anyone on what the feature or features are that make FastScripts an addition when you might already have something like Keyboard Maestro to trigger scripts.

2. AppleScript Support in Drafts

@MacSparky mentioned in the episode that Drafts has “great AppleScript support”. While I am a big advocate for Drafts, I would have to disagree with David on this. While Drafts does have the option to run AppleScript from Drafts actions, or in fact any shell command/script, the support to interact with Drafts from AppleScript is very limited. In fact, this is it in its entirety.

Using Drafts from AppleScript

We are working on exposing more of Drafts features to AppleScript, but to get started implemented the ability to create drafts. This should be useful for incorporating capture with other automation tools. Example:

tell application "Drafts"
   make new draft with properties {content: "My Draft Content", flagged: false, tags: {"blue", "green"}}
end tell

Greg has noted that developing the AppleScript support is something he wants to do at some point, but to date it has not really changed since this was introduced.

3. AppleScript Dictionaries

I’m far from being an AppleScript expert. I know enough to get by for most of the time, but I often have to refer to examples to get things working properly. However, I think the discussion of dictionaries was misleading; though I’ll certainly yield to anyone who has more AppleScript experience.

The second example of AppleScript dictionaries, where they are documentation of what applications offer to the AppleScript language/system, I believe is correct, and is the only dictionary in AppleScript.

I think the first example was referencing what dictionaries are in more general programming terms, but that isn’t what they are in AppleScript. In AppleScript, things in curly braces ({...}) are known as “lists”, sets of unstructured, independent items of data in a single group. When you place object properties in lists, the lists then become structured data and are referred to as “records”. I think the first examples given during the podcast episode for dictionaries were actually examples of AppleScript records.

If you search for dictionaries and AppleScript, you’re going to find references to sets of app documentation, hence I think it is important to clarify the use of terms. Not all concepts have the same name in every language, but having the right term for the language you are using makes it much easier to find what you are looking for in the documentation.


Nice to finally have an episode that does not focus on Shortcuts!

Hope we will get more of these (I almost quit listening because of the narrow focus… :speak_no_evil:)

While Drafts does have the option to run AppleScript from Drafts actions, or in fact any shell command/script, the support to interact with Drafts from AppleScript is very limited.

Just yesterday while handling the task I mentioned above, I was actually surprised by how little AppleScript Drafts suppor has; it makes sense being an app arrived from iOS, but I hope someday the ability to add tags and trigger actions is added to the dictionary.

Adding tags is there for new draft creation in AppleScript. It is in the example above.

To work around the Drafts AppleScript limitations on the Mac, I make heavy use of the much more expansive URL scheme options. They allow you to run the actions, add tags, etc.

If you want an idea of what is possible, I built a lot of Doctor Drafts for Alfred on those URL schemes :wink:

1 Like

OMG, you’re the deity I have to thank for Conductor for Keyboard Maestro!

Thanks for pointing that out about the tags, I missed it.


I use the copy and paste A LOT because I’m very often copying text from web pages, and there’s nothing faster and more precise for this than my mouse. Yes, I’m good with “right hand on mouse, left hand hovering over command-C,” but the easy of the pop clip menu is a lot faster.

So much of the power of pop clip is personalization. The clip I use most often takes the selected text and searches for that text in Linkedin. I doubt 99% of society would ever have a use for that, but I run an executive search firm, so I’m using it to look up names 10+ times a day.

And I love the call out from @cdf1982 about connecting Popclip to Keyboard Maestro. I can select a person’s name on a webpage, and through popclip, send that name to keyboard maestro, which inverts the name from “First Last” to “Last, First” and then pastes that text into our database. Again, probably wouldn’t be valuable to 99% of society, but for me, it saves SO much of my time.

1 Like

Quick question for the Popclipsters:

I heard Rosemary talk about her Amazon Smile extension and since I have been manually cleaning Amazon URLs before sharing them, I thought this would be perfect. So I downloaded Popclip, downloaded her extension, and installed both. Went to a website with some text and highlighted it, and clicked the little Smile A. It asked if I wanted to allow it (Popclip) to control Brave, and I said Yes. Then nothing…

So I tried it again, nothing happens after I click the little A :slight_smile: icon. So I thought perhaps it only works if I highlight text in the browser URL bar… but doing so does not bring up Popclip.

So I unzipped the extension, copied out the ruby file, and ran it by hand on the command line, e.g. POPCLIP_TEXT=https://www.amazon…lotta_junk_here ruby script.rb and that does print out a clean URL, but isn’t quite the automation I was hoping for :slight_smile:

So what am I doing wrong? Any pointers appreciated.

1 Like

I’m still interested in other people’s insights on this, but in the interim, I came across this, and the FastScripts v3 beta with some interesting features. I think for me with v3, there perhaps is some additional benefit to be had.

Rosemary’s Smile extension should work when you select editable text containing an amazon.com link. For example, the link in the address bar of an amazon.com page.

PopClip should show up if you highlight text in Brave’s address bar, but it can be a little bit fickle there because address bars tend to be “clever”. Your best bet is usually just to click the text in the address bar and PopClip should appear automatically.

(I’m the developer of PopClip, hi everyone :wave:)


It should work with any link containing www.amazon, as I often use different ones!

I’ve found Electron apps in particular (Discord for one!) to be a bit dodgy when it comes to allowing PopClip to trigger. Often triggering it manually (in my case, through FastScripts and AppleScript), does the trick - but not always.

And thanks for popping in! We love having developers of the great tools show up here :grin:

1 Like

Ah yes, not just .com, indeed!

Yes unfortunately there are some apps that don’t play along nicely with PopClip. A big part of my time is just keeping up with changes to apps and the OS itself, to keep it working (as) smoothly (as poss). If you ever run into anything where it consistently doesn’t work, do let me know as there is often some tweak I can make. (I’ll take a look at Discord.)

1 Like

Very good, thank you for the reply. I guess I haven’t quite “gotten the hang of it” yet. Now if I select a URL in the address bar of Brave or Safari, it will change it to the Smile link. I have been trying to use it to select URL’s within web pages (expecting that when I clicked the Smile icon it would open that reformatted url in the browser).

I can highlight Amazon links on Amazon pages opened after a search in Brave and the little Smile icon displays, however in Safari doing the same thing does not yield the Smile option. Highlighting the links in your previous response in both browsers does however give me the Smile option, but clicking it does nothing as far as I can tell.

So is it then true that this works only on links actually in the address bar? If so, that is now working. Thank you!


That’s certainly something I could add to that action! But I just intended it for reformatting the text that you already had in a text field somewhere (usually I find the item I want to share on Amazon, and then reformat it either in the URL bar before copying, or if I forget that, on the pasted result).

Makes perfect sense, and works just like that :). Now that I have my expectations in line all is good. Thanks to all for the assistance!

1 Like

Just wanted to make sure @RosemaryOrchard knew there are some Alfred workflows that let you select the audio input/output devices directly from Alfred, don’t have to open the system preferences at all.
This is the one I use, there’s a few others on packal.

1 Like