The Robservatory

Robservations on everything…


Keyboard Maestro

Open URLs in either frontmost or default browser

Between Many Tricks and this blog, I spend a lot of time in browsers. Most of the time, I use Safari, but I do occasionally work in Chrome and Firefox, too—most often to check how a page looks or functions.

I keep my “permanent” bookmarks in Safari, and don’t presently use any sort of cross-browser sync. (I used to use one, but had a lot of trouble with duplicates, so I stopped.)

I wanted a way to open a limited number of URLs in either Safari (if that’s what I was in, or if I wasn’t in a browser), or in the frontmost browser, if that browser were frontmost. I could just create the subset as bookmarks in each browser, but if I wanted to add or remove a page from the list, I’d have to do so multiple times.

In the end, I came up with a set of Keyboard Maestro macros that do exactly what I want. I access my short list of multi-browser URLs via Keyboard Maestro’s pop-up palette, as seen at right.

This appears when I press ⌃1; after that, a single digit opens the desired URL. But how does it know whether to open the URL in Safari or one of the other browsers? It takes one helper macro, then one macro for each URL that I want to open in this manner.


Install and use a non-GUI connection speed test tool

Yesterday on Twitter, Dave Hamilton tweeted…

What is this speedtest exactly? And what is brew, you may also be wondering? You may also be wondering why, if you have brew, Dave’s command doesn’t work…that’s because it’s actually brew install speedtest_cli…but I’m getting ahead of myself.

speedtest is a command line interface (i.e. Unix app run from Terminal) to the connection speed tests at—you get the results without the fancy animated graphics. And Brew is “the missing package manager for macOS.” In other words, it’s an app to help you install (and uninstall) other apps.

Here’s how speedtest looks in its default mode—note that I’ve sped things up greatly for the GIF…

Much nicer to me, though, is the simplified version:

$ speedtest_cli --simple
Ping: 9.482 ms
Download: 94.23 Mbit/s
Upload: 68.66 Mbit/s

No animated dots, just three lines with the results. As you might expect if you read here regularly, I also wrote a Keyboard Maestro macro (of course I did!) that makes it really easy to run the simple version of the test, and does some editing of the output to simplify the display:

If you’d like to install speedtest (and maybe add the macro)—even if you don’t want to install Brew to do so—keep reading…


How I organize my Keyboard Maestro macros

This post was originally published in Decwember of 2016. I took it down to replace one section (using repeats) with anothet (using groups), and to expand some other areas.

I’ve been using Keyboard Maestro (or KM for short) a lot lately, i.e. Create an iTunes song info window or A much improved special character palette, or a slew of others.

As my collection of macros has grown, and some of those macros have gotten more complex, I’ve been using a few of KM’s features to help keep my macros organized, and make it easier to debug them while I’m working on them. Some of these are obvious, some maybe not so obvious, so I thought I’d share what I’m doing.


Count characters in Keyboard Maestro inputs via filters

Yesterday, I added an SSL certificate to my site, and posted a brief note about the change. In that post, I included an image…which turned out to be, well, the comments say it all:

Yes, I posted a non-https image in the ‘site is secure’ post. Sigh.

So I took Jonathan’s comment to heart, and created a Keyboard Maestro macro that ensures I post only relative URLs from now on.

Generally, I don’t think such a thing would be worth sharing, as it’s just a basic text replacement macro, right?. Mostly right, but in this case, I learned about a Keyboard Maestro feature that may be useful to others. So share I will…


See the launch date and time for any app or process

I was working on something with Peter about Moom and its disk usage (it doesn’t use much), and I was curious as to just how long Moom had been running on my Mac. I last rebooted my Mac a week ago, but I often quit and relaunch our own apps to run test versions.

Finder has this info, but that requires finding the running app in Finder. I wanted a quicker solution. In Activity Monitor (and ps in Terminal), you can see how much CPU time an activity has taken…

…but that doesn’t really help at all with knowing when the app (or process) launched. As long as you’re in Activity Monitor, you can get the information by doing the following:

  1. Click once on the app or process of interest.
  2. Press Command-I or click the small ‘i’ icon in the toolbar.
  3. In the new window that opens, click Sample, then wait.

When the sample is complete, you’ll see its output, and included there is the selected item’s launch date and time:

Analysis of sampling Moom (pid 89861) every 1 millisecond
Parent Process:  ??? [1]

Date/Time:       2017-02-15 07:41:18.611 -0800
Launch Time:     2017-02-13 19:44:11.957 -0800

That’s all fine if you’re in Activity Monitor, but a bit of a pain if you need to launch it, find the app, run a sample, etc.

As you might expect, there’s another way via Terminal: The lsappinfo command, which queries CoreApplicationServices about any app or process on your Mac.


Transport the cursor to the center of frontmost window

My home workspace is a 27″ Retina 5K iMac (2560×1440) paired with a vertical 4K display (scaled to view 1440×2560). While I love this setup in general, there’s one time it’s annoying: When I need to move the cursor between displays, and it’s located far away from its destination.

There are many ways to solve this problem, including our own Keymo, which I still use when I want to teleport a drag across displays. But what I really wanted was a fast way to move the cursor to the other display when I switched to a window on the other display—because generally, if I’ve activated the window, I’m probably going to use the mouse in that window at some point.

