User Tools

Site Tools


AppleScript

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
AppleScript [2025/02/27 06:34] – [Using AppleScript to Get and Set Keyboard Maestro Variables] peternlewisAppleScript [2025/02/27 06:45] (current) – [Local & Instance Variables] peternlewis
Line 7: Line 7:
 ```applescript ```applescript
 tell application "Keyboard Maestro Engine" tell application "Keyboard Maestro Engine"
-    getvariable <KM Variable Name> +    set v to getvariable "<KM Variable Name>" 
-    setvariable <KM Variable Name> to <New Value>+    setvariable "<KM Variable Name>to "<New Value>"
 end tell end tell
 ``` ```
Line 80: Line 80:
  
  
-To get or set [[manual:Variables#Instance_Variables_v8|Local or Instance Variables]], you must pass the macro execution instance to the `getvariable` or `setvariable` command.  The instance is passed in to your script via the KMINSTANCE environment variable (v8.0.3+)+To get or set [[manual:Variables#Scope|Local or Instance Variables]], you must pass the macro execution instance to the `getvariable` or `setvariable` command.  The instance is passed in to your script via the KMINSTANCE environment variable (v8.0.3+).
- +
-  * //Local Variables// are denoted by a Variable with the prefix of "Local"+
-  * //Instance Variables// are denoted by a Variable with the prefix of "Instance".+
  
 ```applescript ```applescript
-### Requires Keyboard Maestro 8.0.3+ ### 
- 
 set kmInst to system attribute "KMINSTANCE" set kmInst to system attribute "KMINSTANCE"
 tell application "Keyboard Maestro Engine" tell application "Keyboard Maestro Engine"
- set kmLocalVar1 to getvariable "Local__SomeLocalVariable" instance kmInst+ set to getvariable "Local__SomeLocalVariable" instance kmInst
  setvariable "Local__FromAS" instance kmInst to "Variable set in AppleScript."  setvariable "Local__FromAS" instance kmInst to "Variable set in AppleScript."
 end tell end tell
  
-log kmLocalVar1+log v
 ``` ```
  
AppleScript.1740638090.txt.gz · Last modified: by peternlewis

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki