User Tools

Site Tools


action:Execute_an_AppleScript

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
action:Execute_an_AppleScript [2021/07/21 17:58]
JMichaelTX ADD section on error handling
action:Execute_an_AppleScript [2023/09/12 04:24]
peternlewis
Line 11: Line 11:
 **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 immediately 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 immediately continues on to the next //​Action//​.) |
  
Line 23: Line 23:
  
 {{:​action:​execute-applescript-example-km8.png?​nolink|}} {{:​action:​execute-applescript-example-km8.png?​nolink|}}
 +
 +When editing the script, you can press <​key>​Enter</​key>​ to compile and format the script, and you can press <​key>​Option-Return</​key>​ (v11.0+) to insert a line break (“¬”) character.
  
 If the script fails, the action will fail (v9.0+), potentially aborting the macro. If the script fails, the action will fail (v9.0+), potentially aborting the macro.
Line 89: Line 91:
 Here is an example of such an Action/​Macro to handle errors: ​ [[KM] Script Error Handler [Sub-Macro] ](https://​forum.keyboardmaestro.com/​t/​km-script-error-handler-sub-macro/​4641). Here is an example of such an Action/​Macro to handle errors: ​ [[KM] Script Error Handler [Sub-Macro] ](https://​forum.keyboardmaestro.com/​t/​km-script-error-handler-sub-macro/​4641).
  
-  ​ +===== See Also ===== 
-  + 
 +=== Actions === 
 + 
 +* [[action:​Execute_a_Shell_Script|Execute a Shell Script]] 
 +* [[action:​Execute an Automator Workflow|Execute an Automator Workflow]] 
 +* [[action:​Execute a JavaScript For Automation|Execute a JavaScript For Automation]] 
 +* [[action:​Filter|Filter Variable with Expand Tilde In Path]] 
 +* [[:​Actions|See all Actions]] 
 + 
  
action/Execute_an_AppleScript.txt · Last modified: 2023/09/12 23:04 by peternlewis