How to run scheduled macros in Keyboard Maestro

In our last segment, we created a simple Keyboard Maestro macro that expanded a couple of typed characters and turned into a signature. Next, we're going to create a macro that runs every day at a specific time.

See at Keyboard Maestro

Action Addiction

Keyboard Maestro ships with more than 250 actions you can use to create macros. These actions can do anything from opening applications to changing the location of a window on your screen to reading text from a file and adding it to another application and much much more. In fact, if there's a macro you can dream up you'll most likely be able to create it using Keyboard Maestro.

There's no way we can cover all 250 actions, but let's take a quick inventory of Keyboard Maestro's action collection.

  1. Open Keyboard Maestro
  2. Select the Actions menu
  3. Select Show Actions

Once the Actions window opens, select the All Actions macro group to view all available actions.

Just like Macro Groups, Actions can be organized into groups too. You'll find that the actions are already organized into groups based on what the actions do. Some of these are specific to applications, such as iTunes and QuickTime Player controls and controls for Safari and Google Chrome. Additionally you'll find actions for creating variables, adding flow control to your macros, and opening files and applications.

Most of the Actions are self-explanatory, so take a few minutes to look at some of them. When you're done, close the Actions window and we'll use some of these actions to automatically empty the trash every day.

Automatically Empty the Trash

I typically try to empty my Trash as soon as I fill it, but... sometimes I forget and let it stay full for weeks at a time.

There's a system setting that you can change that deletes anything in the trash that's older than 30 days, but we want to create something that cleans things up sooner than that. To do this we'll create an action that empties the Trash at a specific time every day.

  1. Select your My iMore Macros group
  2. Click the "+" at the bottom of the Macros column
  3. Name your new macro Empty Trash Every Night

You should see something like this:

We're now going to add a timed trigger for this script using the Trigger Menu:

  1. Click the "+" next to where it says New Trigger
  2. Select Time of Day Trigger from the resulting menu
  3. Choose a time
  4. Choose the days you want the script to run

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

Next we need to add the actions that will empty the Trash for us. We'll do this by activating the Finder, then having Keyboard Maestro send the Finder the keyboard shortcut to empty the Trash.

  1. Click the "+" next to New Action
  2. Make sure All Actions is selected in the Categories column
  3. Drag the Activate a Specific Application action (it should be near the top of the list) to where it says, "No Action" in the Macro Editor
  4. Click the menu next to the word "Activate" and select Finder
  5. Make sure "All windows" and "Reopen initial windows" are checked
  6. Click the "Try" button at the bottom of the Macro editor.

The Finder should activate and a new Finder window should appear. If it doesn't, make sure your action looks like the screenshot above.

Next:

  1. Uncheck "All windows" and "Reopen initial windows" (we only needed these checked to make sure the action was working.)
  2. Use the Actions search bar to find the Type a Keystroke action
  3. Double-click that action. Note that Keyboard Maestro automatically puts it just below the Activate Finder action you just created

You should now see something like this:

Command-Shift-Delete is the keyboard shortcut used to empty the Trash, but if you haven't customized your Finder preferences, doing this will display a message asking if you're sure you want to delete what's in the Trash, so we're going to add the Option key to hide that notification.

  1. Click the text box next to the text that says, "Simulate keystroke:"
  2. Type the keys Command-Shift-Option-Delete
  3. Click the "Try" button

If there's nothing in the Trash you will hear an error beep, otherwise the Trash will automatically empty.

For our final step, we're going to make Keyboard Maestro switch back to the application you were working in before emptying the Trash.

  1. Type Activate in the Actions search bar
  2. Locate and drag Activate Last Application to the bottom of your macro

What you see should look something like this:

Now your Trash will empty every day at your specified time.

What's Next

Next up, we'll begin working with variables and named clipboards.

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.