This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
manual:Scripting [2019/06/20 22:26] peternlewis |
manual:Scripting [2023/09/12 22:43] peternlewis [Controlling Keyboard Maestro Engine via Scripting] |
||
---|---|---|---|
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 132: | Line 132: | ||
</code> | </code> | ||
- | The CODE{{{do script}}} will not return until the macro is finished executing. | + | The CODE{{{do script}}} will not return until the macro is finished executing. The [[action:Return_Result|Return Result]] action can be used to return a result to the AppleScipt. |
You can pass an optional parameter using the CODE{{{with parameter}}} clause, which you can read in the macro as the [[token:TriggerValue|%TriggerValue% token]]. | You can pass an optional parameter using the CODE{{{with parameter}}} clause, which you can read in the macro as the [[token:TriggerValue|%TriggerValue% token]]. | ||
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 212: | Line 222: | ||
See the Keyboard Maestro AppleScript dictionary for more information. | See the Keyboard Maestro AppleScript dictionary for more information. | ||
+ | |||
+ | ===== Controlling Keyboard Maestro Engine via Scripting ===== | ||
+ | |||
+ | You can adjust Keyboard Maestro Engine windows with: | ||
+ | |||
+ | <code applescript> | ||
+ | tell application "Keyboard Maestro Engine" | ||
+ | set bounds of window "Clipboard History Switcher" to {1000, 50, 2000, 1200} | ||
+ | end tell | ||
+ | </code> | ||