blob: 463755bf816e10b176a18f808cd7cbf0e8970d77 [file] [log] [blame]
Jack Jansenbae5c962003-04-11 15:35:28 +00001\section{\module{aetools} ---
2 OSA client support}
3
4\declaremodule{standard}{aetools}
5 \platform{Mac}
6%\moduleauthor{Jack Jansen?}{email}
7\modulesynopsis{Basic support for sending Apple Events}
8\sectionauthor{Jack Jansen}{Jack.Jansen@cwi.nl}
9
10
11The \module{aetools} module contains the basic functionality
12on which Python AppleScript client support is built. It also
13imports and re-exports the core functionality of the
14\module{aetypes} and \module{aepack} modules. The stub packages
15generated by \module{gensuitemodule} import the relevant
16portions of \module{aetools}, so usually you do not need to
17import it yourself. The exception to this is when you
18cannot use a generated suite package and need lower-level
19access to scripting.
20
21The \module{aetools} module itself uses the AppleEvent support
22provided by the \module{Carbon.AE} module. This has one drawback:
23you need access to the window manager, see section \ref{osx-gui-scripts}
24for details. This restriction may be lifted in future releases.
25
26
27The \module{aetools} module defines the following functions:
28
29\begin{funcdesc}{packevent}{ae, parameters, attributes}
30Stores parameters and attributes in a pre-created \code{Carbon.AE.AEDesc}
31object. \code{parameters} and \code{attributes} are
32dictionaries mapping 4-character OSA parameter keys to Python objects. The
33objects are packed using \code{aepack.pack()}.
34\end{funcdesc}
35
36\begin{funcdesc}{unpackevent}{ae\optional{, formodulename}}
37Recursively unpacks a \code{Carbon.AE.AEDesc} event to Python objects.
38The function returns the parameter dictionary and the attribute dictionary.
39The \code{formodulename} argument is used by generated stub packages to
40control where AppleScript classes are looked up.
41\end{funcdesc}
42
43\begin{funcdesc}{keysubst}{arguments, keydict}
44Converts a Python keyword argument dictionary \code{arguments} to
45the format required by \code{packevent} by replacing the keys,
46which are Python identifiers, by the four-character OSA keys according
47to the mapping specified in \code{keydict}. Used by the generated suite
48packages.
49\end{funcdesc}
50
51\begin{funcdesc}{enumsubst}{arguments, key, edict}
52If the \code{arguments} dictionary contains an entry for \code{key}
53convert the value for that entry according to dictionary \code{edict}.
54This converts human-readable Python enumeration names to the OSA 4-character
55codes.
56Used by the generated suite
57packages.
58\end{funcdesc}
59
60The \module{aetools} module defines the following class:
61
62\begin{classdesc}{TalkTo}{\optional{signature=None, start=0, timeout=0}}
63
64Base class for the proxy used to talk to an application. \code{signature}
65overrides the class attribute \code{_signature} (which is usually set by subclasses)
66and is the 4-char creator code defining the application to talk to.
67\code{start} can be set to true to enable running the application on
68class instantiation. \code{timeout} can be specified to change the
69default timeout used while waiting for an AppleEvent reply.
70\end{classdesc}
71
72\begin{methoddesc}{_start}{}
73Test whether the application is running, and attempt to start it if not.
74\end{methoddesc}
75
76\begin{methoddesc}{send}{code, subcode\optional{, parameters, attributes}}
77Create the AppleEvent \code{Carbon.AE.AEDesc} for the verb with
78the OSA designation \code{code, subcode} (which are the usual 4-character
79strings), pack the \code{parameters} and \code{attributes} into it, send it
80to the target application, wait for the reply, unpack the reply with
81\code{unpackevent} and return the reply appleevent, the unpacked return values
82as a dictionary and the return attributes.
83\end{methoddesc}