Automator Module Reference

New in version 0.0.4.

Control Automator using JXA-like syntax.

Classes:

XAAutomatorAction(properties)

A class for managing and interacting with actions in Automator.app.

XAAutomatorActionList(properties[, filter])

A wrapper around a list of Automator required resources which utilizes fast enumeration techniques.

XAAutomatorApplication(properties)

A class for managing and interacting with Automator.app.

XAAutomatorDocument(properties)

A class for managing and interacting with Automator windows.

XAAutomatorDocumentList(properties[, filter])

A wrapper around a list of Automator documents which utilizes fast enumeration techniques.

XAAutomatorRequiredResource(properties)

A class for managing and interacting with required resources in Automator.app.

XAAutomatorRequiredResourceList(properties)

A wrapper around a list of Automator required resources which utilizes fast enumeration techniques.

XAAutomatorSetting(properties)

A class for managing and interacting with Automator settings (i.e. named values).

XAAutomatorSettingList(properties[, filter])

A wrapper around a list of Automator settings which utilizes fast enumeration techniques.

XAAutomatorVariable(properties)

A class for managing and interacting with Automator variables.

XAAutomatorVariableList(properties[, filter])

A wrapper around a list of Automator variables which utilizes fast enumeration techniques.

XAAutomatorWindow(properties)

A class for managing and interacting with Automator windows.

XAAutomatorWorkflow(properties)

A class for managing and interacting with Automator workflows.

XAAutomatorWorkflowList(properties[, filter])

A wrapper around a list of Automator workflows which utilizes fast enumeration techniques.

class PyXA.apps.Automator.XAAutomatorAction(properties)[source]

Bases: XAObject

A class for managing and interacting with actions in Automator.app.

New in version 0.0.4.

Attributes:

bundle_id

The bundle identifier for the action.

category

The categories that contain the action

comment

The comment for the name of the action.

enabled

Whether the action is enabled.

execution_error_message

The text error message generated by execution of the action.

execution_error_number

The numeric error code generated by execution of the action.

execution_result

The result of the action, passed as input to the next action.

icon_name

The name for the icon associated with the action.

id

The unique identifier for the action.

ignores_input

Whether the action ignores input when run.

index

The index of the action from the first action in the workflow.

input_types

The input types accepted by the action.

keywords

The keywords that describe the action.

name

The localized name of the action.

output_types

The output types produced by the action.

parent_workflow

The workflow that contains the action.

path

The path of the file that contains the action.

show_action_when_run

Whether the action should show its user interface when run.

target_application

The application(s) with which the action communicates.

version

The version of the action.

warning_action

The action suggested by the warning, if any.

warning_level

The level of the warning, increasing in likelihood of data loss.

warning_message

The message that accompanies the warning, if any.

Methods:

required_resources([filter])

Returns a list of required resource, as PyXA objects, matching the given filter.

settings([filter])

Returns a list of settings, as PyXA objects, matching the given filter.

property bundle_id: str

The bundle identifier for the action.

property category: list[str]

The categories that contain the action

property comment: str

The comment for the name of the action.

property enabled: bool

Whether the action is enabled.

property execution_error_message: str

The text error message generated by execution of the action.

property execution_error_number: int

The numeric error code generated by execution of the action.

property execution_result: Any

The result of the action, passed as input to the next action.

property icon_name: str

The name for the icon associated with the action.

property id: str

The unique identifier for the action.

property ignores_input: bool

Whether the action ignores input when run.

property index: int

The index of the action from the first action in the workflow.

property input_types: list[str]

The input types accepted by the action.

property keywords: list[str]

The keywords that describe the action.

property name: str

The localized name of the action.

property output_types: list[str]

The output types produced by the action.

property parent_workflow: XAAutomatorWorkflow

The workflow that contains the action.

property path: XAPath

The path of the file that contains the action.

required_resources(filter: dict | None = None) XAAutomatorRequiredResourceList[source]

Returns a list of required resource, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter resources by, defaults to None

Returns:

A PyXA list object wrapping a list of required resources

Return type:

XAAutomatorVariableList

New in version 0.0.4.

settings(filter: dict | None = None) XAAutomatorSettingList[source]

Returns a list of settings, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter settings by, defaults to None

Returns:

A PyXA list object wrapping a list of settings

Return type:

XAAutomatorWorkflowList

New in version 0.0.4.

property show_action_when_run: bool

Whether the action should show its user interface when run.

property target_application: list[str]

The application(s) with which the action communicates.

property version: str

The version of the action.

property warning_action: str

The action suggested by the warning, if any.

property warning_level: WarningLevel

The level of the warning, increasing in likelihood of data loss.

property warning_message: str

The message that accompanies the warning, if any.

class PyXA.apps.Automator.XAAutomatorActionList(properties: dict, filter: dict | None = None)[source]

Bases: XAList

A wrapper around a list of Automator required resources which utilizes fast enumeration techniques.

All properties of required resources can be called as methods on the wrapped list, returning a list containing each resource’s value for the property.

New in version 0.0.4.

Methods:

bundle_id()

by_bundle_id(bundle_id)

by_category(category)

by_comment(comment)

by_enabled(enabled)

by_execution_error_message(...)

by_execution_error_number(execution_error_number)

by_execution_result(execution_result)

by_icon_name(icon_name)

by_id(id)

by_ignores_input(ignores_input)

by_input_types(input_types)

by_keywords(keywords)

by_name(name)

by_output_types(output_types)

by_parent_workflow(parent_workflow)

by_path(path)

by_show_action_when_run(show_action_when_run)

by_target_application(target_application)

by_version(version)

by_warning_action(warning_action)

by_warning_level(warning_level)

by_warning_message(warning_message)

category()

comment()

enabled()

execution_error_message()

execution_error_number()

execution_result()

icon_name()

ignores_input()

index()

Returns the index of the first occurrence of the element in the list, or -1 if no such element exists in the list.

input_types()

keywords()

name()

output_types()

parent_workflow()

path()

show_action_when_run()

target_application()

version()

warning_action()

warning_level()

warning_message()

bundle_id() list[str][source]
by_bundle_id(bundle_id: str) XAAutomatorAction | None[source]
by_category(category: list[str]) XAAutomatorAction | None[source]
by_comment(comment: str) XAAutomatorAction | None[source]
by_enabled(enabled: bool) XAAutomatorAction | None[source]
by_execution_error_message(execution_error_message: str) XAAutomatorAction | None[source]
by_execution_error_number(execution_error_number: int) XAAutomatorAction | None[source]
by_execution_result(execution_result: Any) XAAutomatorAction | None[source]
by_icon_name(icon_name: str) XAAutomatorAction | None[source]
by_id(id: str) XAAutomatorAction | None[source]
by_ignores_input(ignores_input: bool) XAAutomatorAction | None[source]
by_input_types(input_types: list[str]) XAAutomatorAction | None[source]
by_keywords(keywords: list[str]) XAAutomatorAction | None[source]
by_name(name: str) XAAutomatorAction | None[source]
by_output_types(output_types: list[str]) XAAutomatorAction | None[source]
by_parent_workflow(parent_workflow: XAAutomatorWorkflow) XAAutomatorAction | None[source]
by_path(path: str) XAAutomatorAction | None[source]
by_show_action_when_run(show_action_when_run: bool) XAAutomatorAction | None[source]
by_target_application(target_application: list[str]) XAAutomatorAction | None[source]
by_version(version: str) XAAutomatorAction | None[source]
by_warning_action(warning_action: str) XAAutomatorAction | None[source]
by_warning_level(warning_level: WarningLevel) XAAutomatorAction | None[source]
by_warning_message(warning_message: str) XAAutomatorAction | None[source]
category() list[list[str]][source]
comment() list[str][source]
enabled() list[bool][source]
execution_error_message() list[str][source]
execution_error_number() list[int][source]
execution_result() list[Any][source]
icon_name() list[str][source]
ignores_input() list[bool][source]
index() list[int][source]

Returns the index of the first occurrence of the element in the list, or -1 if no such element exists in the list.

New in version 0.1.2.

input_types() list[list[str]][source]
keywords() list[list[str]][source]
name() list[str][source]
output_types() list[list[str]][source]
parent_workflow() XAAutomatorWorkflowList[source]
path() list[str][source]
show_action_when_run() list[bool][source]
target_application() list[list[str]][source]
version() list[str][source]
warning_action() list[str][source]
warning_level() list[WarningLevel][source]
warning_message() list[str][source]
class PyXA.apps.Automator.XAAutomatorApplication(properties)[source]

Bases: XASBApplication, XACanOpenPath

