DAGDA SEARCH | Back to results | Support

MacPython / Appscript Module - Python Wiki

Source: https://wiki.python.org/python/platforms/MacPython/AppscriptModule.html

  1. Python Wiki /
  2. Python Wiki /
  3. Platform-Specific /
  4. MacPython /
  5. MacPython / Appscript Module
View as Markdown

MacPython / Appscript Module

Legacy Wiki Page

This page was migrated from the old MoinMoin-based wiki. Information may be outdated or no longer applicable. For current documentation, see python.org.

What is Appscript?

Appscript is a high-level, user-friendly MacPython-to-Apple Event Manager bridge that allows you to control scriptable Mac OS X applications using ordinary Python scripts. Appscript makes MacPython a serious alternative to Apple’s own ../AppleScript language for automating your Mac.

For example, to get the value of the first paragraph of the topmost document in ../TextEdit:

app('TextEdit').documents[1].paragraphs[1].get()

This is equivalent to the /AppleScript statement:

get paragraph 1 of document 1 of application "TextEdit"

Appscript builds upon lower-level Python packages (aem, osaterminology) to provide:

  1. an Apple event-based RPC mechanism for sending commands to applications

  2. a mechanism for converting data between common Python and Apple event types

  3. a simple embedded query language for constructing references to an application’s object model

  4. a mechanism that uses application-defined terminology to present these references in human-readable form

  5. an integrated help system for exploring application terminology information

  6. a clean, object oriented-like syntax for ease of use.

See:

Application scripting notes

Pages containing additional information on scripting individual applications:

PreviousMacPython / Application Interfaces Next MacPython / Authorization