AppleScript
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| AppleScript [2017/10/14 00:46] – ADD section headers, and clarify Local/Instance variables JMichaelTX | AppleScript [2025/02/27 06:45] (current) – [Local & Instance Variables] peternlewis | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| Keyboard Maestro Version 7.1 introduced a streamlined way to Get and Set Keyboard Maestro Variables from AppleScript. | Keyboard Maestro Version 7.1 introduced a streamlined way to Get and Set Keyboard Maestro Variables from AppleScript. | ||
| - | In AppleScript, | + | In AppleScript, |
| - | | + | ```applescript |
| - | setvariable <KM Variable Name> to <New Value> | + | tell application " |
| + | set v to getvariable | ||
| + | setvariable | ||
| + | end tell | ||
| + | ``` | ||
| where both the `<KM Variable Name>` and `<New Value>` are text values. | where both the `<KM Variable Name>` and `<New Value>` are text values. | ||
| - | **For more details, see [[manual: | + | **For more details, see:** |
| + | - [[manual: | ||
| + | - [[action: | ||
| ===== Global Variables ===== | ===== Global Variables ===== | ||
| Line 74: | Line 80: | ||
| - | To get or set [[manual: | + | To get or set [[manual: |
| - | + | ||
| - | * //Local Variables// are denoted by a Variable with the prefix of " | + | |
| - | * //Instance Variables// are denoted by a Variable with the prefix of " | + | |
| ```applescript | ```applescript | ||
| - | ### Requires Keyboard Maestro 8.0.3+ ### | ||
| - | |||
| set kmInst to system attribute " | set kmInst to system attribute " | ||
| tell application " | tell application " | ||
| - | set kmLocalVar1 | + | set v to getvariable " |
| setvariable " | setvariable " | ||
| end tell | end tell | ||
| - | log kmLocalVar1 | + | log v |
| ``` | ``` | ||
AppleScript.1507941985.txt.gz · Last modified: by JMichaelTX