A class for managing and interacting with Automator.app.

New in version 0.0.4.

Classes:

ObjectType(value)

The object types available for creation in Automator.

WarningLevel(value)

Options for warning level in regard to likelihood of data loss.

Methods:

add(action, workflow[, index])

Adds the specified action to a workflow at the specified index.

automator_actions([filter])

Returns a list of Automator actions, as PyXA objects, matching the given filter.

documents([filter])

Returns a list of documents, as PyXA objects, matching the given filter.

make(specifier, properties, data)

Creates a new element of the given specifier class without adding it to any list.

open(path)

Opens the file at the given filepath.

variables([filter])

Returns a list of Automator variables, as PyXA objects, matching the given filter.

workflows([filter])

Returns a list of Automator workflows, as PyXA objects, matching the given filter.

Attributes:

frontmost

Whether Automator is the active application.

name

The name of the application.

version

The version of Automator.app.

class ObjectType(value)[source]

Bases: Enum

The object types available for creation in Automator.

New in version 0.3.0.

Attributes:

ACTION

DOCUMENT

REQUIRED_RESOURCE

SETTING

VARIABLE

ACTION = 'action'
DOCUMENT = 'document'
REQUIRED_RESOURCE = 'required_resource'
SETTING = 'setting'
VARIABLE = 'variable'
class WarningLevel(value)[source]

Bases: Enum

Options for warning level in regard to likelihood of data loss.

Attributes:

IRREVERSIBLE

NONE

REVERSIBLE

IRREVERSIBLE = 1769108086
NONE = 1852796517
REVERSIBLE = 1920361068
add(action: XAAutomatorAction, workflow: XAAutomatorWorkflow, index: int = -1) XAAutomatorApplication[source]

Adds the specified action to a workflow at the specified index.

Parameters:
  • action (XAAutomatorAction) – The action to add

  • workflow (XAAutomatorWorkflow) – The workflow to add the action to

  • index (int, optional) – The index at which to add the action, defaults to -1

Returns:

A reference to the application object

Return type:

XAAutomatorApplication

New in version 0.0.4.

automator_actions(filter: dict | None = None) XAAutomatorActionList[source]

Returns a list of Automator actions, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter actions by, defaults to None

Returns:

A PyXA list object wrapping a list of actions

Return type:

XAAutomatorActionList

New in version 0.0.4.

documents(filter: dict | None = None) XAAutomatorDocumentList[source]

Returns a list of documents, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter documents by, defaults to None

Returns:

A PyXA list object wrapping a list of documents

Return type:

XAAutomatorDocumentList

New in version 0.0.4.

property frontmost: bool

Whether Automator is the active application.

make(specifier: str | ObjectType, properties: dict, data: Any)[source]

Creates a new element of the given specifier class without adding it to any list.

Use XABase.XAList.push() to push the element onto a list.

Parameters:
  • specifier (Union[str, XAAutomatorApplication.ObjectType]) – The classname of the object to create

  • properties (dict) – The properties to give the object

  • data (Any) – The data to give the object

Returns:

A PyXA wrapped form of the object

Return type:

XABase.XAObject

New in version 0.0.4.

property name: str

The name of the application.

open(path: str | NSURL) XAAutomatorWorkflow[source]

Opens the file at the given filepath.

Parameters:

target (Union[str, AppKit.NSURL]) – The path to a file or the URL to a website to open.

Returns:

A reference to the PyXA object that called this method.

Return type:

XAObject

New in version 0.0.1.

variables(filter: dict | None = None) XAAutomatorVariableList[source]

Returns a list of Automator variables, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter variables by, defaults to None

Returns:

A PyXA list object wrapping a list of variables

Return type:

XAAutomatorVariableList

New in version 0.0.4.

property version: str

The version of Automator.app.

workflows(filter: dict | None = None) XAAutomatorWorkflowList[source]

Returns a list of Automator workflows, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter workflows by, defaults to None

Returns:

A PyXA list object wrapping a list of workflows

Return type:

XAAutomatorWorkflowList

New in version 0.0.4.

class PyXA.apps.Automator.XAAutomatorDocument(properties)[source]

Bases: XAObject

A class for managing and interacting with Automator windows.

New in version 0.0.4.

Attributes:

modified

Whether the document has been modified since its last save.

name

The title of the document.

path

The path to the document on the disk.

property modified: bool

Whether the document has been modified since its last save.

property name: str

The title of the document.

property path: XAPath

The path to the document on the disk.

class PyXA.apps.Automator.XAAutomatorDocumentList(properties: dict, filter: dict | None = None)[source]

Bases: XAList

A wrapper around a list of Automator documents which utilizes fast enumeration techniques.

All properties of documents can be called as methods on the wrapped list, returning a list containing each document’s value for the property.

New in version 0.0.4.

Methods:

by_id(id)

by_index(index)

by_title(title)

id()

index()

Returns the index of the first occurrence of the element in the list, or -1 if no such element exists in the list.

title()

by_id(id: int) XAAutomatorDocument | None[source]
by_index(index: int) XAAutomatorDocument | None[source]
by_title(title: str) XAAutomatorDocument | None[source]
id() list[int][source]
index() list[int][source]

Returns the index of the first occurrence of the element in the list, or -1 if no such element exists in the list.

New in version 0.1.2.

title() list[str][source]
class PyXA.apps.Automator.XAAutomatorRequiredResource(properties)[source]

Bases: XAObject

A class for managing and interacting with required resources in Automator.app.

New in version 0.0.4.

Attributes:

kind

The kind of required resource.

name

The name of the required resource.

resource

The specification of the required resource.

version

The minimum acceptable version of the required resource.

property kind: str

The kind of required resource.

property name: str

The name of the required resource.

property resource: str

The specification of the required resource.

property version: int

The minimum acceptable version of the required resource.

class PyXA.apps.Automator.XAAutomatorRequiredResourceList(properties: dict, filter: dict | None = None)[source]

Bases: XAList

A wrapper around a list of Automator required resources which utilizes fast enumeration techniques.

All properties of required resources can be called as methods on the wrapped list, returning a list containing each resource’s value for the property.

New in version 0.0.4.

Methods:

by_kind(kind)

by_name(name)

by_resource(resource)

by_version(version)

kind()

name()

resource()

version()

by_kind(kind: str) XAAutomatorRequiredResource | None[source]
by_name(name: str) XAAutomatorRequiredResource | None[source]
by_resource(resource: str) XAAutomatorRequiredResource | None[source]
by_version(version: int) XAAutomatorRequiredResource | None[source]
kind() list[str][source]
name() list[str][source]
resource() list[str][source]
version() list[int][source]
class PyXA.apps.Automator.XAAutomatorSetting(properties)[source]

Bases: XAObject

A class for managing and interacting with Automator settings (i.e. named values).

New in version 0.0.4.

Attributes:

default_value

The default value of the setting.

name

The name of the setting.

value

The value of the setting.

property default_value: Any

The default value of the setting.

property name: str

The name of the setting.

property value: Any

The value of the setting.

class PyXA.apps.Automator.XAAutomatorSettingList(properties: dict, filter: dict | None = None)[source]

Bases: XAList

A wrapper around a list of Automator settings which utilizes fast enumeration techniques.

All properties of settings can be called as methods on the wrapped list, returning a list containing each setting’s value for the property.

New in version 0.0.4.

Methods:

by_default_value(default_value)

by_name(name)

by_value(value)

default_value()

name()

value()

by_default_value(default_value: Any) XAAutomatorSetting | None[source]
by_name(name: str) XAAutomatorSetting | None[source]
by_value(value: Any) XAAutomatorSetting | None[source]
default_value() list[Any][source]
name() list[str][source]
value() list[Any][source]
class PyXA.apps.Automator.XAAutomatorVariable(properties)[source]

Bases: XAObject

A class for managing and interacting with Automator variables.

New in version 0.0.4.

Attributes:

name

The name of the variable.

settable

Whether the name and value of the variable can be changed.

value

The value of the variable.

property name: str

The name of the variable.

property settable: bool

Whether the name and value of the variable can be changed.

property value: Any

The value of the variable.

class PyXA.apps.Automator.XAAutomatorVariableList(properties: dict, filter: dict | None = None)[source]

Bases: XAList

A wrapper around a list of Automator variables which utilizes fast enumeration techniques.

All properties of variables can be called as methods on the wrapped list, returning a list containing each variable’s value for the property.

New in version 0.0.4.

Methods:

by_name(name)

by_settable(settable)

by_value(value)

name()

settable()

value()

