action:Execute_an_AppleScript
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| action:Execute_an_AppleScript [2023/09/12 08:24] – peternlewis | action:Execute_an_AppleScript [2025/02/27 06:45] (current) – [Using Keyboard Maestro Variables] peternlewis | ||
|---|---|---|---|
| Line 49: | Line 49: | ||
| ===== Using Keyboard Maestro Variables ===== | ===== Using Keyboard Maestro Variables ===== | ||
| - | :!: **See [[: | + | Keyboard Maestro sets the environment variables for the script |
| - | In AppleScript with Keyboard Maestro Version | + | Also, you can (7.1+) access |
| - | | + | ```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 example: | + | ===== Local & Instance Variables ===== |
| - | <code applescript> | + | |
| - | tell application " | + | |
| - | </ | + | |
| - | **Using Keyboard Maestro | + | To get or set [[manual:Variables# |
| - | AppleScripts can access variables by using environment variables (using | + | ```applescript |
| + | set kmInst to system attribute | ||
| + | tell application "Keyboard Maestro Engine" | ||
| + | set v to getvariable " | ||
| + | setvariable " | ||
| + | end tell | ||
| - | <code applescript> | + | log v |
| - | set myVar to do shell script "echo $KMVAR_My_KM_Variable" | + | ``` |
| - | </ | + | |
| ===== Error Handling ===== | ===== Error Handling ===== | ||
action/Execute_an_AppleScript.1694507051.txt.gz · Last modified: by peternlewis
