Welcome to cryan.com
Keyboard Maestro Blog Posts

Keyboard Maestro is a very powerful Macintosh productivity tool. Each Tuesday, I highlight some cool example that demonstrates why every MacOS user should have it on their computer.

...
Keyboard Maestro Blog Posts

Keyboard Maestro is a very powerful Macintosh productivity tool. Each Tuesday, I highlight some cool example that demonstrates why every MacOS user should have it on their computer.

A list of all the Blog Posts in this category.

December 22, 2021

Shuffle Filter System Clipboard

One of the neat things about Keyboard Maestro is the Clipboard History. You can easily activate the Clipboard History Switcher and get back any content that was put in the clipboard. By default Keyboard Maestro will hold the last 200 items in the Clipboard History.

Additional Filters

Along with copy/pasting previous items, you can apply some filters to the text in the clipboard history. There are 21 filters included with every Keyboard Maestro installation:

  • Capitalize
  • Display as Text
  • Flip Horizontal
  • Flip Vertical
  • Font Awesome
  • Half Size Image
  • Lowercase
  • Lowercase First
  • Lowercase then Capitalize
  • Lowercase then Title Case
  • Move to Extra Clipboard
  • OCR Image
  • Remove Styles
  • Rotate 180-
  • Rotate Clockwise
  • Rotate Counter-clockwise
  • Set DPI to Nominal
  • Title Case
  • Translate
  • Uppercase
  • Uppercase First

When you apply a filter they don't happen immediately. A new clipboard entry is created and you can paste the content in. This way you can still get the previous clipboard item for future action.

Shuffle Time

New in version 10 is the Shuffle filter. Now you can easily shuffle the contents of the clipboard. This is useful when you have a list of names that you want to shuffle.

You can find all the details on how to add a new Clipboard Filter Trigger on the Keyboard Maestro Wiki.

Example Macro

Shuffle Filter

December 15, 2021

Backup USB items

This week's is a followup to the "Keyboard Maestro Copy File" blog post. In this week's post, I'll show you how to use Keyboard Maestro's actions to perform the same BASH function.

This is a great example of understanding the power that Keyboard Maestro has. While the BASH code is shorter in code, I feel the Keyboard Maestro version is more flexible in doing other actions.

Simple Task

Create a Macro that will copy all the documents in a particular folder and place a copy of them in a new location based on their created date.

Actions used

  • Get File Name to Variable
  • Get File Type to Variable
  • If All Conditions Met Execute Actions
  • Get Date Created to Variable
  • Set Variable to Text
  • Create New Folder
  • Copy File

Keyboard Maestro Macro

Sony Action Steps

These are the steps in the screenshot:

  • Pause for 1.5 Seconds - Wait for the USB drive to fully mount.
  • For Each Item in a Collection - For all the files in a particular directory on the Sony Recorder execute the following actions.
  • Get File Name to Variable - Save the file name to a variable to be used later.
  • Get File Type to Variable = Identify the type of file in this loop cycle.
  • If All Conditions Met Execute Actions - Now lets take actions only on files and not folders
  • Get Date Created to Variable - Get the file created date and assign it to a variable
  • Set variable to Text - Assign the date format to a human readable format. (Example YYYY-MM-dd)
  • If All Conditions Meet Actions - Check to see if the directory exists.
  • Create New Folder - Create a new folder if it doesn't exists.
  • If All Conditions Meet Actions - Check to see if the file already got moved over.
  • Copy File = Move the selected file to the directory
December 8, 2021

Keyboard Maestro Copy File

Last Summer I purchased a Sony IC Recorder (ICD-UX570). Its a powerful audio recorder that saves files on the internal drive or the microSD expansion.

In order to download the audio from the recorder, I need to connect the device to the computer and drag the files from the device to my hard drive.

I decided to create a Keyboard Maestro Macro that would do that process automatically.

The Task

The task of this macro:

When the device is inserted into the computer, copy the files from the Internal 4GB memory to the ~/Music/Sony/ folder. Each audio should be in a folder with the date the recording was made.

Keyboard Maestro Macro

This is the Macro that I came up with:

Sony Audio File

Now when I insert the Sony Recorder, the files automatically get copied. I don't have to think about it. I can still move the files if I want, but I am guaranteed that a backup copy was made to the computer.

