Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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