Keyboard Maestro Blog Posts

August 28, 2018

Keyboard Maestro and LaunchBar Clipboard Management

Keyboard Maestro and LaunchBar have excellent activate clipboard history switcher. Having both of them enable allows you to get the best of both worlds when you need it.

Keyboard Maestro Advantage

  • You can keep the Clipboard History Switcher and mouse click what you need.
  • You can "pin" clipboard items so you won't loose them.
  • You can preview more of the images in the dialog box.

LaunchBar Advantage

  • Simple Interface, simply select the text and the dialog goes away.
  • Perfect for the quick clipboard history use.
  • ClipMerge - Press Command-C twice to merge the copied data with the latest clipboard content. Useful for list building.

Trick to have them Both Enabled

One trick to having multiple Clipboard management is to have a similar hotkey. This is the setup that I have for both:

  • Launch Bar: Command ∖
  • Keyboard Maestro: Shift Command ∖

Clipboard History Switcher
Settings in LaunchBar and in Keyboard Maestro.

This makes it easy to switch between the two functionalities and use the one that is perfect for me right now.

August 21, 2018

AppleScript iTerm2

iTerm2 is a popular Terminal replacement for Apple’s Terminal application. It provides the ability to create profiles with unique text colors, window appearance and key mapping.

Here’s a simple Keyboard Maestro Macro to open a new Terminal Session from any application.

KM Postgres

AppleScript Code

tell application "iTerm"
set myString to "echo -ne "33]0;"Database Server"07"" set newWindow to (create window with profile "Postgres Server") tell current session of newWindow write text myString end tell end tell

Why Have This Macro?

This comes in handy when I want to open up iTerm2 and go to a specific site..I don't have to open up iTerm2 and then switch to the profile and then select the profile.

August 14, 2018

MultiMarkdown Utility

I have been working with Markdown a lot lately. Trying to convert markdown to HTML has been a bit tricky. One solution that I found was MultiMarkdown. It's a command-line package that allows you to quickly convert markdown to HTML.

After playing with the tool for a while, I figured it's worth making a Keyboard Maestro Macro out of it.

Download the Latest MultiMarkdown Utility

To download the latest version of MMD and core tools, visit the GitHub project releases page, there is a MacOS

You can find additional information on using MultiMarkdown on page.

Sample Macro in Keyboard Maestro

Here's a sample of the Macro that I have created to integrate with MultiMarkdown. The goal of this Macro is to take the Markdown content of the clipboard and convert it to HTML format.

KM Mark Down

Note: I am still working on ways to make this Macro better, I thought, for now, I should share what I have to help others.

August 7, 2018

Trigger Macro by Name

Trigger Macro by Name is an easy way to access your Macros. This is useful when you don't want to assign a keyboard shortcut because the action isn't used all the time. It's also a good way to execute a macro when you can't remember the trigger command.

Creating the Trigger Action

Trigger Macro by Name isn't enabled by default, you have to create a Macro to get this working.

  1. Create a new Macro, put it in the default Global Macro Group
  2. Create a useful trigger action, Keyboard Maestro recommends: Control Option Command T
  3. Insert the Trigger Macro by Name Action
  4. Save

Now when you use the Control Option Command T you'll be able to access any active Macro in Keyboard Maestro.

Trigger Action By Name

Cool Tip

Make the initial search as use:10m that way you'll have instant access to any macro when you trigger the command.

July 31, 2018

Recent Activity Smart Group

Every once in a while a Macro might accidentally get triggered. Wouldn't it be great to figure out which one got executed - so you can fix the trigger action?

There are several ways to find the most recent triggered action, but the simplistic way is to create a smart group which shows the most recent triggered action.

Recent Activity

Creating a Smart Group

  • With Keyboard Maestro open type in Option Command N
  • In the Group section. you should see a new Smart Group created called "Untitled Smart Group"
  • I suggest renaming it to "Recent Activity"
  • Under the "Matches any of these search strings" put in "use:10m" (Or what ever duration you want) Tip: The shorter the duration, the fewer results will be shown.

For my smart group settings, I set the configuration to be within the last 10-minutes. I feel that gives me plenty of time to get to Keyboard Maestro and fix the issue.

Having a "Recent Activity" smart group is also useful if you need to edit a recently triggered action because it didn't do something right. As you don't need to search for it, you can be sure it will be in the "Recent" smart group.

July 24, 2018

Clipboard URL Tracking

Keyboard Maestro has the ability to perform certain actions based on an activity, such as when a USB card is inserted or when you connect to a network. It makes Keyboard Maestro a really powerful application.

Working with the Active Clipboard

One of the monitor activities is the ability to watch the clipboard. That got me thinking. What if there was a way to save the URL that I pasted in the clipboard? That way I can use it later whenever I like.

The goal would be watch changes pasted in the clipboard, and if there's a URL assign it to a variable.

Clipboard activity

This is the Macro that I came up with:

Active U R L Tracking

Some Notes on my Macro

I am using the matching condition because the URL can vary from http to https. I can change this even more by looking at certain URLs or Domains.

I am only concern with tracking events that I copy from the location field in Chrome or Firefox.

If the clipboard doesn't start with a URL do nothing.

I created another macro that would echo the value of ActiveURL whenever I type in show.url.

The nice thing is that I don't have to think about the activity, it just happens in the background.

There's a lot of other activity I can do with the URL, but that's a post for another day.

July 17, 2018

Date Conditions with Macros

One thing that makes Keyboard Maestro a productive tool is the ability to add conditions to Macros. Keyboard Maestro describes the Conditional If-Then-Else Statement:

The If Then Else action allows you to choose which of two sets of actions should execute. If certain conditions are met then execute one list of actions. If not, execute another. If there are no conditions set then no actions will execute.

Having the If-Then-Else feature, I can display a different text output based on the day of the week that I call the Macro.

Perhaps this situation will be helpful:

When testing tickets I need to add a comment in Atlassian Jira that the issue pass testing. I use Keyboard Maestro as my text template. When testing on Wednesday, I am validating issues that are on the staging server but there's no tag - yet. Only issues tested on Thursday will have a tag, and my comment should reflect that tag.

Using a single Macro with a date condition, I can just type one trigger and the correct text will appear based on the time of day/week that I execute it. This makes it easy to remember one macro for similar actions.

Here's an example of the Macro that I have set up:

Keyboard Maestro Condition Macro

Some Notes

The %ICUDateTime%e% outputs the day of the week (1-7). When the day is 5 or greater, than the condition is true and the first statement gets executed. Otherwise show the second statement. Get the full details of all the ICU Date Time functions.

You can see the condition statement is being evaluated in Keyboard Maestro. See the currently false at the top of the If statement. This is helpful to know if your condition is really working.

The Text format in the "Insert Text by typing" field is formatted for Jira.

You can have any type of condition, check for application, mounted volume, clipboard content and so much more!

July 10, 2018

Execute Shell Script

One of the nice things about is the ability to run Shell Scripts as part of a Macro action. This is useful when you want to apply a clipboard text to a shell script or just to execute a shell command.

Recently I wanted to set up a Status Menu action to simply run a shell script. I am doing some automation work and frequently need to test code changes. it's just easier to have a status menu than to open up a terminal and execute the run command.

Simple Setup

To execute commands, simply use the Bash Shell:


Keyboard Maestro Shell Script

Some Notes about Shell Execution

  • You can ignore the output results. (nice feature if you don't need to see the debug information)
  • I have an ampersand after the so the command would run in the background. There is the ability to run the command asynchronously in Keyboard Maestro.
  • In my execution script, the directory where it's being executed from makes a difference, so I needed to change directory before running the command. I didn't use the 'Script File' method.
  • To run PHP commands you would type in: #!/usr/bin/php

Oh, more thing, if I want to run the command frequently, I can instantly change the macro to be included in the Global Macro Palette. It's a simple switch of the trigger type.

There's a lot of options available, including the ability to pass variables to the shell command. The Keyboard Maestro help section has a lot of detailed information on setting those up.

July 3, 2018

Application Switcher

Keyboard Maestro’s Application Switcher is a very powerful way to navigate between active applications. You can quickly go from one application to the next.

Keyboard Switcher2

A Step Above Apple’s Switcher

What’s separates Keyboard Maestro’s Switcher than Apple:

  • You can have define applications to always appear in the Switcher, making it easy to access applications that you can’t justify having in the Dock.
  • You can exclude applications from showing in the application switcher - even if they are open. This helps cut the clutter.
  • You can open multiple applications. So if your working on a database project, you can open multiple apps at the same time - Such as Terminal and pgAdmin.
  • You can have multiple application switchers so that certain apps only show during certain hours during the day.
  • Keyboard Maestro application switcher is easier to configure.

Using the Application Switcher, you can simply enable the command and then select the application. But there are a few additional commands available.

Some Shortcuts

When the Application Switcher is in focus, keep the Command key and use the mouse and these keys to perform actions:

q Quit Application
k (twice) to mark an application to Force Quit
s Make application hidden
l Mark application to launch (You can select more than one!)
a Hide “Always Show” applications
j Show applications that were recently quit
i Get Information on the selected application

If you accidentally hit the Application Switcher, simply hit the escape key to close it.

Easy Force Quit Feature

I personally like the ‘Force Quit’ feature. It makes it so easy to quit out of an application that is stalled. (Much better than having to remember the keyboard shortcut.

When you see the “beach ball” and it appears the application is stuck, simply activate the application switcher and then kk the application to force quit.

June 26, 2018

BBEdit TextFactory in Keyboard Maestro

Did you know that you can tap into BBedit's TextFactory in Keyboard Maestro?

What is BBEdit's TextFactory?

BBEdit Text Factory is a user-defined set of text command done in a particular order. You can do simple tasks such as Change Case, Sort Lines, and simple search and replace in a particular order that works for your situation.

Why use it in Keyboard Maestro?

The key reason to use TextFactory functionality is that it puts the best of both applications together. You use Keyboard Maestro to define the action, and then let BBEdit do it's work.

Sample TextFactory Action

Zap Gremlins Graphic

Zap Gremlins is a common action that I do with BBEdit. I use it to remove all those smart-quotes and other hidden characters that I don't want to appear in the text.

Sort Lines Graphic

Sorting List is and then Capitalize the words is another common task that I would do in BBEdit.

Both of these are Menu items so that it's easier to invoke them when I need to.

Some Notes

  • Text Factory files are usually stored in ~/Library/Application Support/BBEdit/
  • Double check Keyboard Maestro for some text commands as there are plenty of built in tools that might be easier to do in Keyboard Maestro.
  • Applying a BBEdit Text action will cause Keyboard Maestro to open up BBEdit.
  • Learn more about BBEdit TextFactory

June 19, 2018

Quick Way to Add Actions in Keyboard Maestro

Quickest way to add an action to a Keyboard Maestro Macro is to use Control - Command A

This will bring up a Spotlight like search:

Add KM Action

Type in a word that best describes the action you are looking to add - For example, type 'Chrome' if your looking for action that's around Google Chrome.

After using this for a while, you'll see how this is much better than using the 'Add Action' button in the Macro.

Remember to add an action to a Macro type in: Control Command A.

June 12, 2018

Smart Groups in Keyboard Maestro

Smart Groups in Keyboard Maestro is a way to filter macros based on any search criteria. This works very similar to how Smart Folders work in Finder. Anything you search for can be a smart group.

Legacy Macro Smart Group

Wouldn't it be great to track macros that you're not using? Perhaps these macros are from an old project? It would be handy to know which macros that you're not using to declutter your Keyboard Maestro library.

There's a Smart Group query for that -it's easy to find active Macros that you haven't used in a while. Here's a query that I have set up:

nonuse Macros

Search Query: e: -use:5w

This query basically says, "Show me all active macros that have not been executed in the past 5 weeks.

Here's an alternative version:

Search Query: e: -use:365d

This query basically says, "Show me all active macros that have not been executed in the past year.

Some Other Smart Group Ideas

Here are some other ideas for Smart Groups for Keyboard Maestro:

  • Search Query: %Variable%release - Show macros that are using a certain variable
  • Search Query: curl - Show macros that are using curl
  • Search Query: ?php - Show macros that have PHP scripts enabled

Search Query Help

You can find a list of all the queries on the Keyboard Maestro Help page. There's a lot of cool search queries commands available.

Smart Groups are Great

Keyboard Maestro Smart Groups are a great way to find similar macros. This functionality comes in handy when you need to update a bunch of macros - for example: if you updated a common library file.

June 5, 2018

Keyboard Maestro Macro Library

The Keyboard Maestro Macro library is a good Macro Library where you can some good ideas on Macros to create. Before you spend any time creating a Macro, it's worth looking to see if someone already created one.

Keyboard Macro Library

Type in Command-2 to view the Macro Library. There is a search box on the bottom if you are looking for a certain functionality. Just make sure that "All Entries" category is selected.

Keyboard Macro Library

Online Help

In the Keyboard Maestro forum, you can find additional Macros that people have created. This is a great way to learn about the application and get some ideas on how to use Keyboard Maestro.

There are two Libraries to pick from:

May 29, 2018

Milliseconds to Seconds Converter

This is a quick Macro that will activate when I need to convert the number on the clipboard (Milliseconds) to seconds.

In Action...

I simply select the value, then type in my trigger action keys: .mill then the value gets typed in.

So 23893 will become 0:24 - you can configure this so that it can output whatever format works for you.

Keyboard Maestro Script


The Javascript that I used for the calculations:

var app = Application.currentApplication()
app.includeStandardAdditions = true
var kmInst = app.systemAttribute("KMINSTANCE");
var kmeApp = Application("Keyboard Maestro Engine")
var myLocalVar = kmeApp.getvariable("Local__MyVar",  {instance: kmInst});
kmeApp.setvariable("Local__FromJXA", {instance: kmInst, to: "Set in JXA Script"})
function millisToMinutesAndSeconds(millis) {
  var minutes = Math.floor(millis / 60000);
  var seconds = ((millis % 60000) / 1000).toFixed(0);
  return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
millisToMinutesAndSeconds(myLocalVar); // "4:59"

May 22, 2018

Random Keyword

Having a random word comes in handy when you need a word but want to be creative and something more than just 'abc’ or ‘xyz’.

Random Keyword in Keyboard Maestro

Here’s the random keyword macro that I have setup in Keyboard Maestro.

Click on image for the full view of the macro.

$words_file = fopen("/usr/share/dict/words","r");
$words_length = filesize("/usr/share/dict/words");

function random_word() {
  global $words_file, $words_length;
  $rand_offset = rand(0,$words_length - $words_length % 1024);
  fseek($words_file, $rand_offset - $rand_offset % 1024, SEEK_SET);
  $words = explode("n", fread($words_file, 1024));
  $rand_word = utf8_decode($words[rand(1, count($words) - 1)]);
  $description = str_replace("'s", "", trim($rand_word));
  return trim(ucfirst($description));

echo random_word();

There are many ways to generate a random keyword from the Apple System dictionary file. Using the above PHP method has worked for me. In the above example, I remove any 's in any keywords because they were breaking some testing that I was doing. In addition, the keyword isn't returning any breaking space and the first letter will always be upper case.

A couple of Problems with a Random Keyword

The only problem with this is that the keyword is always random. I have no idea the word is that I used. Well, what if I wanted to remember the last random keyword that I used? (Filename or something.)

That's why Keyboard Maestro comes in handy! In the above example, I have the random keyword set to a variable before it was displayed.

Getting the Last Random Keyword

Here’s a Keyboard Maestro's Macro that I have set up to get the last used random keyword:

Repeat Word Y Y

The Other "Problem"

Every now and again the random keyword generator will echo an inappropriate keyword. The best way around this is to use a different dictionary file.

Easy Way to get a Random Keyword

Whenever I need a random keyword, I type in xx. When I want to recall the last random word generated, I type in yy.These are quick and easy strings that I don't have to worry about accidentally typing.