Applescript API 文档 [英] Applescript API documentation

查看:44
本文介绍了Applescript API 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个 AppleScript 来自动执行在 MacBook Pro Retina 上切换分辨率的任务.

I want to make an AppleScript to automate the task of switching resolution on the MacBook Pro Retina.

在互联网上搜索applescript 系统偏好设置",我发现了一个页面 显示一些偏好的地方.作为缩放分辨率的新事物,它没有记录.

Searching the internet for "applescript system preferences" I came across a page where some preferences are show. Being the scaled resolution thing new, it is not documented.

这给我使用 AppleScript 带来了一个更大的问题(请注意,除了复制粘贴我从未真正在其中编写过的内容之外).例如,告诉我系统偏好设置对象实际上称为系统偏好设置"的文档在哪里,它具有称为窗格"的对象,它们有一个 id 并且公开 id 是com.apple.preference".expose"?

This brings to a bigger problem I have with AppleScript (mind that apart from copy-pasting something I never really programmed in it). Where is the documentation that tells me, for instance, tha the System Preferences object is actually called "System Preferences", that it has objects called "pane", that they have an id and that the expose id is "com.apple.preference.expose"?

似乎每个程序都必须有某种秘密"文档,而且它们必须很大,映射所有对象层次结构和可能的操作.最后,AppleScript 核心是最小的,您要做的就是操作这些程序.但是它们在哪里记录?

It seems like there must be some sort of "secret" documentation for every program, and they must be huge, mapping all the object hierarchies and possible actions. In the end, AppleScript core is minimal and all you do is manipulate such programs. But where are they documented?

推荐答案

好的,它是这样工作的:

Ok this is how it works:

例如,告诉我系统偏好设置对象实际上被称为系统偏好设置"的文档在哪里

Where is the documentation that tells me, for instance, tha the System Preferences object is actually called "System Preferences"

该对象称为系统偏好设置",因为这是应用程序的确切名称.你用这个告诉 Applescript 的是我想和名为 System Preferences 的应用程序对话 (tell application "System Preferences" ...)

The object is called "System Preferences" because that is the exact name of the application. What you're telling Applescript with this is I want to speak to the application named System Preferences (tell application "System Preferences" ...)

它有一个叫做窗格"的对象

that it has objects called "pane"

现在是有趣的部分.如果您打开库"窗口(在 Applescript 编辑器中,窗口">库"),您将看到有一组可用的可编写脚本的应用程序,问题是系统偏好设置"不存在.因此,让我们找到它:文件 > 打开词典 > 系统偏好设置.现在您有一个窗口,既可以让您深入了解应用程序的所有可用类/命令/属性,也可以使用相关文档的拆分窗口(如果您单击 SSystem Preferences 你会看到 Cpane,点击它你会看到 Pid 等等).窗格的 id 再次将是窗格的名称(小写和连接 - 我仍在寻找有关此的严格定义的文档).我希望这会让你开始.


S:套件C:类P:属性(圆圈内的'C'代表Command)

Now it's the fun part. If you open your Library window (in Applescript Editor, Window > Library) you will see that there is a collection of scriptable applications available, the thing is that 'System Preferences' is not there. So let's find it: File > Open Dictionary > System Preferences. Now you got a window that both lets you drill down all available classes/commands/properties of the app and also a split window with relevant documentation (if you click on SSystem Preferences you'll see Cpane and by clicking on this you'll see Pid among others). The id of the pane for once more would be the name of the pane (lowercased and concatenated - I'm still looking into documentation for a strict definition on this). I hope that this will get you started.


S:Suite C:Class P:Property (the 'C' inside a circle stands for Command)

这篇关于Applescript API 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