User Tools

Site Tools


manual:Scripting

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
manual:Scripting [2018/07/02 19:38]
JMichaelTX Add setup options table
manual:Scripting [2021/10/17 23:33]
peternlewis [Using Keyboard Maestro Facilities from AppleScript]
Line 21: Line 21:
 **There are two setup options:** **There are two setup options:**
 ^ Setup Option ^ Choices\\ (Default shown first) ^ ^ Setup Option ^ Choices\\ (Default shown first) ^
-| Script location | Execute text script (type or paste script into Action text field)\\ Execute script file (This is faster if it is a compiled script file `.scpt`) | +| Script location | Execute text script (type or paste script into Action text field)\\ Execute script file (This may be faster if it is a compiled script file `.scpt`) | 
-| Script Results | Ignored.\\ Displayed in a floating window.\\ Displayed briefly in a Notification.\\ Typed in the current text field that has focus.\\ Pasted in text field that has focus.\\ Saved to a Keyboard Maestro Variable.\\ Saved to the System or Named Clipboard.\\ Ignore Results and run //​Asynchronously//​ (the script runs while the macro continues on to the next //Action//.) |+| Script Results | Ignored.\\ Displayed in a floating window.\\ Displayed briefly in a Notification.\\ Typed in the current text field that has focus.\\ Pasted in text field that has focus.\\ Saved to a Keyboard Maestro Variable.\\ Saved to the System or Named Clipboard.\\ Ignore Results and run //​Asynchronously//​ (the script runs while the macro continues on to the next //Action//)|
  
  
Line 35: Line 35:
 For more information about using the Clipboard in scripts, see: For more information about using the Clipboard in scripts, see:
   * [AppleScript Clipboard Commands suite](https://​developer.apple.com/​library/​mac/​documentation/​AppleScript/​Conceptual/​AppleScriptLangGuide/​reference/​ASLR_cmds.html)   * [AppleScript Clipboard Commands suite](https://​developer.apple.com/​library/​mac/​documentation/​AppleScript/​Conceptual/​AppleScriptLangGuide/​reference/​ASLR_cmds.html)
-  * [Shell Scripts Pasteboard Commands: ​pbcopy, pbpaste](https://​developer.apple.com/​legacy/​library/​documentation/​Darwin/​Reference/​ManPages/​man1/​pbpaste.1.html)+  * The unix man pages for pbcopy, pbpaste.
  
 ==== Automating Applications and Adding Functionality to Keyboard Maestro ==== ==== Automating Applications and Adding Functionality to Keyboard Maestro ====
Line 170: Line 170:
 end tell end tell
 </​code>​ </​code>​
 +
 +or process tokens with:
 +
 +<code applescript>​
 +tell application "​Keyboard Maestro Engine"​
 +  process tokens "​%LongDate%"​
 +end tell
 +</​code>​
 +
 +The `calculate` and `process tokens` commands can also take an `instance` parameter (v10.0+) to specify the instance for local variable access.
  
 You can ask Keyboard Maestro Engine to find strings in other scripts: You can ask Keyboard Maestro Engine to find strings in other scripts:
Line 213: Line 223:
 See the Keyboard Maestro AppleScript dictionary for more information. See the Keyboard Maestro AppleScript dictionary for more information.
  
-===== URL Schemes ===== +===== Controlling ​Keyboard Maestro ​Engine via Scripting ​=====
- +
-==== Editor ==== +
- +
-Another way you can control ​Keyboard Maestro ​editor is using the "​`keyboardmaestro`"​ URL scheme, which supports the following formats: +
- +
-^ Example Editor URL Command ^ Description ^ +
-| `keyboardmaestro://​u=support%40stairways.com/​s=ABCDEFGH0123456789` | enter your username/​serial number. | +
-| `keyboardmaestro://​m=Activate%20Application%20Switcher`\\ `keyboardmaestro://​m=D2F427A1-51E3-4719-820B-4C25B6FF7329` | edit a specific macro or macro group.\\ You may used either the Macro Name, or UUID. | +
-| `keyboardmaestro://​q=Activate` | filter macros with this keyword. | +
-| `keyboardmaestro://​g=All%20Macros/​q=Activate` | select a macro group and filter macros with this keyword. | +
-| `keyboardmaestro://​a=Execute` | filter actions with this keyword. | +
-| `keyboardmaestro://​c=All%20Actions/​a=Execute` | select action category and filter actions with this keyword. | +
- +
----+
  
-==== Triggers ====+You can adjust Keyboard Maestro Engine windows with:
  
-You can trigger a macro (that is Active and Enabled) using the "​`kmtrigger`"​ URL scheme. ​ The URL uses this format: +<code applescript
- +tell application ​"Keyboard Maestro Engine" 
-`kmtrigger://​macro=<​Macro Name or UUID>​[&​<Trigger Value>]` +    set bounds of window ​"Clipboard History Switcher" ​to {1000, 50, 2000, 1200
- +end tell 
-where +</​code>​
-  * `<Macro Name or UUID>` is either the Macro Name, OR, its UUID +
-  * `<​Trigger Value>` is the _optional_ Trigger Value +
-  * `[ ]` are _not_ included. ​ Used only to show _optional_ parameters +
-  * `&` must precede the Trigger Value, if it is provided. +
- +
-Note both Macro Name and Trigger Value must be URL encoded. +
- +
-You can easily get the Trigger URL by clicking on the "Or by Script" ​Trigger option, and selecting ​"Or by URL"+
- +
-{{:​manual:​km-7.3-macro-trigger-url-setup.png?​nolink|}+
- +
-{{:​manual:​km-7.3-macro-trigger-url-results.png?​nolink|}}+
  
-^ Example Trigger URL Command ^ Description ^ 
-| `kmtrigger://​macro=Your%20Macro%20Name` | Using the Macro Name | 
-| `kmtrigger://​macro=224AA8CB-07EB-4C92-8201-68FED82B6E9F` | Using the Macro UUID | 
-| `kmtrigger://​macro=Your%20Macro%20Name&​value=Your%20Trigger%20Value` | Using Macro Name with Trigger Value | 
-| `kmtrigger://​macro=224AA8CB-07EB-4C92-8201-68FED82B6E9F&​value=Your%20Trigger%20Value` | Using Macro UUID with Trigger Value  | 
  
manual/Scripting.txt · Last modified: 2023/10/04 04:27 by peternlewis