Using Keyboard Maestro To Tag Files in Mavericks

Current tagging macros. When I posted about how I thought adding tagging tools to Keyboard Maestro was going to be a big deal, I hadn’t even used it yet — so here’s my first macro to use them. For me the biggest part is the fact that I can now start to use tags because […]

Current tagging macros.

When I posted about how I thought adding tagging tools to Keyboard Maestro was going to be a big deal, I hadn’t even used it yet — so here’s my first macro to use them. For me the biggest part is the fact that I can now start to use tags because I can quickly add them, whereas before it was far too much clicking of the mouse to tag files.

Here’s the setup:

And here is the one to remove all tags:

There are currently four options for working with tags:

  • tags : This sets the tags to a specific set, hence leaving it blank removes all tags.
  • tags (add) : Think of this like append, as you aren’t changing the existing tags, but appending one or more new tags to the list.
  • tags (toggle) : As the name suggest this will toggle on and off one or more tags. I am actually thinking of changing my macros to use this method, but for now I am not. I want to see if my way has conflicts or not and I am not sure I want tags turned off if I blindly apply a tag to a list of files.
  • tags (remvoe) {That typo is in the app, not mine.} : This removes a specific tag.

All in all Keyboard Maestro has fixed the biggest drawback to using tagging instead of folders: mouse management of tags. I think this will getting me using tags a lot more.

UPDATED (on Apr 2, 2014): The macros were updated after the developer told me I was doing it the long way.

Keyboard Maestro Macro: Attach and Send

I’ve long had a need to take a file sitting on my computer and send to to someone. While you can do that with the share menu on OS X, it’s not that great for a couple of reasons: It’s a menu item you have to click. It doesn’t, and can’t, set simple things like […]

I’ve long had a need to take a file sitting on my computer and send to to someone. While you can do that with the share menu on OS X, it’s not that great for a couple of reasons:

  1. It’s a menu item you have to click.
  2. It doesn’t, and can’t, set simple things like the to, subject, bcc, and sending email account.

Those are items I always need to change — so I’d like to be able to set those to a keyboard shortcut for faster sending of files. Additionally I have PDFs that I email monthly, to the same people, with just the date in the subject changing (and the PDF) — it’d be great to automate that too.

What I have come up with in Keyboard Maestro (hat tip to this post from Viticci) is a macro that does just that. More so than any of my other macros, this macro heavily relies on AppleScript to get the job done.

What this macro is doing is using Keyboard Maestro to pass variables to an AppleScript. I pass the date, because I simply couldn’t figure out how to get todays date formatted the way I wanted it in AppleScript. You will also notice a blank variable for the recipient email address — I use that in later macros and it was easier to keep in than remove.

The heart of the macro is this AppleScript:

Screen Shot 2013-08-15 at 4.44.13 PM

(Download the script here.)

At my office we BCC all communications to Highrise, and so you can see the address for that on the BCC line. I also set the sender in the AppleScript, but if you wanted to you could set that with a Keyboard Maestro variable just like I have for the recipient and subject lines.

With that all setup, and the basic macro in place, I just duplicated the macro for each group of people I wanted to send an email to. Pasted their address in the macro variable box for addresses, and modified the subject variable as needed.

In all I have 14 different file emailing macros. All stored in one group and activated with the same hotkey. You can select as many files as you want and they will all be attached — this saves me a ton of time each month.

Keyboard Maestro Macro: Based on my Wifi, Do This

With the ability to now trigger macros based on WiFi, I’ve come up with a doozey of a macro that I have been using as a sort of “geofenced” WiFi trigger for certain settings on my Mac. I like my computer to look and act a certain way at work, differently at home, and differently […]

With the ability to now trigger macros based on WiFi, I’ve come up with a doozey of a macro that I have been using as a sort of “geofenced” WiFi trigger for certain settings on my Mac.

I like my computer to look and act a certain way at work, differently at home, and differently everywhere else.1 In the past I had a ton of Keyboard Maestro macros that I would invoke quickly to setup my computer — but no more (well mostly no more).

My WiFi actions macro. (full-size here, open that in a new tab.)

Instead I now have my computer tweak a few settings based on the WiFi network I am connected to. To the right you can see the macro, but I think I should walk you through this in case you aren’t familiar with some of the tools I am using.

First the macro is being triggered by connection to any WiFi network, that is what the . denotes. The reason for this is simple: I want to do something specific if I connect to any other network than the ones I specify. This works well for me because I only have two “trusted” networks (my home network and office network).

What follows for the actions is a large if/then statement inside the macro. The first condition checks to see if the WiFi network is my office network. If it is, then the macro sets the volume of my computer to 0% and executes an AppleScript that turns on notification center. Lastly the macro hides all Safari windows — WHO KNOWS what I was looking at last.

The next test is to see if I am on my home network (aptly named “Comcast is Probably Down” — a name that never ceases to make me grin). If I am home, then I turn my volume to 60%, turn on notification center and leave it at that.

The last is the else statement, meaning if my computer connects to any WiFi network that is not one of the two above, here’s what needs to be done. My assumption is that I have either connected to a coffee shop network, or am in another office for some reason (or another person’s house) either way, I want certain things to happen. 2 First, volume to 0% again, because why wouldn’t you be polite? Next some mouse clicks, which are currently the only way I know how to automate turning on my VPN — which is what those mouse clicks do. From there I set my wallpaper to a specific background, which is all black for good measure. I hide Safari windows — I already touched on why. Then I turn off notification center. Lastly, I send a notification to let me know I am on such a sketchy network as to need all these precautions, but that the macro ran to protect me anyways.

You can add as many intermediate WiFi network checks as you want, and you can add tons of actions to each one. Previously, I did some of this with time triggers, but those weren’t fool-proof and this method has yet to fail me — I love it.

Further Playing

I’ve also toyed with the idea of having KM take all the open tabs in Safari, grab the URLs, send them to Instapaper (or bookmark them) and then close Safari. That’d be something I would do if I was more presentation oriented, but I can’t remember the last time I presented something.

Sum

My ultimate goal is to just be able to close the lid on my laptop, and open the lid, without having to worry who is sneaking a peek, or what I was doing last.


  1. A few people have mentioned Control Plane to me, but in looking at it I prefer to stay with Keyboard Maestro. 

  2. I should note that I could set it up to act if I tether, but I have not done that because it would almost be identical to the else action. 

Keyboard Maestro Macro: Quoting a Website in Markdown

I often run into this scenario: I have already invoked the actions to start a new post from a website I am currently reading, but now I want to add in additional quotes from other sites. This used to mean a lot of copy-paste and CMD-Tab. Of course that also means this is something that […]

I often run into this scenario: I have already invoked the actions to start a new post from a website I am currently reading, but now I want to add in additional quotes from other sites. This used to mean a lot of copy-paste and CMD-Tab. Of course that also means this is something that can be completely automated by Keyboard Maestro, so let’s do that.

Scenario:

You have just started writing about a quote you grabbed from Website A, and now you want to go back and quote (and link to) the source from Website B.

Solution:

To the right is my solution. Currently I have the macro linking the text from the title of the page to the URL, this is mostly because 20% of the time the author’s name might be in it, but regardless I have to edit that text 100% of the time anyway. Some of the formatting is also specific to the writing tools I am using, so you may need to adjust it (it’s all formatted for Markdown right now).

The benefit is that now I can select text on a page, hit the hot key and paste to my document, saving a bunch of extra clicks. It’s not the best, but it sped things up a touch for me.

Keyboard Maestro Macro: Publishing to WordPress from iA Writer (kind of)

One of the things I used to love about doing all of my writing in TextMate was publishing directly to this site using the “blogging” bundle. iA Writer is a better writing app than TextMate, so the tradeoff when I switched seemed fair, but I still get annoyed every time I copy and paste the […]

One of the things I used to love about doing all of my writing in TextMate was publishing directly to this site using the “blogging” bundle. iA Writer is a better writing app than TextMate, so the tradeoff when I switched seemed fair, but I still get annoyed every time I copy and paste the latest post into MarsEdit.

This is further complicated by linked-list style posting: When I did Daring Fireball style linked lists, with one-line comments, it was easy to quickly post a link with a pull-quote by hitting CMD+1. That shortcut dumped all the data I grabbed into MarsEdit. But it sucks for my Kottke-style links where I try to write a bit more — often not in the same sitting.

Bottom line: My most irritating workflow problem used to be the amount of copying and pasting going on just to post something to this site.

That’s now changed.

The Research

The biggest stumbling block was getting the text to WordPress from Writer. I found ways to do it via PHP, Python, and a command line interface — but none of these were solutions that I could figure out, or wanted use. Additionally these solutions require detailed documentation to reinstall, should I start on a fresh computer.1

I wanted something easier. Actually I wanted an AppleScript that would send the post, but I’ve yet to figure that out.

MarsEdit was out of the running due to it having categories under check boxes that I can’t easily set using the keyboard.

Welcome back TextMate, old friend.

The Macro

The macro.

You can see the macro on the side there. It’s not overly complicated, just lots of actions.

Here’s what the macro does (simplified):

  1. Grabs the title, which it places at the top of the post, prefixed with a # and followed by a carriage return.
  2. Grabs the body text.
  3. Asks me for metadata.
  4. Opens a new TextMate document and dumps all that information in, formatted for the TextMate blogging bundle.
  5. Waits for me to publish the post (so I can check everything looks correct).
  6. When I hit the shortcut to publish in TextMate, the post publishes. The changes to the Writer file are reverted and saved, then the windows for all the programs used are closed.

Pretty simple.

Another thing I wanted was to set the scheduled publish date, which meant adding a field in TextMate containing a correctly formatted date string. I used a TextExpander snippet to speed things up (;bdate).

(Here’s the detail view of some of the actions that you may find useful. Pause action. Meta data questionnaire. Text insertion to TextMate.)

End Result

Now I can publish from iA Writer via a series of simple actions, triggered by a single keystroke.

Because I install this macro’s only dependencies — Writer and TextMate — on every Mac I own, the solution is simple to reinstall and portable.

You can download the macro here.


  1. This is something I have recently done, so I’m a bit sensitive to it. 

‘Scheduling Do Not Disturb’

The lovable Ben Waldie posted a fantastic article detailing how to script Do Not Disturb mode on your Mac. He is using Automator and Calendar to schedule the script to turn on and off Do Not Disturb mode, but we can do one better because we have Keyboard Maestro. The macro. I simply created a […]

The lovable Ben Waldie posted a fantastic article detailing how to script Do Not Disturb mode on your Mac. He is using Automator and Calendar to schedule the script to turn on and off Do Not Disturb mode, but we can do one better because we have Keyboard Maestro.

The macro.

I simply created a hot key trigger (and timed trigger) in Keyboard Maestro that executes the Applescript that Waldie creates for either enabling or disabling Do Not Disturb mode. It works really well, and is a great tool to add to Keyboard Maestro.

[via Shawn]

Keyboard Maestro Macro / AppleScript: Mail This Selected Item

(This post is a part of a series on Keyboard Maestro, see more here.) As part of my job I compile a monthly PDF report which I send out to the owners of properties I manage. I do this for quite a few properties every month. When I started I used a bunch of TextExpander […]

(This post is a part of a series on Keyboard Maestro, see more here.)

As part of my job I compile a monthly PDF report which I send out to the owners of properties I manage. I do this for quite a few properties every month.

When I started I used a bunch of TextExpander shortcuts to build the email, but this soon became too cumbersome. Not one to rest, I eventually built a Keyboard Maestro macro based off of Automator to send these files. Using Automator allowed me to pre-fill all the info in the email, with custom dates and To fields, but Automator has a significant downside.

Anyone who triggers Automator via Keyboard Maestro knows that Automator is a really slow tool to use. I would be waiting for my computer to think and work before I could do anything else and this drove me nuts.

I immediately started to work with AppleScript to try and replace Automator — I figured out how to do everything except automatically attach the selected file from Finder. The more I searched, the less I came up with a solution. Until Eelco Lempsink got in touch, responding to my plea for help on App.net, Lempsink sent over an awesome AppleScript that builds a new email with the selected Finder item attached.

So with Lempsink’s permission, here’s the AppleScript he built:

tell application "Finder"
 -- Make a list to gather the names of the selected files
 set fileAliases to {}
 -- Get the selection of the frontmost Finder window
 set fileSelection to the selection
 -- Iterate of the selection
 repeat with fileItem in fileSelection
 copy the fileItem as alias to the end of fileAliases
 end repeat
 -- Check if the selection is not empty
 if the number of items of fileAliases is 0 then
 -- Audible feedback, so the script always does something.
 beep
 else
 -- Now talk to mail to create the message
 tell application "Mail"
 set newMessage to make new outgoing message at beginning with properties {visible:true}
 -- Attach all the selected files
 repeat with fileAlias in fileAliases
 make new attachment with properties {file name:fileAlias} at after the last paragraph of newMessage
 end repeat
 -- Put Mail in the foreground
 activate
 end tell
 end if
 end tell
When executed this AppleScript grabs the selected Finder item(s) and attaches them to the email. For my purposes I needed to add a bit more to it so that I didn’t have to touch a single thing in the email before I sent it.

Here’s my modifications:

-- Variables
 set theSubject to "PROPERTY NAME Owner's Report"
 set theContent to "Let me know if you have any questions. -Ben"
 set recipientAddress to {}
 tell application "Contacts"
 if group "CONTACT GROUP" exists then
 set recipientAddress to "CONTACT GROUP"
 end if
 end tell
 tell application "Finder"
 -- Make a list to gather the names of the selected files
 set fileAliases to {}
 -- Get the selection of the frontmost Finder window
 set fileSelection to the selection
 -- Iterate of the selection
 repeat with fileItem in fileSelection
 copy the fileItem as alias to the end of fileAliases
 end repeat
 -- Check if the selection is not empty
 if the number of items of fileAliases is 0 then
 -- Audible feedback, so the script always does something.
 beep
 else
 -- Now talk to mail to create the message
 tell application "Mail"
 set newMessage to make new outgoing message at beginning with properties {subject:theSubject, content:theContent, visible:true}
 -- Set a recipient
 tell newMessage
 make new to recipient at end with properties {address:recipientAddress}
 make new bcc recipient at end of bcc recipients with properties {address:"HIGHRISE BCC ADDRESS"}
 end tell
 -- Attach all the selected files
 repeat with fileAlias in fileAliases
 make new attachment with properties {file name:fileAlias} at after the last paragraph of newMessage
 end repeat
 -- Put Mail in the foreground
 activate
 end tell
 end if
 end tell
I’ve added a few things:
  • A variable block, so that I can define items one time. Here I define the report subject, the content, and the contacts to send the email to. I added this because I had to create one Applescript for each property I manage. I decided to use a contact group instead of individual contact emails in the script because it allows for easier information change down the line: I just update the Contacts application.
  • The other changes are just adding in the spots for the variables.
  • Additionally I added in a BCC field where I stick my Highrise BCC address for logging my email correspondence.

That’s the AppleScript, and it rocks.

Keyboard Maestro

I, of course, trigger this with Keyboard Maestro. You could use FastScripts, but I use Keyboard Maestro so that I can add one more thing: today’s date. I know you can get this in AppleScript, but for the life of me I can’t figure out how to format the date the way I want it.1

The Keyboard Maestro Macro.
Depending on what fields you have Mail showing in the compose window you may need to edit the tabbing and arrows on the macro — essentially I just use keyboard shortcuts to navigate to the subject line and append today’s date.

The entire macro only takes a few seconds to run and that makes it much faster than Automator.

I stack every property under one hot key trigger so I can just click the one I want to use. This is saving me a ton of work each month.


  1. I truly suck at Applescript. 

Keyboard Maestro Macro: All Caps to Title Case

(This post is a part of a series on Keyboard Maestro, see more here.) I really hate websites that capitalize every letter of an authors name in their byline because it makes it hard to link to that post — mostly because I like to copy and paste names so that I make sure I […]

(This post is a part of a series on Keyboard Maestro, see more here.)

I really hate websites that capitalize every letter of an authors name in their byline because it makes it hard to link to that post — mostly because I like to copy and paste names so that I make sure I don’t make a typo.

Luckily with names, for the most part, a simple Title Case will fix the problem. This is an action that can be done very simply in Keyboard Maestro.

The result of this macro is to take the highlighted text and convert it from all caps to Title Case, so that I can post a link citing the author without worrying about misspelling a name.

The Macro

I start by triggering the macro with a hot key, specifically the hot key: Control + OPT + Shift + CMD + T. (Easy to remember as every modifier except FN is pressed, then T for Title Case.)

The macro assumes that you have the editable text selected, so you will need to have already copied and pasted your text where you want it. (I made it this way so that I could use it universally, as many leases I work on also suffer this problem.)

The finished macro.

Next Keyboard Maestro performs four actions:

  1. The selected text is copied to the clipboard using the action: Type the CMD+C keystroke.
  2. Next Keyboard Maestro filters the clipboard to all lowercase (this is done because the Title case action won’t change the case of all capitalized words). To get this action, just add the Filter Clipboard action and select lowercase.
  3. Add the same action again, but this time filter to Title Case.
  4. Like the copy action above, we change it to paste by sending the keystroke CMD+V.

All done.

If everything works your all caps text should now be properly cased. This also works for titles of blog posts, as it will remove your poor casing and re-case the words as they should be (just be sure to edit for proper names and such).

Bonus

One change makes it useful for legal documents.

I mentioned that I often use this in leases at my day job, another thing that comes up is people liking to type in all caps for emphasis. I find it ridiculous, and impossible to read, so I have another macro to re-case those stupid sentences to Sentence Case.

The steps are the exact same, just choose Sentence Case instead of Title Case in the third step.

Keyboard Maestro Macro: Append to Quote File

(This post is a part of a series on Keyboard Maestro, see more here.) One of the things that I have always loved doing is saving quotes. The problem for me has aways been where to save those quotes. As it turns out, I don’t often go back and read the quotes — they are […]

(This post is a part of a series on Keyboard Maestro, see more here.)

One of the things that I have always loved doing is saving quotes. The problem for me has aways been where to save those quotes. As it turns out, I don’t often go back and read the quotes — they are more like things that I use as future references. I have some quotes in dedicated apps — never to be seen again — others in Yojimbo and Pinboard and none of these solutions work well for me.

All I want is a bunch of quotes strung together, so I decided to craft a way to save quotes with Keyboard Maestro and a hot key trigger.

Doing this is actually pretty simple: all the quotes end up in the same text file and the end result looks pretty decent for viewing.

The finished product.

Here’s what my macro grabs:

  • The quoted text.
  • The current date.
  • The URL of the quoted text.

All of that info is dumped into one file as an append action. The process is actually very simple.

The Macro

The full macro.

As you can see this macro is exceedingly simple, but it assumes you have already selected the text you want to quote.

  1. The first thing the macro does is copy the selected text using CMD+C.
  2. Next the macro saves that copied text to a named clipboard called Quoted Text. (Hint: to create named clipboards just select the Save Clipboard to Named Clipboard action and in the chooser for the named clipboard, select New. You can also edit these in the preferences for Keyboard Maestro.)
  3. I then simulate the keystroke CMD+L, which highlights the current URL in Safari and Chrome.
  4. Again, just copying that URL and setting it to another named clipboard — this time called URL.
  5. The last part is to append this text to our file. So I have set the following to append to the file:

