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.
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.
- Open Keyboard Maestro
- Select the Actions menu
- 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.
- Select your My iMore Macros group
- Click the "+" at the bottom of the Macros column
- 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:
- Click the "+" next to where it says New Trigger
- Select Time of Day Trigger from the resulting menu
- Choose a time
- 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.
- Click the "+" next to New Action
- Make sure All Actions is selected in the Categories column
- 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
- Click the menu next to the word "Activate" and select Finder
- Make sure "All windows" and "Reopen initial windows" are checked
- 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.
- Uncheck "All windows" and "Reopen initial windows" (we only needed these checked to make sure the action was working.)
- Use the Actions search bar to find the Type a Keystroke action
- 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.
- Click the text box next to the text that says, "Simulate keystroke:"
- Type the keys Command-Shift-Option-Delete
- 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.
- Type Activate in the Actions search bar
- 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.
Next up, we'll begin working with variables and named clipboards.
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.
Thank you for signing up to iMore. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.