Here’s an example of how you can use Keyboard Maestro to create bookmarks that use dynamic components. For this example I wanted to create a bookmark that would give me the correct URL to get a report of the last 365 days of Toggl time entries. Toggl lets you pass a start date and an end date in the URL. Using KM it’s easy to replace those values with calculated date values.
Click the screenshot at the right to see the macro, which I’ve also provided here: Toggl entries for the last 365 days.kmmacros.
In the past I’ve used Shush to achieve a push-to-talk or push-to-silence setup on my Mac. It works alright but more often than not I forget which mode I’m in, or whether I’m silenced or not. This leads to awkward moments in meetings.
I’ve solved the problem using Keyboard Maestro. This macro, triggered via CTRL-m simple enables or disables the current “input” device (whatever is selected in the Sound preferences) by setting its level to 0 or 100. It’s a toggling macro so you can use the same hotkey to flip between the two states. Most importantly, though, is the nice popup alert that appears when you go into “disabled” mic mode. This window is hide-able if it gets in the way, and it also disappears if you re-enable (via hotkey OR the RE-ENABLE button). You can safely disable the “Custom HTML Prompt” action if you don’t want to see the prompt. Here’s what the popup looks like:
I was surprised to find that you can type variables into the tiny coordinate text fields. They get bigger when you do.
When executed, this will select a random item (excluding “- None -“) from the select list.
I use SnagIt to capture screenshots. The editor window that appears after you capture takes a few seconds to open if the application isn’t running. I realized that, while the capture tools remain open, the editor goes away when I hit ⌘W to close the window. Instead of using ⌘W to close the editor window, I sometimes remember to use ⌘H to hide the window, which hides the window but leaves the application open. The editor window pops open much quicker if the application is still open.
Using Keyboard Maestro I’m able to intercept the ⌘W that I do all the time (muscle memory), and turn that into a ⌘H.
If you’re like me, you take lots of screenshots. I probably average 20 a day. Primarily I use CMD-SHIFT-4 and drag a box around what I want to capture. The result is exactly what I highlighted. Here’s an example:
That looks fine, except there’s nothing that really helps the image stand out. It’s not ready for blog posts, documentation, or wherever else you’d like to use an image. I’ve approached the problem a few different ways in the past, but I’ve finally settled on a Keyboard Maestro-based solution for “Automatic” processing of these screenshots. I also have created a “Drop shadow” Service so you can apply a dropshadow to any image by right-clicking and using the Services menu.
This graphic illustrates how you can loop through each line of the clipboard and use the line’s value for some purpose. It also demonstrates how to handle the first line differently than the others.
This is zero-based. The second time through the loop will say “Line number 1” if you use the exact setup below. If you need your i variable to be “1” on the first loop, just move the i + 1 calculation above the If All Conditions Met Execute Actions and change the i is 0 to i is 1. Alternatively you could start i as 1 and change the i is 0 to i is 1.
Your Mac knows the last time you moved the mouse or pressed a keyboard key. We can use this information in Keyboard Maestro to perform actions based on whether we’ve “gone away” from or have “come back” to our computer. I’m using this technique to set my status in Slack to “Away” if I step away from my computer for more than 10 minutes, and back to “Active” when I return. Here are a few quick examples that could use this same basic framework:
- Automatically pause music if I step away
- Show me a “Welcome back!” message when I return
- Write the date/time to a log file the when I go away and when I return
Setup your macro with a “Periodically while logged in” trigger. In the example here I’m using 10 seconds because I want no more than 10 seconds to pass before my system detects that I’ve returned to my desk. The macro isn’t very CPU-hungry so 10 seconds shouldn’t be problematic.
Yet again I’ve found a great use for Keyboard Maestro. I’m a web developer and often have to create “filler” or “dummy” text during development. In the past I’ve used Alfred workflows, copy-and-paste, browser extensions, and more. I’ve recently come up with a much cleaner (and more powerful) solution to achieving field-by-field or one-off dummy text.
What do I mean by field-by-field and one-off? Well, I use tools sometimes to automate filling an entire form repeatedly (Fake, Selenium, iMacros, etc.). I’ve even written a Selenium extension to inject random text into the fields Selenium is automatically filling. Unfortunately, this all takes time. Sometimes I just need to fill some fields in a form a few times and move on. It’s not worth automating at that point. Enter Keyboard Maestro.
Keyboard Maestro offers many ways to trigger macros, but unfortunately there isn’t a URL handler that lets you trigger macros via a URL. There are a number of keyboardmaestro:// URLs handled by the built-in url scheme, but executing a macro isn’t an option. If you’re interested in triggering macros via bookmarklets and Finder shortcuts, read on…
I’ve written a URL handler that allows you to execute macros and pass variables to them. It’s a simple app that registers a URL handler to process kmlink:// links.
If you’re like me, on occasion you accidentally (or sometimes purposefully) include a password in a command. Until recently I would execute history , find the offending command’s number, then do a history -d NUMBER . It is kind of a pain.
The following deletes the last item in your bash history:1history -d $((HISTCMD-2)) && history -d $((HISTCMD-1))
You can create an alias for this, type it manually (umm, no thanks), or, as is the case for me, create a Keyboard Maestro macro for it. Here’s what my macro looks like: