Keyboard Maestro: How to use Variables and Named Clipboards

So here we go... just a few more segments left in our series on Keyboard Maestro. Today's section is going to take us well beyond the basics and will be a setup for what's to come.

The Task At Hand

There are some tasks I perform with Keyboard Maestro that are designed for very specific purposes: I send email messages to the director, cast, and crew members when I'm stage managing theatre productions. So the specifics of the task we'll be using for this segment may not specifically match what you'll want to do with Keyboard Maestro, as I suspect most of you aren't stage managing plays. But you can use what you learn here as the foundation for other tasks you may want to perform. Specifically, we'll be creating a macro to create a custom email message that always contains some information but also contains other information that can change. To do this we need to:

  • Open the Mail app
  • Create a new email message
  • Add email addresses to the To: field
  • Add email addresses to the Cc: field
  • Add custom information to the Subject: field including today's date and the sequence number for the message we're sending

In order to perform this task we're going to take advantage of Keyboard Maestro's Variables and Named Clipboard features. These will allow you to collect and store information that macros you create will use to perform specific tasks.

Today we're going to create the variables and clipboards we'll need to perform this task.

Keyboard Maestro Variables

Variables, as the name implies, are pieces of information that can, and often do, vary, or change, every time you use them. In Keyboard Maestro you can insert variables into macros as placeholders for information. At the time your macro runs, Keyboard Maestro replaces the placeholder with the information stored in that variable.

Keyboard Maestro offers a few different types of variables, but for our purposes, we're going to use a Global Variable, which means it's available for every macro you create. Keyboard Maestro stores Global Variables locally on your computer. Information stored in these variables persists through restarts.

We create these variables using the Variables preference in Keyboard Maestro's application preferences.

To create a Variable:

  1. Open Keyboard Maestro.
  2. Click the Keyboard Maestro menu.
  3. Select Preferences.
  4. Click the Variables tab.

Keyboard Maestro has three default variables:

  • Path
  • Variable
  • VarName

We're going to create a new variable called CurrentCounter that will store the sequence number we'll use in the Subject field of our email message.

  1. Click the "+" button at the bottom of the Variable preference
  2. A Variable Name field will appear next to the "+" button
  3. Type CurrentCounter in the Variable Name field
  4. The CurrentCounter variable will appear and be selected in the variable list
  5. Type the number "1" where it says Default Value in your Current Counter variable

You should now see something that looks like this:

Next, we'll create custom clipboards where we can copy and temporarily store information for our variables to use.

Keyboard Maestro Clipboards

You've been using clipboards for as long as you've used computers. When you copy and paste you're copying to and from your device's System Clipboard. Using Keyboard Maestro you can create custom clipboards where you can store and retrieve information to be used in your macros.

We need three clipboards:

  • Cast, for cast email addresses
  • Crew, for crew email addresses
  • RRCounter, for storing and incrementing the sequencing number

(You're welcome to call these variables something that makes more sense for what you want to use them for.)

To create these clipboards:

  1. Select Keyboard Maestros's Clipboards preference
  2. Click the "+" button at the bottom of the Clipboards preference window
  3. In the text field that appears type, "Cast" and press return
  4. Repeat this process to create the "Crew" and "RRCounter" clipboards

When you're done you should see something like this:

Create Text Files For Reading Data

Finally, we need to create the text files we need to store the email addresses we'll use to address our email messages.

  1. Create a new folder on your Desktop or in your Documents folder named Email Addresses
  2. Open TextEdit
  3. Create a new document
  4. Add one email address to the document
  5. Save the document as Cast Email Addresses in your newly created Email Addresses folder
  6. Create a second TextEdit document named Crew Email Addresses, add another email address and save it in the Email Addresses folder

Your Email Addresses folder should now look something like this:

Once you've completed these steps you're ready for our next segment.

Jeffery Battersby

Jeff is a writer, actor, Apple Certified Trainer, and IT consultant, born and raised in A-town and now living in NY. You can often catch him behind the scenes and on stage at County Players, Falls Theatre. Up next? He's stage managing *Cat on a Hot Tin Roof* at the aforementioned County Players.