1. Introduction
The osax
module provides an easy way to call scripting additions (a.k.a. OSAXen) from Python. It exports a single public class, OSAX
. For convenience, it also re-exports appscript's ApplicationNotFoundError
and CommandError
classes and k
variable.
The OSAX
class represents a single scripting addition. It is similar to an appscript application object, except that it defines commands for the specified scripting addition instead of the application's normal commands.
Once you've created a OSAX
instance, you can invoke its commands in exactly the same way as you would call a scriptable application's commands in appscript.
For example:
import osax
sa = osax.OSAX()
sa.say("Hello world", using="Victoria")
The default application commands (run
, activate
, quit
, etc.) are also available; see the appscript manual for details on those.
By default, OSAX
objects use StandardAdditions terminology and are targeted at the current application. You can specify the name of a different scripting addition via the constructor's osaxname
argument. You can specify another application by supplying one of the following optional keyword arguments: name
, id
, creator
or url
. These arguments are the same as for appscript.