美文网首页
六、AppleScript 词典

六、AppleScript 词典

作者: 加盐白咖啡 | 来源:发表于2020-04-02 23:00 被阅读0次

有一个很好的查看和编写.sdef的工具,叫做Sdef Editor ,开源的,可以点击这里下载。

如果想要知道调用的应用程序支持哪些对应的操作,需要我们打开AppleScript词典来看一下
打开脚本编辑器,文件 > 打开词典,选择想要查看的app。
我们以Xcode为例,打开后是一个Xcode.sdef文件,如图所示

image.png

我们也可以在xcode里找到对应的文件


image.png

可以看到.sdef文件是一个xml格式的文件,

  • Suites

xml的字典可能包含一个或多个 suite 套件.
一个 suite 必须包含 name 和 code(由四个字符组成,指定该 suite) 这两个属性,支持可选属性如 description 属性.
例:

<suite name="Xcode Application Suite" code="pbas" description="This suite contains application-level classes and commands.">
  • The Classes

一个 suite 可能包含一个或多个 class 元素。
一个 class 必须包含 name 和 code(由四个字符组成,指定该 class ) 两个属性。支持可选属性。
例:

<class name="file document" code="fild" description="A document that represents a file on disk. It also provides access to the window it appears in." inherits="document" plural="file documents">
        <cocoa class="NSDocument" />
    </class>
  • The commands

一个 suite 可能包含一个或多个 command 元素
一个 command 必须包含 name 和 code(由八个字符组成,前四个可能是 suite 或者 class 的 code,猜测哈) 两个属性。支持可选属性。
一个 command 可能包含 一个 direct-parameter(直接参数) 、一个 result(结果) 、一个 parameter(可选参数) 元素,
这些元素必须 有一个 type 属性,有必要时也可以加上对 type 进行说明的 description属性。type 必须有值,并且要么是AppleScript的基本类型,要么是已经定义的类。
parameter 元素必须有两个属性 name 和 code(由四个字符组成作为该 parameter 的id)。
例:

<command name="count" code="corecnte" description="Return the number of elements of a particular class within an object.">
        <cocoa class="NSCountCommand"/>
        <access-group identifier="*"/>
        <direct-parameter type="specifier" requires-access="r" description="The objects to be counted."/>
        <parameter name="each" code="kocl" type="type" optional="yes" description="The class of objects to be counted." hidden="yes">
            <cocoa key="ObjectClass"/>
        </parameter>
        <result type="integer" description="The count."/>
    </command>

相关文章

网友评论

      本文标题:六、AppleScript 词典

      本文链接:https://www.haomeiwen.com/subject/jfdqphtx.html