Bash Code

#!/bin/bash
cd /Volumes/IC RECORDER/REC_FILE/FOLDER01
for f in *; do
dir="/Users/cryan/Music/Sony/"$(stat -f%SB -t%Y-%m-%d "$f")
# echo $f '->' $dir
[ -d "$dir" ] || mkdir "$dir"
cp "$f" "$dir"/
done

Some Notes

This was a quick fix, using BASH. There is a better way to do this in Keyboard Maestro using a lot of the built-in actions. Next week I'll show you the "official" way to do this using Keyboard Maestro

The "pause" is needed because Keyboard Maestro works immediately when the device is connected - the file system doesn't even see it yet.

December 1, 2021

Time Zone Convert

This past week I was scheduling a meeting with a counterpart in California. I was looking for an easy way to let them know the time of the meeting using Slack. I thought there would be some plug in to automatically display a time in EDT to other timezones.

There isn't a Slack tool. Instead of giving up, I decided to make a quick action in Keyboard Maestro.

TimeZone Convert Action

This macro is triggered via the status menu - since it's something that I don't use all the time. When I select the entry, a dialog box opens up and asks me to select the meeting time.

After I click 'OK' the output of the Macro will be sent to the clipboard.

Dialog Box

Meeting Time Dialog

After clicking 'ok' the following data is in the clipboard:

The meeting is at 4:00 PM EDT / 3:00 PM CDT / 1:00 PM PST

I can paste the clipboard data in Slack, Email, Facebook, or anyplace I need.

Keyboard Maestro Macro

This is what my macro looks like in Keyboard Maestro. I used the "Prompt for User Input" and "Execute Shell Script" actions.

Time Zone Converter

Python Shell Code

Provided here so you don't have to type in the information in the above screenshot

#!/usr/bin/env /usr/bin/python3
import datetime
import os
from datetime import datetime as dt, timedelta
from dateutil import relativedelta
kmTime=int(os.environ['KMVAR_Time'])
dt_object = dt.fromtimestamp(kmTime)
est = dt_object + relativedelta.relativedelta();
pst = dt_object + relativedelta.relativedelta(hours=-3);
cst = dt_object + relativedelta.relativedelta(hours=-1);
print(f'The meeting is at {est.strftime("%-I:%M %p")} EDT / {cst.strftime("%-I:%M %p")} CDT / {pst.strftime("%-I:%M %p")} PST')

Some Notes

I used Python instead of the built-in ICUDateTime function because it was a bit complicated to pass through a variable to the ICUDateTime function.

This Python shell script is a good example of how to pass Keyboard Maestro variables to Python.

I am sure the Python code could be cleaned up - just thought I share it in the basic form.

November 5, 2021

Keyboard Maestro 10

Keyboard Maestro 10 was released this week and it's packed with a lot of cool new features. You can find the complete list on Keyboard Maestro website.

The nice thing is that the developer is giving a discount for Keyboard Maestro 9 users. You can save $7 if you upgrade in the next 30-days. I would highly recommend getting the upgrade.

Three Features I am Excited About

Display in Menu Bar

Display in Menu bar allows you to make a Keyboard Maestro Group into it's own menu bar item. Now you can clean up the Keyboard Maestro menu by moving things out.

You can configure in what applications the menu bar appears. This way you don't have menu bar clutter in applications that won't use various macros.

You can only set Menu bar to real groups not smart groups.

Keyboard Maestro Menu Bar
Cool Trick here is to add your computer IP address to the menu bar.

Setting up the Group Menu bar:

  • Select a group on the left pane
  • In the far right pane, change "Do not display in menu bar" to "Display in Menu bar"

There's options to control what actually gets displayed - but that's for a later blog post.

Favorite Actions

Favorite Actions are a quick way to reuse common actions. Not only is the main part of the action in play, such as paste text, but also the various texts of that action. This is useful when you want to reuse certain actions over and over again.

One action that I have used multiple times is the "Set System Clipboard to Past Clipboard." I used this when I want to reset the clipboard content after running a macro.

Keyboard Maestro Favorties 2021
1. Select the Favorite in the Action category. 2. Available Actions. 3. How to add a Favorite.

