Server : Apache System : Linux server1.cgrithy.com 3.10.0-1160.95.1.el7.x86_64 #1 SMP Mon Jul 24 13:59:37 UTC 2023 x86_64 User : nobody ( 99) PHP Version : 8.1.23 Disable Function : NONE Directory : /usr/share/doc/python-docs-2.7.5/html/library/ |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>37.2. aetools — OSA client support — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="37. MacPython OSA Modules" href="macosa.html" /> <link rel="next" title="37.3. aepack — Conversion between Python variables and AppleEvent data containers" href="aepack.html" /> <link rel="prev" title="37.1. gensuitemodule — Generate OSA stub packages" href="gensuitemodule.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="aepack.html" title="37.3. aepack — Conversion between Python variables and AppleEvent data containers" accesskey="N">next</a> |</li> <li class="right" > <a href="gensuitemodule.html" title="37.1. gensuitemodule — Generate OSA stub packages" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="macosa.html" accesskey="U">37. MacPython OSA Modules</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-aetools"> <span id="aetools-osa-client-support"></span><h1>37.2. <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><tt class="xref py py-mod docutils literal"><span class="pre">aetools</span></tt></a> — OSA client support<a class="headerlink" href="#module-aetools" title="Permalink to this headline">¶</a></h1> <p>The <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><tt class="xref py py-mod docutils literal"><span class="pre">aetools</span></tt></a> module contains the basic functionality on which Python AppleScript client support is built. It also imports and re-exports the core functionality of the <a class="reference internal" href="aetypes.html#module-aetypes" title="aetypes: Python representation of the Apple Event Object Model. (deprecated) (Mac)"><tt class="xref py py-mod docutils literal"><span class="pre">aetypes</span></tt></a> and <a class="reference internal" href="aepack.html#module-aepack" title="aepack: Conversion between Python variables and AppleEvent data containers. (deprecated) (Mac)"><tt class="xref py py-mod docutils literal"><span class="pre">aepack</span></tt></a> modules. The stub packages generated by <a class="reference internal" href="gensuitemodule.html#module-gensuitemodule" title="gensuitemodule: Create a stub package from an OSA dictionary (Mac)"><tt class="xref py py-mod docutils literal"><span class="pre">gensuitemodule</span></tt></a> import the relevant portions of <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><tt class="xref py py-mod docutils literal"><span class="pre">aetools</span></tt></a>, so usually you do not need to import it yourself. The exception to this is when you cannot use a generated suite package and need lower-level access to scripting.</p> <p>The <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><tt class="xref py py-mod docutils literal"><span class="pre">aetools</span></tt></a> module itself uses the AppleEvent support provided by the <a class="reference internal" href="carbon.html#module-Carbon.AE" title="Carbon.AE: Interface to the Apple Events toolbox. (deprecated) (Mac)"><tt class="xref py py-mod docutils literal"><span class="pre">Carbon.AE</span></tt></a> module. This has one drawback: you need access to the window manager, see section <a class="reference internal" href="../using/mac.html#osx-gui-scripts"><em>Running scripts with a GUI</em></a> for details. This restriction may be lifted in future releases.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">This module has been removed in Python 3.x.</p> </div> <p>The <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><tt class="xref py py-mod docutils literal"><span class="pre">aetools</span></tt></a> module defines the following functions:</p> <dl class="function"> <dt id="aetools.packevent"> <tt class="descclassname">aetools.</tt><tt class="descname">packevent</tt><big>(</big><em>ae</em>, <em>parameters</em>, <em>attributes</em><big>)</big><a class="headerlink" href="#aetools.packevent" title="Permalink to this definition">¶</a></dt> <dd><p>Stores parameters and attributes in a pre-created <tt class="docutils literal"><span class="pre">Carbon.AE.AEDesc</span></tt> object. <tt class="docutils literal"><span class="pre">parameters</span></tt> and <tt class="docutils literal"><span class="pre">attributes</span></tt> are dictionaries mapping 4-character OSA parameter keys to Python objects. The objects are packed using <tt class="docutils literal"><span class="pre">aepack.pack()</span></tt>.</p> </dd></dl> <dl class="function"> <dt id="aetools.unpackevent"> <tt class="descclassname">aetools.</tt><tt class="descname">unpackevent</tt><big>(</big><em>ae</em><span class="optional">[</span>, <em>formodulename</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#aetools.unpackevent" title="Permalink to this definition">¶</a></dt> <dd><p>Recursively unpacks a <tt class="docutils literal"><span class="pre">Carbon.AE.AEDesc</span></tt> event to Python objects. The function returns the parameter dictionary and the attribute dictionary. The <tt class="docutils literal"><span class="pre">formodulename</span></tt> argument is used by generated stub packages to control where AppleScript classes are looked up.</p> </dd></dl> <dl class="function"> <dt id="aetools.keysubst"> <tt class="descclassname">aetools.</tt><tt class="descname">keysubst</tt><big>(</big><em>arguments</em>, <em>keydict</em><big>)</big><a class="headerlink" href="#aetools.keysubst" title="Permalink to this definition">¶</a></dt> <dd><p>Converts a Python keyword argument dictionary <tt class="docutils literal"><span class="pre">arguments</span></tt> to the format required by <tt class="docutils literal"><span class="pre">packevent</span></tt> by replacing the keys, which are Python identifiers, by the four-character OSA keys according to the mapping specified in <tt class="docutils literal"><span class="pre">keydict</span></tt>. Used by the generated suite packages.</p> </dd></dl> <dl class="function"> <dt id="aetools.enumsubst"> <tt class="descclassname">aetools.</tt><tt class="descname">enumsubst</tt><big>(</big><em>arguments</em>, <em>key</em>, <em>edict</em><big>)</big><a class="headerlink" href="#aetools.enumsubst" title="Permalink to this definition">¶</a></dt> <dd><p>If the <tt class="docutils literal"><span class="pre">arguments</span></tt> dictionary contains an entry for <tt class="docutils literal"><span class="pre">key</span></tt> convert the value for that entry according to dictionary <tt class="docutils literal"><span class="pre">edict</span></tt>. This converts human-readable Python enumeration names to the OSA 4-character codes. Used by the generated suite packages.</p> </dd></dl> <p>The <a class="reference internal" href="#module-aetools" title="aetools: Basic support for sending Apple Events (deprecated) (Mac)"><tt class="xref py py-mod docutils literal"><span class="pre">aetools</span></tt></a> module defines the following class:</p> <dl class="class"> <dt id="aetools.TalkTo"> <em class="property">class </em><tt class="descclassname">aetools.</tt><tt class="descname">TalkTo</tt><big>(</big><span class="optional">[</span><em>signature=None</em>, <em>start=0</em>, <em>timeout=0</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#aetools.TalkTo" title="Permalink to this definition">¶</a></dt> <dd><p>Base class for the proxy used to talk to an application. <tt class="docutils literal"><span class="pre">signature</span></tt> overrides the class attribute <tt class="docutils literal"><span class="pre">_signature</span></tt> (which is usually set by subclasses) and is the 4-char creator code defining the application to talk to. <tt class="docutils literal"><span class="pre">start</span></tt> can be set to true to enable running the application on class instantiation. <tt class="docutils literal"><span class="pre">timeout</span></tt> can be specified to change the default timeout used while waiting for an AppleEvent reply.</p> </dd></dl> <dl class="method"> <dt id="aetools.TalkTo._start"> <tt class="descclassname">TalkTo.</tt><tt class="descname">_start</tt><big>(</big><big>)</big><a class="headerlink" href="#aetools.TalkTo._start" title="Permalink to this definition">¶</a></dt> <dd><p>Test whether the application is running, and attempt to start it if not.</p> </dd></dl> <dl class="method"> <dt id="aetools.TalkTo.send"> <tt class="descclassname">TalkTo.</tt><tt class="descname">send</tt><big>(</big><em>code</em>, <em>subcode</em><span class="optional">[</span>, <em>parameters</em>, <em>attributes</em><span class="optional">]</span><big>)</big><a class="headerlink" href="#aetools.TalkTo.send" title="Permalink to this definition">¶</a></dt> <dd><p>Create the AppleEvent <tt class="docutils literal"><span class="pre">Carbon.AE.AEDesc</span></tt> for the verb with the OSA designation <tt class="docutils literal"><span class="pre">code,</span> <span class="pre">subcode</span></tt> (which are the usual 4-character strings), pack the <tt class="docutils literal"><span class="pre">parameters</span></tt> and <tt class="docutils literal"><span class="pre">attributes</span></tt> into it, send it to the target application, wait for the reply, unpack the reply with <tt class="docutils literal"><span class="pre">unpackevent</span></tt> and return the reply appleevent, the unpacked return values as a dictionary and the return attributes.</p> </dd></dl> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h4>Previous topic</h4> <p class="topless"><a href="gensuitemodule.html" title="previous chapter">37.1. <tt class="docutils literal"><span class="pre">gensuitemodule</span></tt> — Generate OSA stub packages</a></p> <h4>Next topic</h4> <p class="topless"><a href="aepack.html" title="next chapter">37.3. <tt class="docutils literal"><span class="pre">aepack</span></tt> — Conversion between Python variables and AppleEvent data containers</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/aetools.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="aepack.html" title="37.3. aepack — Conversion between Python variables and AppleEvent data containers" >next</a> |</li> <li class="right" > <a href="gensuitemodule.html" title="37.1. gensuitemodule — Generate OSA stub packages" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="macosa.html" >37. MacPython OSA Modules</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2020, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Oct 13, 2020. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>