Browse the docs

Keyboard Maestro tokens and functions

Keyboard Maestro tokens and calculation functions.

Keyboard Maestro writes tokens as %Name%; Switchboard writes expressions as {{ }}. The importer converts both.

Tokens #

Keyboard Maestro tokenWhat it isBecomes
%AccessedVariables%returns (v10.{{runInfo("accessedVariables")}}
%ActionResult%returns text indicating the success or failure of the immediate past action.{{runInfo("actionResult")}}
%AddressBook%The %AddressBook%x% token returns information about your AddressBook entry (the “Me” card).{{addressBook("")}}
%AlertButton%(v8+) returns the name of the last selected Alert button in this execution instance.{{runInfo("alertButton")}}
%Application%Each token take a parameter indicating the application.{{appInfo("name", "x")}}
%ApplicationBundleID%You can get information about running applications using the variable Application tokens:{{appInfo("bundleID", "")}}
%ApplicationLongVersion%You can get information about running applications using the variable Application tokens:{{appInfo("longVersion", "")}}
%ApplicationName%You can get information about running applications using the variable Application tokens:{{appInfo("name", "")}}
%ApplicationPath%You can get information about running applications using the variable Application tokens:{{appInfo("path", "")}}
%ApplicationVersion%You can get information about running applications using the variable Application tokens:{{appInfo("version", "")}}
%Ask%The %Ask% tokens is a placeholder used in the Prompt for Snippet action to indicate locations where user input for the snippet is required.{{askUser("")}}
%AudioDevice%The audio device tokens (v11.{{audioDevice("output")}}
%AudioInputDevice%The audio device tokens (v11.{{audioDevice("input")}}
%AudioInputDeviceUID%The audio device tokens (v11.{{audioDevice("input", "uid")}}
%AudioInputDevices%The AudioInputDevices token (v11.{{audioDevice("input", "list")}}
%AudioOutputDevice%%AudioOutputDevice% (available since v8.{{audioDevice("output")}}
%AudioOutputDeviceUID%The audio device tokens (v11.{{audioDevice("output", "uid")}}
%AudioOutputDevices%The AudioOutputDevices token (v11.{{audioDevice("output", "list")}}
%AudioSoundEffectsDevice%The audio device tokens (v11.{{audioDevice("effects")}}
%AudioSoundEffectsDeviceUID%The audio device tokens (v11.{{audioDevice("effects", "uid")}}
%Bin%The %Bin8% token (v8+) returns the value in binary format, padded with zeros to eight digits (similarly % Bin16% to 16 digits digits, etc).{{formatBase((0), 2, 0)}}
%Calculate%The %Calculate%<formula>% token returns the numeric result of performing a calculation,{{(number(shared.x))}}
%CalculateFormat%The %CalculateFormat%<formula>%<format>% token (v8+) returns the numeric result of performing a calculation.Plain text
%ChromeBundleID%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("chrome", "bundleID")}}
%ChromeField%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserField("chrome", "")}}
%ChromeJavaScript%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserJS("chrome", "")}}
%ChromeLongVersion%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("chrome", "longVersion")}}
%ChromeName%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("chrome", "name")}}
%ChromePath%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("chrome", "path")}}
%ChromeReadyState%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("chrome", "readyState")}}
%ChromeTitle%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("chrome", "title")}}
%ChromeURL%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("chrome", "url")}}
%ChromeVersion%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("chrome", "version")}}
%ChromeWindowName%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("chrome", "windowName")}}
%CurrentApplication%returns the name of the current application (same as %Application%1%).{{currentApp()}}
%CurrentClipboard%The %SystemClipboard% token (prior to v8, called the %CurrentClipboard% token) returns the text of the current system clipboard.{{clipboard}}
%CurrentMouse%returns the current mouse location.{{mouseLocation()}}
%CurrentTrack%%CurrentTrack%name% - the current iTunes track name.{{currentTrack("")}}
%Dec%The %Dec2% token (v8+) returns the value in decimal format, padded with zeros to two digits (similarly %Dec5% to five digits, etc).{{formatBase((0), 10, 0)}}
%Delete%The %Delete% tokens is not a real token.Plain text
%Dictionary%The %Dictionary[<Dict>,<Key>]% token (v8+) allows you to access dictionary values in a token text field, where <Dict> is the name of the dictionary and <Key> is the key.Plain text
%ExecutingInstance%returns (v9.{{runInfo("instanceID")}}
%ExecutingInstanceName%The %ExecutingInstanceName%instance% token returns (v9.{{runInfo("instanceName")}}
%ExecutingInstances%returns (v9.{{runInfo("instanceID")}}
%ExecutingMacro%returns the name of the currently executing macro.Plain text
%ExecutingMacroGroup%returns the name of the macro group containing the currently executing macro.{{runInfo("groupName")}}
%ExecutingMacroGroupUUID%returns the UUID of the macro group containing the currently executing macro.{{runInfo("groupID")}}
%ExecutingMacroUUID%returns the unique ID of the currently executing macro.{{runInfo("macroID")}}
%ExecutingThisMacro%returns the name of the macro the action is within.Plain text
%ExecutingThisMacroGroup%returns the name of the macro group the action is within.{{runInfo("groupName")}}
%ExecutingThisMacroGroupUUID%returns the UUID of the macro group the action is within.{{runInfo("groupID")}}
%ExecutingThisMacroUUID%returns the UUID of the macro the action is within.{{runInfo("macroID")}}
%FindPasteboard%returns the current system find pasteboard value.{{findPasteboard()}}
%FinderInsertionLocation%returns insertion location in the Finder, which is usually the path of the front window.{{finderInsertionLocation()}}
%FinderSelection%returns (v10.{{finderSelection()}}
%FinderSelections%returns (v10.{{finderSelections()}}
%FoundImage%The %FoundImage% Token (v8+) returns the details of the last found image in this execution instance.{{runInfo("foundImage")}}
%FrontBrowser%(v9+) returns the name of the front browser (the most recently front web browser of Safari or Google Chrome).{{browserInfo("front", "name")}}
%FrontBrowserBundleID%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("front", "bundleID")}}
%FrontBrowserField%The %FrontBrowserField%document.{{browserField("front", "")}}
%FrontBrowserJavaScript%The %FrontBrowserJavaScript%document.{{browserJS("front", "")}}
%FrontBrowserLongVersion%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("front", "longVersion")}}
%FrontBrowserName%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("front", "name")}}
%FrontBrowserPath%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("front", "path")}}
%FrontBrowserReadyState%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("front", "readyState")}}
%FrontBrowserTitle%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("front", "title")}}
%FrontBrowserURL%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("front", "url")}}
%FrontBrowserVersion%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("front", "version")}}
%FrontBrowserWindowName%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("front", "windowName")}}
%FrontDocumentPath%The %FrontDocumentPath % token returns (v11.{{frontDocumentPath()}}
%FrontWindowFrame%%WindowFrame% and %FrontWindowFrame%{{windowInfo("1", "frame")}}
%FrontWindowName%%WindowName% and %FrontWindowName%{{frontWindowTitle}}
%FrontWindowPosition%%WindowPosition% and %FrontWindowPosition%{{windowInfo("1", "position")}}
%FrontWindowSize%%WindowSize% and %FrontWindowSize%{{windowInfo("1", "size")}}
%HTMLResult%(v8+) returns the result of the last Custom HTML Prompt action in this execution instance.{{runInfo("htmlResult")}}
%Hex%The %Hex2% token (v8+) returns the value in Hex format, padded with zeros to two digits.{{formatBase((0), 16, 0)}}
%ICUDateTime%The %ICUDateTime%, %ICUDateTimePlus%, %ICUDateTimeMinus% and %ICUDateTimeFor% tokens return the a date formatted in a specific format.{{date("x")}}
%ICUDateTimeFor%The %ICUDateTime%, %ICUDateTimePlus%, %ICUDateTimeMinus% and %ICUDateTimeFor% tokens return the a date formatted in a specific format.Plain text
%ICUDateTimeMinus%The %ICUDateTime%, %ICUDateTimePlus%, %ICUDateTimeMinus% and %ICUDateTimeFor% tokens return the a date formatted in a specific format.Plain text
%ICUDateTimePlus%The %ICUDateTime%, %ICUDateTimePlus%, %ICUDateTimeMinus% and %ICUDateTimeFor% tokens return the a date formatted in a specific format.Plain text
%JSONFromDictionary%The %JSONFromDictionary%dictionary% token returns the JSON object constructed from the specified dictionary.{{jsonText(shared.x)}}
%JSONFromVariables%The %JSONFromVariables%prefix% token returns the JSON object constructed from the variables with the specified prefix.{{jsonText(variablesJSON("shared.x"))}}
%JSONValue%The %JSONValue%jsonpath% token returns the JSON value from the specified JSON path).{{jsonValue("")}}
%KeyboardLayout%(v8+) returns the current keyboard layout name.{{keyboardLayout()}}
%KeyboardMaestroLongVersion%The %KeyboardMaestroVersion% and %KeyboardMaestroLongVersion% tokens (v11.Plain text
%KeyboardMaestroVersion%The %KeyboardMaestroVersion% and %KeyboardMaestroLongVersion% tokens (v11.Plain text
%LastAbortedActionID%returns (v11.{{runInfo("lastAbortedActionID")}}
%LastApplication%returns the name of the last application (same as %Application%2%).{{lastApp()}}
%LastWindowID%returns (v10.{{runInfo("lastWindowID")}}
%LineFeed%returns the linefeed (0x0A) character.Plain text
%LongDate%returns the current date in a localized long format.{{localizedDate("date", "long")}}
%LongSystemVersion%Note the %SystemLongVersion% token was incorrectly %LongSystemVersion% from v11.{{systemLongVersion()}}
%LongTime%returns the current time with seconds in a localized format.{{localizedDate("time", "medium")}}
%MacIPAddress%returns the current Mac IP Address.{{macIP()}}
%MacName%returns the current Mac name.{{macName()}}
%MacUUID%returns a unique ID for this Mac.{{macUUID()}}
%MacroNameForUUID%%%MacroNameForUUID%%%Variable%myUUID%%%{{macroName("")}}
%MailBCCRecipients%returns comma separated list of the bcc recipients in the currently selected mail message.{{mailInfo("bcc")}}
%MailCCRecipients%returns comma separated list of the cc recipients in the currently selected mail message.{{mailInfo("cc")}}
%MailContents%returns the contents of the currently selected mail message.{{mailInfo("contents")}}
%MailRawSource%returns the raw source of the currently selected mail message.{{mailInfo("rawSource")}}
%MailRecipients%returns comma separated list of the recipients in the currently selected mail message.{{mailInfo("recipients")}}
%MailReplyTo%returns the reply to of the currently selected mail message.{{mailInfo("replyTo")}}
%MailSender%returns the sender of the currently selected mail message.{{mailInfo("sender")}}
%MailSubject%returns the subject of the currently selected mail message.{{mailInfo("subject")}}
%MailToRecipients%returns comma separated list of the to recipients in the currently selected mail message.{{mailInfo("to")}}
%MusicPlayerState%The MusicPlayerState token (v11.{{musicPlayerState()}}
%NamedClipboard%returns the text of a specified named clipboard.{{namedClipboard("")}}
%NamedClipboardFlavors%(v11.{{namedClipboardFlavors("")}}
%NetworkLocation%returns the current network location name.{{networkLocation()}}
%NumberDate%returns the current date in a localized numeric format.{{localizedDate("date", "short")}}
%Oct%The %Oct3% token (v8+) returns the value in octal format, padded with zeros to three digits (similarly % Oct5% to five digits, etc).{{formatBase((0), 8, 0)}}
%OptionReturn%(v11.Plain text
%PastClipboard%returns the text of a specified past clipboard.{{pastClipboard((0))}}
%PastClipboardFlavors%(v11.{{pastClipboardFlavors((0))}}
%PasteByNameText%returns (v10.{{runInfo("pasteByNameText")}}
%PromptButton%(v8+) returns the name of the last selected Prompt for User Input button in this execution instance.{{runInfo("promptButton")}}
%PromptWithListModifiers%returns (v10.{{runInfo("promptWithListModifiers")}}
%PromptWithListText%returns (v10.{{runInfo("promptWithListText")}}
%RandomUUID%(v8+) returns a new random universally unique ID.{{upper(uuid())}}
%Return%returns the carriage return (0x0D) character.Plain text
%SafariBundleID%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("safari", "bundleID")}}
%SafariField%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserField("safari", "")}}
%SafariJavaScript%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserJS("safari", "")}}
%SafariLongVersion%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("safari", "longVersion")}}
%SafariName%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("safari", "name")}}
%SafariPath%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("safari", "path")}}
%SafariReadyState%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("safari", "readyState")}}
%SafariTitle%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("safari", "title")}}
%SafariURL%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("safari", "url")}}
%SafariVersion%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("safari", "version")}}
%SafariWindowName%The tokens come in three forms, for example %SafariTitle%, %ChromeTitle%, %FrontBrowserTitle%.{{browserInfo("safari", "windowName")}}
%Screen%The %Screen% tokens returns the frame of the specified screen.{{screenFrame("")}}
%ScreenResolution%(v11.{{screenResolution("")}}
%ScreenResolutions%(v11.{{screenResolutions("")}}
%ScreenVisible%The %ScreenVisible% tokens returns the visible frame of the specified screen, excluding the menu bar and the dock.{{screenVisibleFrame("")}}
%SelectMenuByNameText%returns (v11.{{runInfo("selectMenuByNameText")}}
%ShortDate%returns the current date in a localized short format.{{localizedDate("date", "short")}}
%ShortTime%returns the current time without seconds in a localized format.{{localizedDate("time", "short")}}
%Space%returns the space character.Plain text
%SystemClipboard%(prior to v8, called the %CurrentClipboard% token) returns the text of the current system clipboard.{{clipboard}}
%SystemClipboardFlavors%(v11.{{clipboardFlavors()}}
%SystemLongVersion%The %SystemVersion% and %SystemLongVersion% tokens (v11.{{systemLongVersion()}}
%SystemVersion%The %SystemVersion% and %SystemLongVersion% tokens (v11.{{systemVersion()}}
%SystemVolume%returns the current system volume.{{systemVolume()}}
%Tab%returns the tab (0x08) character.Plain text
%Trigger%returns the trigger description of the trigger that fired this macro.{{runInfo("trigger")}}
%TriggerBase%returns the trigger type.{{runInfo("triggerBase")}}
%TriggerClipboard%(v8+) returns the text of a Trigger Clipboard.{{triggerValue}}
%TriggerClipboardFlavors%(v11.{{clipboardFlavors()}}
%TriggerValue%returns the value associated with how the macro was triggered.{{triggerValue}}
%UserHome%returns (v10.{{userHome()}}
%UserLoginID%returns the current user login id.{{userLogin()}}
%UserName%returns the current user name.{{userName()}}
%VBAR%The vertical bar text token (%/%) is a special token used with the Insert Text action which adds a sequence of left arrow keystrokes to the end of the action to (attempt to) position the insertion cursor at the desired sPlain text
%Variable%The %Variable%<VariableName>% token allows you to include a variable in a token text field, where <VariableName> is the name of the variable.{{shared.x}}
%WindowFrame%%WindowFrame% and %FrontWindowFrame%{{windowInfo("1", "frame")}}
%WindowName%%WindowName% and %FrontWindowName%{{windowInfo("1", "name")}}
%WindowPosition%%WindowPosition% and %FrontWindowPosition%{{windowInfo("1", "position")}}
%WindowSize%%WindowSize% and %FrontWindowSize%{{windowInfo("1", "size")}}
%WirelessNetwork%returns the name of the currently connected wireless network(s).{{wirelessNetwork()}}
%Hex<N>%%Hex<N>%formula% - number as hexadecimal padded to N digitsPlain text
%Dec<N>%%Dec<N>%formula% decimal paddedPlain text
%Oct<N>%%Oct<N>%formula% octal paddedPlain text
%Bin<N>%%Bin<N>%formula% binary paddedPlain text
%JSONFromVariables<Pretty|Compact|Strict..>%%JSONFromVariables%name1/name2% as JSON (variants Compact/Pretty/Strict)Plain text
%JSONFromDictionary<variant>%%JSONFromDictionary%name% as JSON (variants)Plain text
%JSONValue<variant>%%JSONValue%jsonpath% (variants Compact, Pretty, Strict, CompactStrict, PrettyStrict)Plain text

Functions #

Keyboard Maestro functionSwitchboard
ABS(x)abs
ACOS(x)acos
APPLICATIONS()applications
ASIN(x)asin
ATAN(x)atan
ATAN2(y,x)atan2
BATTERY()battery
BIN(t)bin
CALCULATE(t)calculate
CEIL(x)ceil
CHARACTERS(t)characters
CHROMEISCOMPLETE()chromeIsComplete
CHROMETABCOUNT()chromeTabCount
CHROMETABINDEX()chromeTabIndex
CLIPBOARDSEED()clipboardSeed
CONCEALEDPALETTES()concealedPalettes
COS(x)cos
COSH(x)cosh
COUNT((context: size of enclosing JSON array))kmCount
DARKMODE()darkMode
DAY([unixtime])day
DOUBLECLICKINTERVAL()doubleClickInterval
DOW([unixtime])dow
DPI(X|Y)dpi
EXP(x)exp
FLOOR(x)floor
FONTSIZE()fontSize
FRONTBROWSERISCOMPLETE()frontBrowserIsComplete
FRONTBROWSERTABCOUNT()frontBrowserTabCount
FRONTBROWSERTABINDEX()frontBrowserTabIndex
GMTOFFSET()gmtOffset
HEX(t)hex
HOUR([unixtime])hour
IDLE()idle
IMAGE(Width|Height)image
JD(year, month, day, hour, minute, second)jd
JD2MJD(x)jd2mjd
JD2TIME(x)jd2time
JSONVALUE(jsonpath)jsonValue
KEYREPEATDELAY()keyRepeatDelay
KEYREPEATINTERVAL()keyRepeatInterval
KMDARKMODE()appDarkMode
LENGTH((context: length of text the action works on))kmLength
LINES(t)lines
LOG(x)log
LOG10(x)log10
LOG2(x)log2
MAILDATERECEIVED()mailDateReceived
MAILDATESENT()mailDateSent
MAILFLAG()mailFlag
MAILFLAGGED()mailFlagged
MAILJUNKSTATUS()mailJunkStatus
MAILREADSTATUS()mailReadStatus
MAILWASFORWARDED()mailWasForwarded
MAILWASREDIRECTED()mailWasRedirected
MAILWASREPLIEDTO()mailWasRepliedTo
MAX(x,y)max
MEMORY()memory
MENUBARHEIGHT()menuBarHeight
MICROSECONDS()microseconds
MILLISECONDS()milliseconds
MIN(x,y)min
MINUTE([unixtime])minute
MJD(year, month, day, hour, minute, second)mjd
MJD2JD(x)mjd2jd
MJD2TIME(x)mjd2time
MONTH([unixtime])month
MOUSEBUTTON()mouseButton
MOUSEX()mouseX
MOUSEY()mouseY
NOW()now()
OCT(t)oct
ONLINE()online
PIXEL(component,x,y)pixel
PROCESSORS()processors
RAND([N])rand
RANDOM(A,B)random
ROUND(x)round
SAFARIISCOMPLETE()safariIsComplete
SAFARITABCOUNT()safariTabCount
SAFARITABINDEX()safariTabIndex
SCREEN(index [number OR name], coordinate, percentage)screen
SCREENCOUNT()screenCount
SCREENINDEX()screenIndex
SCREENSAVER()screenSaver
SCREENVISIBLE()screenVisible
SECOND([unixtime])second
SECONDS()seconds
SECUREINPUT()secureInput
SIN(x)sin
SINH(x)sinh
SOURCEDPI(X|Y)sourceDpi
SOURCEIMAGE(Width|Height)sourceImage
SYSTEMVOLUME()systemVolume
TAN(x)tan
TANH(x)tanh
TIME(year, month, day, hour, minute, second)time
TIME2JD(x)time2jd
TIME2MJD(x)time2mjd
TRIGGERTIME()triggerTime
TRUNC(x)trunc
UPTIME()uptime
WINDOW(Index, Coordinate)window
WINDOWCOUNT()windowCount
WORDS(t)words
YEAR([unixtime])year