User Tools

Site Tools


AppleScript

**This is an old revision of the document!**

AppleScript Tips and Tricks for Keyboard Maestro


Create Keyboard Maestro variable using AppleScript.

# Keyboard Maestro — Create variable "<variable name>"
tell application "Keyboard Maestro Engine"
  make new variable with properties {name:"MyVariableName", value:MyVariableValue}
end tell

Note that the name MUST be a string, although you can hold that string in a varible:

set someVariable to "MyVariableName"
make new variable with properties {name:someVariable, value:MyVariableValue}

Set Keyboard Maestro variable using AppleScript.

# Keyboard Maestro — Set value of variable "<variable name>"
# Requires KM7.0.2 or higher.
set myText to "whatever"

tell application "Keyboard Maestro Engine"
  if variable "myKMVariableName" exists then
    set value of variable "myKMVariableName" to myText
  else
    make new variable with properties {name:"myKMVariableName", value:myText}
  end if
end tell

Get Keyboard Maestro variable using AppleScript.

# Keyboard Maestro — Get value of variable "<variable name>"
# Requires KM7.0.2 or higher.
tell application "Keyboard Maestro Engine"
  if variable "myKMVariableName" exists then
    set myAppleScriptVariableName to value of variable "myKMVariableName"
  end if
end tell
AppleScript.1450289478.txt.gz · Last modified: 2015/12/16 13:11 by ccstone