PyObjC Framework Automator

12.1 · active · verified Tue Apr 14

The `pyobjc-framework-automator` library provides Python wrappers for the macOS Automator framework, enabling Python applications to develop Automator actions and run workflows. It is part of the larger PyObjC bridge, which allows Python scripts to use and extend Objective-C class libraries, notably Apple's Cocoa. The current version is 12.1, released on 2025-11-14. PyObjC maintains an active development pace with several major and minor releases per year, often tied to macOS SDK updates and Python version support changes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the `Automator` framework and access its core classes. Running full Automator workflows or developing actions typically requires a complete macOS application context, often built with `py2app`, or a carefully configured console application. This example focuses on verifying framework access.

import Automator
from Foundation import NSURL, NSArray # Foundation is often used with PyObjC frameworks

# This example confirms that core Automator classes are accessible.
# Actual execution of Automator workflows or creating complex actions
# typically involves a full macOS application context (e.g., via py2app)
# and specific workflow files.

print(f"PyObjC Automator framework version: {Automator.__version__}")

try:
    # Check for the presence of key Automator classes
    if hasattr(Automator, 'AMWorkflow'):
        print(f"Automator.AMWorkflow class found: {Automator.AMWorkflow}")

    if hasattr(Automator, 'AMWorkflowController'):
        print(f"Automator.AMWorkflowController class found: {Automator.AMWorkflowController}")

    # Example: Trying to get system-wide Automator actions (conceptual)
    # Note: Requires a running Cocoa event loop in a real application
    # or careful setup for console tools.
    # For a simple check, we just confirm the class exists.
    # AMAction.allActionsWithSearchFor_("PDF") # Requires a real app context.

    print("PyObjC Automator framework classes successfully accessed.")

except Exception as e:
    print(f"An error occurred: {e}")
    print("Ensure you are running on macOS and the pyobjc-framework-automator is installed.")

view raw JSON →