my setKMVar("MY_KM_Variable", "some new value") on setKMVar(pKMVarNameStr, pValueStr) --- Compatible with Keyboard Maestro 6+ --- -- • Creates the KM Variable if does not exist (just like KM 7 setvariable) -- • Returns true if new Variable was created set varCreatedBool to false tell application "Keyboard Maestro Engine" try set value of variable pKMVarNameStr to pValueStr on error errMsg number errNum if (errNum = -10006) then --- KM Variable Does NOT Exist --- --- Create & Set KM Variable --- make new variable with properties {name:pKMVarNameStr, value:pValueStr} set varCreatedBool to true else error ("Error " & errNum & ": " & errMsg) end if -- END on error end try end tell return varCreatedBool end setKMVar