{OPT+Return} --- {OPT+Return} "%NamedClipboard%Quoted Text%" | saved %ShortDate% %ShortTime% {OPT+Return}(%NamedClipboard%URL%)

I couldn’t get the command %Return% play nice in TextMate 2, so I added carriage returns by using OPT+RETURN when entering the text.

That’s it, now every time you invoke the command your text, URL, and dated added is appended to one text file. I personally find this much more useable than a dedicated app because I store it in Dropbox and can get to it from anywhere.

Keyboard Maestro Macro: Docu Store

(This post is a part of a series on Keyboard Maestro, see more here.) As a blogger (I’m sure this applies to others) there are a lot of times when I am writing and need/want to grab a lot of source material to use. For me this typically involves a lot of copy and pasting […]

(This post is a part of a series on Keyboard Maestro, see more here.)

As a blogger (I’m sure this applies to others) there are a lot of times when I am writing and need/want to grab a lot of source material to use. For me this typically involves a lot of copy and pasting and command-tabbing between Safari and Writer.

I was fed up with this, so I created a system where I could just copy an infinite amount of data and paste it back into an app all at once.

Enter Keyboard Maestro: with these two macros you can write things to a simple text file with one shortcut and then paste it back out of the text file into your writing (and then you clear the text file). This is all done quickly and simply.

Here’s how:

Docu Store – Build

The first part I had to build was the engine that would write everything I want to a text file. Here’s how I did this:

I’ve set the hot key trigger to CTRL+CMD+C so that it is not something easily triggered on accident, but only one modification from a standard copy command.1

From there, Keyboard Maestro performs three simple actions:

  1. Copies the text so it is on your clipboard.
  2. Appends what is on your clipboard to a specific text file. In my case that is stored in Dropbox, in a Workflows folder, with a file name called Docu-store.txt. This writes the info you want to the text file. I’ve further set it to write in plain text, thus removing any formatting.
  3. The last bit is a simple formatting preference. If you don’t add this part, all the stuff you copy will all be on one line. I’ve added two carriage returns between each entry add by telling Keyboard Maestro to append %Return% %Return% at the end of every add to the file. This way, when my text is pasted in the next macro, it is easy to see. (You can also use: %LineFeed% %Return% %Tab% %Space%.)

That’s it for the first macro — we can now add text. Next we just need to extract it.

Docu Store – Paste

Now we need to extract that text back out of the file and paste it at will.

Here’s how I have that setup:

I’ve kept things standardized by using the CTRL+CMD+V shortcut. From there Keyboard Maestro runs four actions:

  1. I first set the contents of the text file we were writing to, to a variable called DocuStore. All this does is get data in a place where we can use it. (I first tried loading the data directly to the clipboard, but had very inconsistent results when I did that — this seems to be the most predictable way to get the file contents.)
  2. Next I set the clipboard to the DocuStore variable. (Again, this could be one step, but it wasn’t working correctly for me.)
  3. The data is then pasted by hitting CMD+V.
  4. This last action is one you might want to think about not adding. I write back to the text file nothing — which clears everything out of the text file, making it a blank slate for the next round.

All of that gives you a nice clean way to grab say an author name, link to the article, and block quote from the article — all in one fell swoop.

I love it.

Notes & Tips

You may not always want to wipe the file, so there’s an easy way to make that an option you can decide on at the time:

By adding that one action a dialog will pop up asking if you want to wipe the file. Say no and nothing is done.

Lastly, I use a text file because it is a non-volatile way to store the data. It will persist if you restart your Mac, it won’t be wiped out for some odd reason, and is backed up. You could use a custom clipboard for this, but a text file has an added advantage of being a document you could just open and edit if you wanted or needed.


  1. An added bonus, that made it easy to remember, was that it is the Windows copy shortcut and the Mac copy shortcut in one. 

A Better Way to Append the Date with Keyboard Maestro

Miłosz Bolechowski wrote in to tell me that using Automator to change the date was silly because all of it can be done in Keyboard Maestro. This is a really complex version, but does work much faster than using Automator (my method). I actually had no clue just how easy it was to grab files […]

Miłosz Bolechowski wrote in to tell me that using Automator to change the date was silly because all of it can be done in Keyboard Maestro. This is a really complex version, but does work much faster than using Automator (my method).

I actually had no clue just how easy it was to grab files from Finder in Keyboard Maestro, so this is incredibly helpful to me long term as well.

Thank you to Miłosz Bolechowski. This is awesome.

(You’ll probably need to translate the page, but the last link in the post is a zip to download the macro.)

Keyboard Maestro Macro: Appending a Date to a File Name

(This post is a part of a series on Keyboard Maestro, see more here.) This macro will allow you to select any file in Mac OS X and append the current date to the end of the file name. It is all done with one keyboard shortcut and no need to get to the editing […]

(This post is a part of a series on Keyboard Maestro, see more here.)

