Conduct your Mac Like a Pro!
A Macro executes a sequence of Macro Actions in order. There are many actions to choose from (detailed below), some simple actions, such as Sleep Computer, require no other information and simply do their job, while other more complex actions, such as Select Menu Item, require you to specify more information, such as a target application or menu name.
There are many powerful Macro Actions available for your use, and you can sequence them together to perform complex tasks.
Process Control actions allow your to switch, quit, or hide applications. The actions are:
Interface Control actions allow you to interact with the user interface, selecting menus, clicking buttons, simulating keystrokes and so forth. The actions are:
The Select Menu Item action lets you choose from all currently running applications and their menus.
The Select Menu and Press Button actions allow you to specify multiple options separated by a vertical bar (eg Show|Hide) to allow for toggling menus. They will also ignore the difference between three dots (...) and an ellipsis so you do not have to worry which one the menu uses.
The Select Menu and Press Button actions will, by default, abort the macro if the action is not successful (for example if the button or menu cannot be found or is disabled). The action can be configured to allow the macro to continue if the menu or button is not essential (such as “Mark As Read” which might be disabled if the item is already marked as read).
iTunes Control actions allow you to interact with iTunes, playing songs, stopping or pausing, rewinding or fast-forwarding. All actions will launch iTunes if it is not already running. The actions are:
QuickTime Player Control actions allow you to interact with QuickTime Player, playing movies, stopping or pausing, stepping forward or backward, or adjusting the volume. All actions will launch QuickTime Player if it is not already running. The actions are:
System Control allows you to control your Mac. Most are pretty self explanatory. The actions are:
Send a MIDI message:
The MIDI messages come from a device named “Keyboard Maestro” which will be created as soon as you add any MIDI action.
Open actions allow you to open files, folders, URLs or System Preference Panes. The actions are:
Execute actions let you execute AppleScripts, Shell scripts, Automator Workflows or another macro. Shell scripts can be any kind of script, sh, zsh, tcsh, perl, python, and so on. The actions are:
The results of an AppleScript os shell script can be ignored, or you can:
For example, you could have a shell script date display briefly in a HUD window every hour, or use a hot key to type the results directly into your text editor.
These powerful actions allow you to add any new facilities we have not provided for, stringing them together with other actions as desired.
You can also use the clipboard by piping from pbpaste and to pbcopy.
Shell scripts are executed in the background and will be abandonded after 20 seconds, allowed to continue running to completion but otherwise ignored.
AppleScripts are executed in the background via osascript. This means they are not allowed to do user interaction. You can work around this by asking an application like System Events to do the user interaction for you, for example:
tell application "System Events" activate display dialog "Hello" end tell
The Insert Text action allows you to insert specified text either by setting the system clipboard and pasting, or by simulating a sequence of keystrokes.
Tokens are provided to include such things as the time or date.
The Insert Text action can be very useful to insert standard text templates, such as your signature, address, copyright or other boilerplate text, and so on. If you ever get email from Peter, you will probably notice that many of his emails end with “Thanks for your kind words, Peter.” - with the amount of email he deals with, you don’t think he types that in every time do you?
Insert Text can expand various tokens, including dates in any ICU date format. For example, we use an Insert Text action to insert the copyright message at the top of code files:
/* * Created by %UserName% on %ICUDateTime%EEE d MMM yyyy%. * Copyright (c) %ICUDateTime%yyyy% Stairways Software. All rights reserved. */
Clipboard actions let you manipulate the system clipboard, Named Clipboards and cut, copy or paste clipboard items. The actions are:
Filter Clipboard can apply a number of possible transforms to the current system clipboard:
We will likely expand the list of possible filters, so if you have specific filtering needs that you think might be of general interest, please let us know. In the mean time, remember that you can apply scripted filters using an AppleScript or shell script, for example the shell script:
pbpaste | perl -pe 'tr/A-Z/a-z/' | pbcopy
is roughly equivalent to the Lowercase filter, except that it only works with ASCII characters.
Each of these switchers is actually just a macro action, triggered like any other macro. By default Keyboard Maestro creates a Macro Group called Switcher Group which includes the following macros:
You can create your own macros using these actions or adjust their triggers within the Switcher Group.
You may want to change the Activate Program Switcher trigger to command-Tab to replace the system Program Switcher.
Recording allows Keyboard Maestro to watch you as you perform a task and create the actions to produce a similar result.
Record Quick Macro is a variant of this that you can activate at any time without even launching Keyboard Maestro. You trigger the recording, and then perform a series of actions, and then turn off recording. Then press the associated hot key to replay the recording.
By default, Keyboard Maestro creates a macro triggered by control-F1 which executes the Record Quick Macro action with a hot key of option-F1. So for example, if you press control-F1 to start quick recording, type “hello” and then press control-F1 again to finish recording, then Keyboard Maestro will type “hello” each time you press option-F1.
Because you cannot see or edit the recorded actions, it is best to keep them very simple. A good rule of thumb would be not to touch the mouse, just use the keyboard.
For example, say you wanted to quote a dozen different words in a paragraph, you could click in the middle of the first word, press control-F1 to start quick recording, type option-left arrow, quote ("), option-right arrow, quote ("), and then control-F1 again to finish recording. Now click in the middle of each remaining word and press option-F1.
The Google action displays a HUD window you can enter a search query in to and this fires off the query in your web browser.
The Pause action lets you pause in the middle of a sequence of actions. You can use this to get a visual break in your sequence of actions (eg for a slideshow), or to allow time for the applications affected by previous actions to “catch up” before continuing.
The Growl action lets you display a message using the Growl notification system. The message can include tokens so you can display the current clipboard or the date or various other pieces of information.
Play a simple beep. This can be useful for debugging complex Macros or for alerting you when a long running macro is finished.
The Alert action lets you display a message as a system alert. The message can include tokens so you can display the current clipboard or the date or various other pieces of information. The alert includes two buttons, Continue and Stop. The macro continues when you click Continue, or stops if you click Stop.
The Comment action lets you store a comment in your Macro. It does nothing when executed. This can be useful for documenting complex macros.
The Cancel All Macros action stops all macros currently executing.