Skip to content

Instantly share code, notes, and snippets.

@JMichaelTX
Last active March 9, 2024 06:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JMichaelTX/25ad8069b513bea77444 to your computer and use it in GitHub Desktop.
Save JMichaelTX/25ad8069b513bea77444 to your computer and use it in GitHub Desktop.
Set Keyboard Maestro (KM) Variable using AppleScript
###——————————————————————————————————————————————
# setKMVar() Sets KM Variable, Makes if needed
#
# Ver 2.0 2015-12-27
###——————————————————————————————————————————————
on setKMVar(pKMVarName, pKMVarValue)
--log ("setKMVar: " & pKMVarName & ": " & pKMVarValue)
tell application "Keyboard Maestro Engine"
try -- to set variable, will error if it doesn't exist
set value of variable pKMVarName to pKMVarValue
on error -- Make & Set Variable
make new variable with properties {name:pKMVarName, value:pKMVarValue}
end try
end tell -- KM
end setKMVar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment