AMAction is an abstract class that defines the interface and general characteristics of Automator actions. Automator is an Apple application that allows users to construct and execute workflows consisting of a sequence of discrete modules called actions. An action performs a specific task, such as copying a file or cropping an image, and passes its output to Automator to give to the next action in the workflow. Actions are currently implemented as loadable bundles owned by objects of the AMBundleAction class, a subclass of AMAction.


class AMAction : NSObject


The critically important method declared by AMAction is run(withInput:). When Automator executes a workflow, it sends this message to each action object in the workflow (in workflow sequence), in most cases passing in the output of the previous action as input. The action object performs its task in this method and ends by returning an output object for the next action in the workflow.

Subclassing Notes

Subclassing AMAction is not recommended. For most situations requiring an enhancement to the Automator framework, it is sufficient to subclass AMBundleAction.


Initialization and encoding

init?(definition: [String : Any]?, fromArchive: Bool)

Initializes the receiver with the specified definition.

init(contentsOf: URL)

Loads an Automator action from a file URL.

func write(to: NSMutableDictionary)

Examines the parameters and other configuration information specified in the passed dictionary and adds its own information to it if appropriate.

Controlling the action

func finishRunningWithError(Error?)

Causes the action to stop running and return an error, which, in turn, causes the workflow to stop.

func reset()

Resets the receiver to its initial state.

func runAsynchronously(withInput: Any?)

Causes Automator to wait for notification that the receiver has completed execution, which allows the receiver to perform an asynchronous operation.

func run(withInput: Any?) -> Any

Requests the receiver to perform its task using the specified input.

func stop()

Stops the receiver from running.

func willFinishRunning()

Invoked by Automator when the receiver has essentially completed its run phase.

Initializing and synchronizing the action user interface

func activated()

Invoked when the window of the Automator workflow to which the receiver belongs becomes the main window. This allows the receiver to synchronize its information with settings in another application.

func opened()

Invoked when the receiver is first added to a workflow, allowing it to initialize its user interface.

Updating action parameters

func parametersUpdated()

Requests the receiver to update its user interface from its stored parameters, which have changed.

func updateParameters()

Requests the receiver to update its stored set of parameters from the settings in the action’s user interface.

Getting Information About the Action

func closed()

Invoked by Automator when the receiving action is removed from a workflow, allowing it to perform cleanup operations.

var ignoresInput: Bool

A Boolean value that indicates whether the action acts upon its input or the input is ignored.

var name: String

The name of the action.

var output: Any?

The action’s output.

var progressValue: CGFloat

A float value between 0 and 1, which indicates how far along the action is while processing.

var selectedInputType: String?

The type of input, in UTI format, of the input received by the action.

var selectedOutputType: String?

The type of output, in UTI format, of the output to be produced by the action.

var isStopped: Bool

Indicates whether the user clicked the stop button on the parent workflow.


Inherits From

Conforms To