This macro will allow you to select any file in Mac OS X and append the current date to the end of the file name. It is all done with one keyboard shortcut and no need to get to the editing file name mode. This is very useful for versioning files if you work outside of a version control system — or if you get a lot of files with the same name (images are one I constantly add this info to).

What you need: Keyboard Maestro and Automator.

How To

We need to start in Automator and build a new workflow.

  1. Open Automator and when prompted to create a new file select Workflow.
  2. In the search field to the left, search for the action named Get Selected Finder Items. Drag that to the pane on the right.

    This action will tell Automator that we are working with the files you have selected and only those files.

  3. Search for another action named Rename Finder Items and drag it to the right pane. When prompted to add an action to copy the file first select Don’t Add.

Once you have this action in there you will be presented with a multitude of options to consider. Here’s how I have mine setup:

The final Automator action, that adds the date and the time.

There’s some important things to note:

  • Be sure to use spaces, dashes, or underscores for the separators so that you don’t break non-Mac tools (other operating systems and websites hate the forward slashes).
  • You have four options of the date to grab: Created, Modified, Last Opened, Current. All the options work as expected, but the first three may not always result in the date you intended it to, for that reason I stay with the current date.
  • Use Leading Zeros just means that August will be represented as 08 instead of 8. I recommend turning this on for a more consistent file length.
  1. Now you just need to save the workflow somewhere you remember and somewhere that you will not move it. (I have a dedicated Dropbox folder that I keep these workflows in.)
  2. Open Keyboard Maestro and create a new Macro (CMD+n).
  3. Set the trigger to This hot key:. Next you will need to click on the field below to record your new keyboard shortcut, personally I chose: Control+Shift+Command+R. Make sure Is pressed reads after the shortcut.
  4. Next click to add a new action and search for Execute an Automator Workflow. Drag that action to the pane on the right to add it.
  5. Click the button with the ellipses on it (the three dots) and select the workflow that you just saved in step 4.

You are now done. With a file selected you should be able to press your keyboard shortcut and have the date appended to it.

Final macro in Keyboard Maestro.

Note: Pressing the shortcut more than once on any file will keep appending the date, be careful.

Advanced

You may have noticed that Automator doesn’t actually allow you to append the Date and Time to a file name — at least not in one fell swoop. This is easily added by opening the workflow back up in Automator and making these tweaks:

  • Add another copy of Rename Finder Items, again selecting Don’t Add when prompted.
  • Change the format from the date, to the the time and adjust settings to your liking.

This will now append the date first, followed by the time, and then the file extension. If you want the two reversed, simply drag the Time action above the Date action.

The nice part is that we don’t need to change anything in Keyboard Maestro and can keep playing with tweaks until we find the mix that is right for our intended use.

The Keyboard Maestro Basics

Before I start sharing a bunch of Keyboard Maestro macros, we need to be on the same page when it comes to understanding the inner workings of Keyboard Maestro. So let’s get that out of the way. Keyboard Maestro is a two part application. The first part is what you see when you launch the […]

Before I start sharing a bunch of Keyboard Maestro macros, we need to be on the same page when it comes to understanding the inner workings of Keyboard Maestro. So let’s get that out of the way.

Keyboard Maestro is a two part application. The first part is what you see when you launch the application: the macro editor where you can build your macros. The second part is the very lightweight Keyboard Maestro engine — this runs in the background to monitor user input so that Keyboard Maestro can make your macros actually work.

There isn’t much to know about the engine, but you can stop and start it from the File menu in the Keyboard Maestro macro editor. So unless you don’t have any macros, just leave the engine running — conversely if your macros don’t seem to work, check to make sure the engine is running.

The Keyboard Maestro engine isn’t something you can control, instead everything the user does is inside the editor interface so that’s what I will focus on.

The Editor

Once you launch the editor you will see three main panes. From left to right these are:

  • Groups: I will touch on these more later, but these serve as a way to group macros together and add additional functionality to the groups of macros by limiting them to certain applications.
  • Macro list: A simple list of all your macros.
  • The Macro: this is the detail view of a selected macro, showing the triggers and the actions (more on those in a bit).

The interface only get’s more complicated from here, so let’s break this apart a bit more.

Grouping Macros

I mentioned that you can get additional power out of macros if you add them to a group. Groups are not a way to organize macros, they are a way to limit the power of macros and thus make your life a bit easier. For instance: there are bound to be macros that you want to work only in a certain application, or more often, never in a certain application. Groups are where you set up such controls.

So if you wanted to create a new group of macros that only works in Safari, you would simply create a group like this:

And if you wanted to create a group of macros that never work in Safari, you just change those settings to this:

The power isn’t limited there, because perhaps you want to create a group of macros that only work in web browsers, which is easily done like so:

Of course, your results will vary depending on the web browsers you have installed.

Because of the way groups work it is best to think of them as ways of preventing bad things from happening in other apps — especially if you are sharing keyboard shortcuts. However, this is not the only thing we can do, you could use the group setting in conjunction with a quit-all macro. The macro could then easily quit every application running, except those excluded in the macro group.

Groups are an important tool in Keyboard Maestro to keep in mind as you are working through the construction of more complicated macros.

Macro Editor

The macro editor can be broken down into two views, and two panes. The two views are: description and editor. These are the views you are presented with if you are not in macro editing mode.

The two panes that appear in editing mode are: triggers and actions. When you click the edit button at the bottom of the macro editor you are able to manipulate both triggers and actions, and these panes are where you build your macro, so we need to take a deeper look.

Triggers

Triggers are what’s going to set the macro into action. This is simply asking: what event has to happen for the below actions to run?

Right now there are 12 triggers, and four script triggers that you can choose from. (It’s important to note that you can have more than one trigger for each macro — as I will show in later examples.) For now, that could be a macro that runs everyday at a given time and that can also be invoked by a keyboard shortcut, or any combination of these twelve macros that you can dream up:

And the script triggers:

In this series I will primarily use time and hotkey triggers, but as you can see there are many different ways that you can trigger your macros.

To aid in the construction of macros you need to understand how each macro could be triggered.

  • Hot Key: This is your basic keyboard shortcut trigger, and likely to be your most used trigger. It’s important to note that Keyboard Maestro will intercept any keyboard shortcut and run the macro while stopping the shortcut from working at the system level. Therefore if you were to assign CMD+C as a hotkey, the universal “copy” command would simply execute your macro, and not copy anything (unless that is your macro). So choose your triggers carefully.
  • Typed String: Similar to the Hot Key trigger, except that this trigger watches for you to type a particular series of characters and then it will trigger (instead of forcing you to hold down a set combination of keys). I will show you some examples of Typed String triggers, but for now think of this as a great trigger to use to trigger macros while you are typing in a document — much like you would use TextExpander.
  • Application: This will trigger a macro based on the state of one or more applications. Some examples would be if you launch a game, you can trigger system hogging applications to be quit. Or if you switch to a particular application, you could make it go fullscreen at that time. Perhaps when you quit an application you force the application to close all windows so that they do not reopen when you next launch the app.
  • System Wake: Triggers macros when your Mac wakes from sleep. One of my favorite triggers here is to hide all applications on system wake — since I don’t sleep my computer much, there is a good chance that I am changing locations when I do sleep my computer and in these instances such a macro could save you some embarrassment if your screen didn’t have any of your previous “work” when you wake the computer — just saying.
  • Login: Triggers a macro when you login into the account you used to create the macro. This can be used to replace login items, or applications that automatically start when you boot your Mac, but more pointedly you could use this to changes settings to specific defaults after you restart a Mac, among many other things.
  • Time: This is a great trigger that I use often. You pick a time of day, and the days of the week, that you want the trigger to fire the macro for you. For example: Monday-Friday at 8:30am. I use this trigger to have my Mac remind me of daily things (Lunch Time!) and to keep my embarrassment level low(er) (Set volume to 0 when I get to work).
  • While Logged in: Another fantastic trigger, this one will repeatedly trigger a macro within the parameters that you set. There’s three aspects to the trigger: how often you want the macro trigger, between what times of the day to do this, and which days of the week. (e.g. Trigger every 30 seconds between 8:30am and 4:00pm on Wednesdays and Fridays.) Another great trigger for automating a routine task, such as checking your OmniFocus inbox for unprocessed to-do items, or reminding you to look away from the screen.
  • The Macro Palette entry is clicked.: A good trigger for macros that you build for one-off never to be used again circumstances. This trigger gives you a palette that overlays on your screen and you trigger the macro by clicking on an icon in the palette. I only use this if I build a macro for a specific document I am working on, knowing I will not need to use the macro later. This saves me from remembering a new keyboard shortcut. (Also handy for testing macros while you are making them.)
  • The Status Menu item is selected.: Much like the last trigger, except instead of a palette that sits on your screen, there’s a menubar icon that allows you to execute a macro from it. (Hint: If you unchecked to show the menubar item in Keyboard Maestro preferences, but it still shows — make sure no macros are using this trigger and then restart.) This is the best way to trigger macros if you are keyboard-shortcut adverse.
  • The Public Web entry is executed.: A bit more complicated, but you can set up a local area network webpage that is hosted by your Mac, and any macros with this trigger set, will appear on that page. You then can execute the macro by clicking on that page. Not a bad idea if you have a Mac running with no keyboard/mouse/monitor hooked up to it — just make sure your security settings are done correctly. I use this on a Mac that I use as a server to run a few commands without having to remote-login to the machine.
  • This Device key: Ok, this trigger is a bit more complex; basically if an input is pressed on a particular device, then the macro triggers (with options for holding modifier keys). One potential use would be if you have a Griffin PowerMate controller and want to execute macros by clicking the PowerMate. Other options would be if you wanted to have a dedicated Keyboard Maestro keyboard, you could do so without having to hold modifiers, just using the Device Key trigger. Some good possibilities, but not many which I use.
  • This MIDI note: I have to be honest, before writing this book I had no idea what this did. Here’s what Keyboard Maestro’s documentation says: “The macro can execute when the MIDI note is pressed (note on), released (note off) or continuously while it is held down. This allows you to do things like have a macro execute when the key is pressed, and then a second macro execute when the key is released, for example to toggle a setting on and then off again.” Seems like it could be useful for musicians, but I honestly still can’t think of a use case.
  • Or by Script: I’ll leave the scripts out, as those are more advanced triggers than we will be getting into with this series of posts, but the Keyboard Maestro documentation does show a couple of examples that might be of use.