To setup a favorite:

  • Open up a Macro.
  • Right click on an Action and click "Add to Favorite" (In the middle of the right click menu.)

To find all favorite actions:

  • Command Control A to open the Insert Action search box
  • Search for Favorite

Paste by Name Action

This allows me to paste clipboard history content that matches certain criteria. This would be equivalent to me opening up the Clipboard History Switcher tool and searching for something then pasting it in.

This would be useful when I want to paste the most recent Jira url in the clipboard.

Keyboard Maestro Paste By Name

Blog Posts

Check out some cool tips and tricks with Keyboard Maestro on my Keyboard Maestro Blog Posts.

February 26, 2019

Reset Clipboard History in Keyboard Maestro

Keyboard Maestro gives users a couple of options when adding a macro - the content can be typed or pasted in. If there's a lot of text to be inserted, pasting is the right way to go. Not only does the content get added faster, but there's less chance of accidentally typing a key when the macro is being inserted.

The downside to pasting is that the pasted content is now the most recent data in the clipboard. (Which isn't good if you want to do multiple things with the clipboard content.)

Thankfully Keyboard Maestro has a clipboard management functionality and you can easily roll back in one simple step; "Set System Clipboard to Past"

Adding Clipboard History

After I paste a content, I add the "Set System Clipboard to Past" to ignore the content being pasted in the clipboard:

Keyword Maestro Clipboard History

The advantage of doing this is that I can still use the clipboard content in another Macro or have access to the original content.

In the above example, I am pasting in a random phrase that I have setup for testing. The clipboard get's reset after the content gets pasted.

February 19, 2019

Hide Multiple Browsers Bookmarks

Sometimes I like to showcase how a website looks in Chrome and Firefox. I usually hide the Bookmark bar so that it's less distraction to the screenshot.

I made this process easier by creating a Keyboard Maestro macro to hide both browser's bookmark toolbars at the same time.

Using Keyboard Maestro, I set up a Macro so that I could close both Chrome and Firefox Bookmarks at the same time.

Keyboard Maestro Macro

Cross Brosser Bookmarks

Some Notes on the Macro

I used a weird keyboard combination to open/close the bookmark bar. If I need to do this a lot, I'll change up the shortcut to something a bit more reasonable.

When I execute the command a second time, both bookmark toolbars are visible.

I can easily change this to support other browsers, such as Omni, Safari and Maxthon.

The commands execute almost simultaneously and it doesn't matter which browser I have currently focused.

February 12, 2019

Adding Excel Date Shortcut Everywhere

If your a regular user of Excel you probably know the shortcut to add the current date to any field: Control ;

So, if your use to it, why not just make it a shortcut in any application.

Simple Shortcut

Here's is a simple way to add Excel 'Today's Date' feature using Keyboard Maestro.

Simple Date

Now when I need to add the date, I simply type in Control ;.

Advanced Technique

What if you need a different date format in different applications? For example, you may want to display today's date differently in Slack than in an Excel table.

There's a simple way to make this happen (This is what makes Keyboard Maestro a really cool application!) Simply put in a condition to check to see what is the current active application:

Advanced Date Maestro

I used PHP to do the formatting here because I wanted to add an English ordinal suffix (1st, 3rd)

I can add multiple applications checks by adding additional conditions to the statement. Which makes it easy to have a single action short cut to display different formats in applications.

February 5, 2019

Keyboard Maestro Keyboard Shortcut Enhancer

If your switching back and forth between applications, it can be hard to remember certain keyboard shortcuts. Apple has a UI Guidelines which standardize many common tasks: Cut/Paste/ Hide Applications.

What's nice about Keyboard Maestro is you can define short cuts when the application don't have functionality to do so.

Case in Point: I navigate between Apple Mail and Microsoft Outlook a lot. I wanted to have one keyboard shortcut to insert HTML links - since it's a command that I use a lot. Outlook uses Control Command K and Apple uses Command K.

With Keyboard Maestro, I can now remember only one shortcut between applications:

Outlook Quick Key

The above macro is in a group that is available only for Microsoft Outlook. This way it doesn't get activated in other applications. Come to think of it, it might be a good shortcut for BBEdit insert Anchor action.

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.