by_name(name: str) XAAutomatorVariable | None[source]
by_settable(settable: bool) XAAutomatorVariable | None[source]
by_value(value: Any) XAAutomatorVariable | None[source]
name() list[str][source]
settable() list[bool][source]
value() list[Any][source]
class PyXA.apps.Automator.XAAutomatorWindow(properties)[source]

Bases: XASBWindow

A class for managing and interacting with Automator windows.

New in version 0.0.4.

Attributes:

document

The document currently displayed in the window.

floating

Whether the window floats.

modal

Whether the window is a modal window.

titled

Whether the window has a title bar.

property document: XAAutomatorDocument

The document currently displayed in the window.

property floating: bool

Whether the window floats.

property modal: bool

Whether the window is a modal window.

property titled: bool

Whether the window has a title bar.

class PyXA.apps.Automator.XAAutomatorWorkflow(properties)[source]

Bases: XAAutomatorDocument

A class for managing and interacting with Automator workflows.

New in version 0.0.4.

Methods:

automator_actions([filter])

Returns a list of actions, as PyXA objects, matching the given filter.

delete()

Closes the workflow.

execute()

Executes the workflow.

save()

Saves the workflow to the disk at the location specified by XAAutomatorWorkflow.path, or in the downloads folder if no path has been specified.

variables([filter])

Returns a list of variables, as PyXA objects, matching the given filter.

Attributes:

current_action

The current or most recent action of the workflow.

execution_error_message

The text error message generated by the most recent execution.

execution_error_number

The numeric error code generated by the most recent execution.

execution_id

The unique identifier for the current or most recent execution.

execution_result

The result of the most resent execution.

name

The name of the workflow.

automator_actions(filter: dict | None = None) XAAutomatorActionList[source]

Returns a list of actions, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter actions by, defaults to None

Returns:

A PyXA list object wrapping a list of actions

Return type:

XAAutomatorActionList

New in version 0.0.4.

property current_action: XAAutomatorAction

The current or most recent action of the workflow.

delete()[source]

Closes the workflow.

New in version 0.0.4.

execute() Any[source]

Executes the workflow.

Returns:

The return value of the workflow after execution

Return type:

Any

New in version 0.0.5.

property execution_error_message: str

The text error message generated by the most recent execution.

property execution_error_number: int

The numeric error code generated by the most recent execution.

property execution_id: str

The unique identifier for the current or most recent execution.

property execution_result: Any

The result of the most resent execution.

property name: str

The name of the workflow.

save() XAAutomatorWorkflow[source]

Saves the workflow to the disk at the location specified by XAAutomatorWorkflow.path, or in the downloads folder if no path has been specified.

Returns:

The workflow object.

Return type:

XAAutomatorWorkflow

New in version 0.0.5.

variables(filter: dict | None = None) XAAutomatorVariableList[source]

Returns a list of variables, as PyXA objects, matching the given filter.

Parameters:

filter (dict, optional) – Keys and values to filter variables by, defaults to None

Returns:

A PyXA list object wrapping a list of variables

Return type:

XAAutomatorVariableList

New in version 0.0.4.

class PyXA.apps.Automator.XAAutomatorWorkflowList(properties: dict, filter: dict | None = None)[source]

Bases: XAList

A wrapper around a list of Automator workflows which utilizes fast enumeration techniques.

All properties of workflows can be called as methods on the wrapped list, returning a list containing each workflow’s value for the property.

New in version 0.0.4.

Methods:

by_current_action(current_action)

by_execution_error_message(...)

by_execution_error_number(execution_error_number)

by_execution_id(execution_id)

by_execution_result(result)

by_name(name)

current_action()

execution_error_message()

execution_error_number()

execution_id()

execution_result()

name()

by_current_action(current_action: XAAutomatorAction) XAAutomatorWorkflow | None[source]
by_execution_error_message(execution_error_message: str) XAAutomatorWorkflow | None[source]
by_execution_error_number(execution_error_number: int) XAAutomatorWorkflow | None[source]
by_execution_id(execution_id: str) XAAutomatorWorkflow | None[source]
by_execution_result(result: Any) XAAutomatorWorkflow | None[source]
by_name(name: str) XAAutomatorWorkflow | None[source]
current_action() XAAutomatorActionList[source]
execution_error_message() list[str][source]
execution_error_number() list[int][source]
execution_id() list[str][source]
execution_result() list[Any][source]
name() list[str][source]