Actions

Now that we have the triggers all sorted out, we need to go through the action side of a macro. As the name implies actions are what the macro will actually do when it is activated. There is a wide range of actions available, and even more when you factor in that launching a script can be an action in a macro. While I won’t go through what each action does, the documentation does a decent job of that, I will say that it is worth your time to simply browse all the actions and get an idea of what’s available to you.

There are a few things that I want to go over about actions.

Action Picker

The very right pane in Keyboard Maestro is the action area, and the bottom section is where the heart of your macro lies.

All you need to know here is that actions are executed in the order they are shown, from top to bottom. Clicking the green plus that says New Action will bring up the Action Picker that lays atop where your macros were previously listed. From this pane you can drag, or double-click, to add any new action to your macro.

A Few Tips for Building Macros

Search

There’s a search box that sits in the top right corner of the action picker — this searches through all available actions. I recommend that you use this to find what you need if you already know the name of it since this will save you quite a bit of time.

Groups

All actions are grouped together by type, so that if you want to see all available clipboard actions, you can just select the clipboard group of actions — depicted as folders. I will reference where actions are by groups as I show examples of macros later on, this way you can find them more quickly.

Action Items

The last, and most powerful part of actions, is that each action has additional options attached to it. A lot of the time it may not be readily apparent that there are additional options.

The best way to look for additional options is to look for arrows in the action itself after it has been added to the macro. Things like these:

There’s a lot to these options and I will dive into some of these as we go through example macros. Suffice to say that these options can double the power of Keyboard Maestro itself — they are important to look at.

Basics

That’s the basics of Keyboard Maestro, while it takes a lot to explain, it is no more complicated than taking out the garbage for most tasks. All you need to know is the order of events:

  • Pull garbage bag out of garbage can.
  • Tie the top of garbage bag.
  • Walk garbage bag to door.
  • Open door.
  • Walk garbage bag to garbage can.
  • Open garbage can.
  • Place garbage bag in garbage can.
  • And so forth.

I like to think of Keyboard Maestro as a puzzle, where it can do anything I want it to do as long as I find the right puzzles pieces to fit together. Next up, a lot of examples.

(This post is a part of a series on Keyboard Maestro, see more here.)

Keyboard Maestro, Your Savior

Keyboard Maestro is the best tool you can purchase for your Mac. It is a bigger upgrade for most people than doubling up your RAM — yet Keyboard Maestro is also a daunting tool to learn at first glance. The reason I will be writing a series on Keyboard Maestro is that all too often […]

Keyboard Maestro is the best tool you can purchase for your Mac.

It is a bigger upgrade for most people than doubling up your RAM — yet Keyboard Maestro is also a daunting tool to learn at first glance. The reason I will be writing a series on Keyboard Maestro is that all too often I watch people waste time doing repetitive things that could quickly and easily be solved with Keyboard Maestro. And yet Keyboard Maestro is not installed on most Macs.

When you really get down to it, Keyboard Maestro is a simple tool to learn and use. All you have to know are two things:

  1. Your goal (Or what you want to accomplish with any given Keyboard Maestro macro.)
  2. The steps to go from start to the finish to make that goal happen.

For example, if I wanted to grab text that’s highlighted in one application and paste it into the last used application, all I would need to know is the order of actions to do that:

  1. Copy text.
  2. Switch to last used application.
  3. Paste text.

There’s no code to learn to figure how to make that work, you just look through the massive list of Keyboard Maestro actions and select the ones that accomplish your goal. Put them in the right order and move on.

Of course this is just the very tip of the iceberg for Keyboard Maestro — it can do, oh, so much more.

In the next post I will walk you through the basics of Keyboard Maestro to give you the building blocks needed to work through automating your Mac with Keyboard Maestro.

Following that I will walk you through many of the macros that I have built, so that you can either replicate them, or build off of each macro to fit your computing needs. At each step I will try to explain why I am doing something a certain way, especially if there are other ways that may be more obvious to use.

As with any tool, you will need to use Keyboard Maestro in the manner that best suits you to get the maximum benefit.

Note to Advanced Users

If I can make a macro work without having to write a script or take you into shell commands, I will do so for two reasons:

  1. It’s easier to understand and thus replicate.
  2. It’s easier to change and tweak the settings without having to teach scripting.

There are many advantages to diving into scripting and shell commands, but those are for another series of posts — not this series. In some cases I will use simple scripting commands if I feel the benefits of doing so outweighs the complexity of using scripts.