Keyboard Maestro 5 IconKeyboard Maestro 5

Conduct your Mac Like a Pro!

Macro Actions


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.

To see all actions, select the All Actions category. To select just your favorite actions, select the Favorites. You can drag actions into your Favorites category.

Application Control

Application 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 Current Application
quits the current application, optionally force quitting or relaunching.
Quit a Specific Application
quits the specified application, optionally force quitting or relaunching.
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.


Clipboard actions let you manipulate the system clipboard, Named Clipboards, the clipboard history 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. 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.
Delete Past Clipboard
delete a past 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.
Search and Replace Clipboard
search and replace the current system clipboard, optionally using regular expressions, and allowing Text Tokens. The replacement can also include $1 tokens for regular expression replacements.

The Filter Clipboard action includes a number of filters you can apply to the clipboard (or correspondingly, the Filter Variable action can apply them to variables).

The filters are:

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.

Control Flow

You can control the flow of a macro execution using a variety of actions, from a simple Pause for a number of seconds, through a complex nesting of If/Then/Else and looping.

The actions to control the flow of a macro are:

pause for a number (which may be a calculation) of seconds.
Pause Until
pause until conditions are met.
execute a list of actions until conditions are met.
while conditions are met, execute a list of actions.
repeat a list of actions a number (which may be a calculation) of times.
For Each
loop over a collection of values.
If Then Else
if conditions are met, execute a list of actions, otherwise execute another list.
Execute a Macro
execute another macro (like a subroutine).
Cancel All Macros
Cancel all macros that Keyboard Maestro Engine is currently executing.
Cancel This Macro
Cancel this macros (including any macro that executed this macro).

You will often need to use the Pause action to slow down replaying of an action sequence to allow the system time to catch up—especially after you have changed application or if you want to use a mouse click.

The condition clause of the flow control actions can be any of:

If there are no conditions in the set at all, the action will not execute anything except the Until action which will execute the actions once. Neither side of the If Then Else will execute.

There is over a dozen different kinds of conditions, from testing what the current application is, through examining variables or the clipboard, and on to check your network location or testing a pixel on your screen, see the Conditions section.

The For Each action loops over a set of collection items, setting a variable to each value and executing the contained actions. The collections can include:

The control flow actions include a nested list of their own actions to execute, and that nested list can include further control flow actions—go wild! But keep in mind, there may be a time when a shell or AppleScript is a more useful way of describing your solution.

See also the Conditions, Variables and Calculations sections.


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 Shell Script
execute a specified shell script, either from a file or text. For example, pbpaste | pbcopy.
Execute a Macro
execute a specified macro. This allows you to create subroutines of instructions. The current macro waits until the submacro finishes.

The results of an AppleScript or 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 can access variables by using environment variables, see the Variables section.

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"
  display dialog "Hello"
end tell

AppleScripts can access variables by talking to the Keyboard Maestro Engine, see the Variables section.


File actions allow you to interact with the file system, moving, copying, duplicating, trashing or deleting files or folders. The actions are:

The source path must be an absolute path (or a home relative ~ path). The destination path must either be a simple single path component (not ~ or /) or an absolute path. If it is a simple path component, then it is relative to the parent directory of the source path. This is particularly useful in the Move or Rename action, as you can, for example, rename from ~/Folder/Old Name to New Name.

You can read or write files in a variety of formats, including PNG, TIFF, JPEG, as well as HTML, Web Archive, Word Document and more.


Image actions allow you to manipulate images, such as flipping, rotating, or capturing the screen. The actions are:

Image actions typically act on an image in the clipboard or in a named clipboard. You can read or write images files using the File actions.

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 using any mouse button, and optionally dragging. 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, or a found image on the screen.
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 various size and location fields can be Calculations.

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. Alternatively, you can start the name with an ^ and use a regular expression to match the menu or button name. Also, Select Menu will translate the word "APPLICATION" (all capitals) into the current application name, allowing menu selections like APPLICATION -> About APPLICATION.

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.


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.


Keyboard Maestro can notify you in a variety of ways:

display a message via Growl (or in a popup HUD window if Growl is not installed).
Display Text
display text (which may contain Text Tokens).
display an alert (which may contain Text Tokens).
Prompt For User Input
display a dialog requesting information, see the Variables section.
System Beep
play a standard system beep.
Play Sound
play a sound, optionally through a specific output device.
Speak Text
speak text (which may contain Text Tokens) in any desired voice.
Highlight Location
highlight a location on the screen.


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 the Finder Selection
opens the files or folders that are currently selected in the Finder.
Open URL
open a URL with the appropriate helper.
Open System Preference Pane
opens a specified System Preference Pane.

Files, folders, the Finder selection and URLs can all open either in their default applications, or a specific application. So you could, for example, create a macro that opens the Finder selection in BBEdit.

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.


Keyboard Maestro includes several powerful switchers, including Application Launcher, Application 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 Application Launcher
activates the Application Launcher (Command-Control-Tab).
Activate Application Switcher
activates the Application Switcher (Command-Tab).
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 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.

By default, older versions of Keyboard Maestro used Option-Tab for its Application Switcher to avoid overriding the system Application Switcher, but if you wish to use Command-Tab you can do so. Similarly, if you wish to use the system switcher with Command-Tab, you can do so by changing the hot key trigger or by disabling Keyboard Maestro’s macro.

System Control

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

Put Computer to Sleep
puts your Mac to sleep.
Restart Computer
restarts your Mac.
Shut Down Computer
shuts down your Mac.
Fast User Switcher
Fast User Switcher to a specific user.
Log Out
Log Out the current 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 is already muted.
Increase/Decrease System Sound Volume
Increases or decreases the sound volume.
Set System Sound Volume
Sets the sound volume to a specific amount (can be a calculation).
Increase/Decrease Screen Brightness
Increases or decreases the screen brightness.


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. The Display Text action allows you to display the resulting text in a floating window or briefly in a HUD window (via Growl if available).

Tokens are provided to include variables, calculations, the time or date, or a large variety of other system information.

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 data format. For example, you can 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.

See also the Text Tokens section.


Keyboard Maestro includes permanently stored variables that you can use in a number of special purpose actions, as well as in Calculations or Text Tokens which can be used in almost any field in Keyboard Maestro.

These specific actions let you manipulate variables:

Set Variable to Text
set a variable to text. Text Tokens are provided to include such things as the value of other variables or the time or date.
Set Variable to Calculation
set a variable to the result of a calculation, see the Calculations section.
Filter Variable
apply one of a set of filters to a variable, see the Clipboard section.
Search and Replace Variable
search and replace the value of a variable, optionally using regular expressions, and allowing Text Tokens. The replacement can also include $1 tokens for regular expression replacements.
Use Variable
Use a variable to set a variety of system values like mouse location or front window. See below.
Prompt For User Input
display a dialog asking for a variety of user input. See below.

The Use Variable action can perform the following actions:

Most of these have analogs in the Text Tokens, so for example you might do:

Set variable ‘Temp’ To Text ‘%FrontWindowFrame%’
Set variable ‘Temp’ To Calculation ‘Temp[1]+Temp[3]/2,Temp[2]+Temp[4]/2’
Use ‘Temp’ to Set the Mouse Location

Which will result in the mouse being placed at the center of the front window.

Prompt For User Input will allow you to ask for user input, storing any results in variables as designed. If the variable is a password variable, it will be displayed in a password field.

If the default value you specify consists of choices separated by a bar (|), then a popup menu will be used (the first value will be the default value, and can be repeated later if a different location is desired). For example “Better|Good|Better|Best” would result in a popup menu with Good, Better, and Best, with Better pre-selected.

If the popup menu would contain only "0" and "1", then a checkbox is used (so for example “0|1" or "1|0", depending on the desired default).

You can include one or more buttons, which may optionally cancel the macro. You can also include / to configure command keys for the buttons (/. means escape, / by itself means the default button). If there are no text fields in the dialog, the command key is not needed and the letter by itself will complete the dialog. The name of the button pressed will be stored in the Result Button variable.

See also the Variables, Text Tokens and Calculations sections.


This action displays a HUD window where you can enter a search query and then sends the query in your web browser. You can customize the URL (by default the query is to search Google).

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.

Set Macro or Group Enable

The Set Macro or Group Enable action allows you to enable, disable or toggle the enable of a macro group or macro. The Keyboard Maestro editor does not need to be running, but it will see the enable state when it is next launched (or immediately if it is already running).


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

Show/Hide Macro Palette

These macros will show or hide the global macro palette. It will remain hidden until shown. You can also hide the global macro palette by clicking the close icon, so you may wish to include a global macro, perhaps with a status bar trigger, which uses the Show Macro Palette to redisplay it.

Continue on to Variables


Feedback Form

Please provide any feedback you may have

Email Address:

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.


Old Documentation