User Tools

Site Tools


action:Execute_a_Swift_Script

**This is an old revision of the document!**

Execute Swift Script

The Execute a Swift Script action executes a specified Swift script, either from a file or text.

Using the Results

The results of the script can be:

  • Ignored.
  • Displayed in a floating window.
  • Displayed briefly in a Notification.
  • Typed in to the current selection.
  • Pasted in to the current selection.
  • Saved to a variable.
  • Saved to the system or a Named Clipboard.
  • Asynchronously ignored — the action runs while the macro continues on.

How to Get Keyboard Maestro Variables

Swift scripts can get (but not set) Keyboard Maestro Variables by using environment variables, for example:

Swift 2 (Xcode 7 and 8)

import Foundation
print(NSProcessInfo.processInfo().environment["KMVAR_Variable_Name"]!)

Swift 3 (currently beta, Xcode 8)

import Foundation
print(ProcessInfo.processInfo.environment["KMVAR_Variable_Name"]!)

See Also

Forum Topics

action/Execute_a_Swift_Script.1473791791.txt.gz · Last modified: 2016/09/13 14:36 by JMichaelTX