Keyboard Maestro IconKeyboard Maestro

Conduct your Mac Like a Pro!

Macro Actions

Overview

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

Process Control actions allow your to switch, quit, or hide applications. The actions are:

Switch to Last Application
switches back to the previous application you were in.
Switch to Next Application
switches to the next application (alphabetically).
Activate a Specific Application
launches if necessary and brings the specified application to the front, optionally reopening the initial windows. If the application is already at the front, the action can optionally switch out, hide or quit it, allowing you to toggle an application, very useful for utilities like PCalc.
Bring Application Windows to Front
brings all the windows of the current application to the front.
Quit All Applications
quits all foreground applications, optionally honoring the excluded application list.
Quit Other Applications
quits all foreground applications except the current one, optionally honoring the excluded application list.
Quit a Specific Application
quits the specified application.
Hide All Applications
hides all foreground applications, optionally honoring the excluded application list.
Hide Other Applications
hides all foreground applications except the current one, optionally honoring the excluded application list.
Hide Current Application
hides the current application.
Hide a Specific Application
hides the specified application.
Show All Applications
shows all foreground applications.
Show a Specific Application
shows the specified application.

Interface Control

Interface Control actions allow you to interact with the user interface, selecting menus, clicking buttons, simulating keystrokes and so forth. The actions are:

Manipulate Window
resize, move, center, bring to front, close, zoom, or minimize the front window or a specified window.
Move or Click Mouse
move, click or move and click the mouse. You can specify modifiers such as the shift key, as well as the position, relative to any corner of the front window, the main screen, or the current mouse location.
Select Menu Item
select a specified menu item in the front or a specified application.
Press Button
press a named button in the front window.
Simulate Keystroke
simulate pressing a specified keystroke.
Simulate Scroll Wheel
simulate scrolling the mouse wheel up or down, left or right.

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

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:

Play a Specific Track
play a specified song.
Play a Specific Playlist
play the songs in a specified Playlist.
Play a Random Track
play a random song.
Play a Random Track from a Specified Playlist
play a random song from a specified Playlist.
Play/Pause Current Track
toggle from playing to pausing or vice-versa.
Pause Current Track
pause the current song.
Stop Current Track
stop playing any song.
Fast-Forward Current Track
fast-forward the current song. It will keep fast-forwarding until you do something else or until it reaches the end of the song.
Rewind Current Track
rewind the current song. It will keep rewinding until you do something else or until it reaches the beginning of the song.
Next Track
play the next song.
Previous Track
Go to the previous song or the start of the current song if it is already playing.
Increase/Decrease or Set iTunes Volume
Increase, decrease or set the iTunes volume.
Increase/Decrease or Set Rating
Increase, decrease or set the rating of the current track.

QuickTime Player Control

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:

Play Current Movie
play the current movie.
Play/Pause Current Movie
toggle from playing to pausing or vice-versa.
Pause Current Movie
pause the current movie.
Step Forward Current Movie
step the current movie forward one frame.
Step Backward Current Movie
step the current movie backward one frame.
Increase/Decrease or Set QuickTime Player Volume
Increase, decrease or set the QuickTime Player volume.

System Control

System Control allows you to control your Mac. Most are pretty self explanatory. The actions are:

Sleep Computer
puts your Mac to sleep.
Restart Computer
restarts your Mac.
Shutdown Computer
shuts your Mac down.
Log Out
Log Out the current user.
Fast User Switcher
Fast User Switcher to a specific user.
Activate Screen Saver
starts the screen saver (could be especially useful if the screen saver requires a password to unlock it).
Open/Close CD Tray
Opens the CD tray if it is closed, or closes it if open (especially useful for keyboards that do not have an eject key).
Toggle System Sound Mute
Mutes the sound if sound is currently on, unmutes the sound if already muted.
Increase/Decrease System Sound Volume
Increases or decreases the sound volume.
Increase/Decrease Screen Brightness
Increases or decreases the screen brightness.

MIDI

Send a MIDI message:

Send MIDI Note On
sends a MIDI Note On message, specifying the note, velocity and channel.
Send MIDI Note Off
sends a MIDI Note Off message, specifying the note, velocity (usually 0) and channel.
Send MIDI Control Change
sends a MIDI Control Change message, specifying the control, value and channel.

The MIDI messages come from a device named “Keyboard Maestro” which will be created as soon as you add any MIDI action.

Open

Open actions allow you to open files, folders, URLs or System Preference Panes. The actions are:

Open File or Folder
opens a specified file or folder. Don’t underestimate the power of this command as you can open bookmarks or other action documents to perform a lot of customized actions.
Open URL
open a URL with the appropriate helper.
Open System Preference Pane
opens a specified System Preference Pane.

Execute

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:

Execute AppleScript
execute a specified AppleScript, either from a file or text. For example, say "hello".
Execute Automator Workflow
execute a specified Automator Workflow.
Execute a Macro
execute a specified macro. This allows you to create subroutines of instructions. The current macro waits until the submacro finishes.
Execute Shell Script
execute a specified shell script, either from a file or text. For example, pbpaste | pbcopy.

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

Text

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

Clipboard actions let you manipulate the system clipboard, Named Clipboards and cut, copy or paste clipboard items. The actions are:

Cut
Copy, Paste,simulate command-X, command-C, or command-V keystrokes to Cut, Copy or Paste to/from the system clipboard.
Set Clipboard to Text
set the system clipboard to text. Tokens are provided to include such things as the time or date.
Set Clipboard to Past Clipboard
set the system clipboard to some item that was previously copied to the system clipboard. This can be used to restore the system clipboard after another action sets the clipboard temporarily.
Use a Named Clipboard
cut, copy or paste to/from the specified Named Clipboard.
Set Clipboard to Named Clipboard
set the system clipboard to a specified Named Clipboard.
Save Clipboard to Named Clipboard
set the specified Named Clipboard to the current system clipboard.
Apply a BBEdit Text Factory
apply any saved BBEdit Text Factory to the current system clipboard.
Filter Clipboard
apply one of a set of filters on the current system clipboard (see below for a list).

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.

Activate Switcher

Keyboard Maestro includes several powerful switchers, including Program Switcher, Window Switcher, and Copy, Cut and Paste Clipboard Switchers and Clipboard History Switcher.

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:

Activate Clipboard Copy Switcher
copies the current selection to a named clipboard you select (command-shift-C).
Activate Clipboard Cut Switcher
cuts the current selection to a named clipboard you select (command-shift-X).
Activate Clipboard Paste Switcher
pastes a named clipboard you select into the current system clipboard and current selection (command-shift-V).
Activate Clipboard History Switcher
pastes a previous system clipboard you select from the clipboard history into the current system clipboard and current selection (command-control-shift-V).
Activate Program Switcher
activates the Program Switcher (option-Tab).
Activate Window Switcher
activates the Window Switcher (control-Tab).

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.

Record Quick Macro

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.

Google

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.

Pause

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.

Growl

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.

System Beep

Play a simple beep. This can be useful for debugging complex Macros or for alerting you when a long running macro is finished.

Alert

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.

Comment

The Comment action lets you store a comment in your Macro. It does nothing when executed. This can be useful for documenting complex macros.

Cancel All Macros

The Cancel All Macros action stops all macros currently executing.

Continue on to Macro Triggers

Close

Feedback Form

Please provide any feedback you may have


Email Address:
Subject:
Feedback:


Your email address is appreciated but is not required and will not be saved.
It will be used only for responding to or clarifying this feedback.

Documentation

Old Documentation