PyObjC AppleScriptObjC Framework

12.1 · active · verified Tue Apr 14

pyobjc-framework-applescriptobjc provides Python wrappers for the AppleScriptObjC framework on macOS. It enables Python applications and scripts to interact with and extend AppleScript-based application bundles. The current version is 12.1, and releases typically align with new macOS SDKs and Python version support, ensuring compatibility with the latest Apple technologies.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to programmatically attempt to load the AppleScriptObjC framework's bundle using `Foundation.NSBundle`. Due to its specialized nature for extending AppleScript application bundles, a simple, general-purpose functional example is not straightforward without a full application context.

import objc
from Foundation import NSBundle

# The AppleScriptObjC framework is primarily used within AppleScript-based
# application bundles to extend their functionality.
# A direct functional example outside this context is complex.
# This snippet demonstrates how to check if the framework can be loaded.

try:
    # Attempt to get the NSBundle for the AppleScriptObjC framework
    bundle = NSBundle.bundleWithPath_(
        "/System/Library/Frameworks/AppleScriptObjC.framework"
    )

    if bundle and bundle.load():
        print("AppleScriptObjC framework loaded successfully.")
        # At this point, classes and functions from the framework would be available
        # through 'AppleScriptObjC' or through runtime introspection, e.g.,
        # AppleScriptObjC.ASOCScript or similar if defined.
    else:
        print("Failed to load AppleScriptObjC framework or it's not present.")
except Exception as e:
    print(f"An error occurred: {e}")

view raw JSON →