Using Keyboard Maestro, it’s possible to create a macro to make this happen automatically:

This macro will activate every time you switch applications, and then move the mouse to the center of that newly-frontmost window and highlight its location with a quick circle. Having tested this, however, I can say it’s a non-ideal solution: Most of the time when I switch an app, I do not want the cursor to move. I found it more annoying—much more annoying—than useful.

As useless as the above macro is, with one minor change it quickly became one of my most-used macros…


Transforming text via Keyboard Maestro

Recently, Melissa Holt wrote about transforming text via the Transformations menu. After seeing this article, a reader named Hunter wrote to me with this comment:

Today in The Mac Observer Melissa Holt wrote about using the TextEdit/ Edit/ Transformations command to change the case of a sentence or paragraph. However, there is no option to perform, “Sentence Case”, i.e., capitalize the first letter of the first word, and keep all other words in lower case.

Is there a way in Terminal, or maybe Keyboard Maestro to add this option to Transformations? It seems to me that the given choices have rather limited uses.

In addition to not offering sentence case, the Transformations menu has a few other drawbacks:

  • Not all apps have a Transformations menu.
  • Only three very basic transformations (upper, lower, capitalize) are supported.
  • The transformations are buried in a sub-menu, requiring lots of mouse navigation to reach.

While I don’t believe it’s possible to modify the Transformations menu, it’s pretty easy to use Keyboard Maestro to build a “Sentence Case” transformation…or more usefully, as seen at right, a palette with many more transformations. Unlike the Transformations menu, the Keyboard Maestro solution will work in any app where you can copy and paste text.


Create a pop-up web search tool using Keyboard Maestro

My original Keyboard Maestro special character palette (which has been replaced by a much better version), used the Conflict Palette to display a window from which you could pick the special characters.

While this turned out to not be ideal for the special character palette (no way to pick more than one at a time), the Conflict Palette is ideal for many other tasks.

I use the one at right to search a number of web sites—activate the palette with ⌃⌥L then press a, for instance, type a query, press Return, and my browser loads with search results from my old site.

Feel free to download my macro if you’d like to use/modify it.

I use a couple additional palettes—one for retrieving iTunes’ artwork and searching the store, and the other for inserting commonly-used bits of code while writing help files in Coda for the Many Tricks‘ apps.

Here’s how the web search palette looks in use; I love being able to search a specific site from anywhere without first switching to my browser. And because I have Keyboard Maestro syncing its macros, I can do this from any Mac I own.

The advantage of using the Conflict Palette for these web searches is that I need only remember one shortcut, not 11 different ones, and the palette is a nice visual reminder of which service I wanted to search.


A much-improved special character palette

A while back, I created a pop-up character palette using Keyboard Maestro to allow easy insertion of the Mac’s special characters (like , ⌘, ⌥, etc.). While this worked fine, I discovered a few major shortcomings:

  • I couldn’t create more than one character without calling up the palette again.
  • I had to decide in advance if I wanted HTML entities or the actual characters.
  • Two palettes (HTML or character) meant two keyboard shortcuts to remember.
  • Adding characters to the palette was a real pain, because they had to be done twice.
  • I was out of digits for shortcuts, so I was going to have to change the palette structure.
  • It was slow: From calling up the palette to identifying which icon I wanted to use to selecting that icon, and then doing it all again for a second character was just really slow.

I set out to fix all of these issues, thinking I could use Keyboard Maestro’s Custom HTML Prompt action, as I did for my iTunes song info window. And, in the end, that’s what I used for the new-and-improved character palette:

This doesn’t have to be used just for Mac special characters, of course. You could make yourself a customized pop-up for emoji, math symbols, whatever…

Read on for the how-to and download, if you’d like to put this to use…


Automatically prevent Messages’ URL Previews

I spend a lot of time in Messages in macOS, and one of its newer features is something called link previews, as seen at the right side of this text block.

While these previews can occasionally be useful, most of the time, they’re just annoying: I’m talking with people I know, and we trust the links we send each other, so the preview is superfluous. Plus it makes it nearly impossible to rickroll anyone. But what’s really annoying is that they make it impossible to send messages like this:

Oh, have you seen [paste copied URL]

Try that, and the URL becomes a preview, and the question mark vanishes. It really interrupts conversational flow. You can prevent this by either writing text on both sides of the pasted URL, or surrounding the URL with angle brackets:

Oh, have you seen < [paste copied URL]>?

So there’s the quick tip: To prevent link previews, surround your pasted links with either text on both sides, or more simply, angle brackets.

But because I often forget to do that, I wanted it to be automatic. Thanks to Keyboard Maestro, I was able to make that happen: When I paste a link in Messages—using the system’s standard ⌘V shortcut—it’s enclosed in angle brackets. If I paste anything other than a URL, it’s pasted as is. If I do want a preview, I can use the actual Paste menu item instead to get a link with preview.

This solution is perfect for my needs, as I always use ⌘V to paste, and I so rarely want to send a link preview that it’s OK that it requires a trip to the menu. (If it ever does annoy me, I’ll just remap Paste in Messages to ⌃⌘V or somesuch.


The Robservatory © 2017 Built from the Frontier theme