iTunes Apple 事件 API
我想通过 Objective-C 控制 iTunes(我只是无法在我的 OS/X 10.6.3 系统上正确安装 Python appscript
...那是我的第一选择)。
据我所知,Cocoa 上的 IPC 基于 Apple Events :是否有:
- iTunes / Apple Events API 的在线文档?
- 获取 iTunes API 的自省机制?
我了解 Applescript 编辑器/开放词典功能,但我不知道如何将我看到的信息翻译为 IPC 调用。
注意:我已经尝试通过PyObjC制定解决方案,但我追求的主要功能是轨迹搜索,我无法弄清楚。
免责声明:这里是 OS/X 超级新手。
I'd like to control iTunes through Objective-C ( I just can't get Python appscript
installed correctly on my OS/X 10.6.3 system ... that would have been my first choice ).
From what I gather, the IPC on Cocoa is based on Apple Events : is there either:
- Online documentation on iTunes / Apple Events API ?
- Instrospection mechanism to get to iTunes API?
I know about Applescript Editor / Open Dictionary functionality but I can't figure out how to translate the information I see into IPC calls.
Note: I have already tried working out a solution through PyObjC but the main function I am after is track searching which I can't figure out.
Disclaimer: OS/X super-newbie here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否考虑过使用脚本桥?它内置于操作系统中,也可与 PyObjC 配合使用。没有明显的搜索 API,因为搜索内置于 AppleScript 中 (whose 子句),映射到 Scripting Bridge 中的 NSPredicate。
另外,如果您是 AppleScript 新手,我强烈推荐 Script Debugger 的字典浏览器。
Have you considered using Scripting Bridge? It's built into the OS and also works with PyObjC. There's no distinct searching API because searching is built into AppleScript (whose clauses), which map to NSPredicate in Scripting Bridge.
Also, if you're new to AppleScript, I highly recommend Script Debugger's dictionary explorer.
如果您在使用 py-appscript 时遇到问题,请联系作者(即我)来解决问题。包括有关正在使用的 Python 安装、Xcode 版本以及问题是否特定于 appscript 或影响所有第三方模块或具有 C 扩展的第三方模块的信息。另外,如果您使用 python.org 框架构建而不是内置 Python,请确保安装了可选的 OS X 10.4 SDK。
API 文档可通过 OS X 的 AppleScript 编辑器(文件 > 打开词典)、appscript 的 ASDictionary 或其他第三方 AS 编辑器获得。如果安装了 ASDictionary,您还可以使用 appscript 的内置 help() 方法以交互方式浏览字典。
然而,可编写脚本的应用程序的 API 文档是出了名的不足,因此还需要充分了解 AppleScript 的一般情况和应用程序脚本的具体工作原理。 Apple 自己的 AppleScript 语言指南 描述了涉及到的各种功能,但没有过多提及如何将它们投入实际使用;如果您愿意花一些钱,可以找到几本好书(免责声明:我自己刚刚与人合写了一本)。
并期望通过在线文章、讨论论坛和现有脚本进行大量挖掘以寻找线索。 Doug's AppleScripts for iTunes 是 iTunes 脚本的重要来源。当然,它们是用 AppleScript 编写的,但其中许多都可以在 AppleScript Editor 中阅读,因此是很好的提示来源,如果您使用 appscript,则可以使用 ASTranslate 将 AppleScript 语法转换为 appscript 语法作为起点写你自己的。
If you're having problems with py-appscript, please contact the author (that'd be me) to troubleshoot it. Include information on Python installation(s) being used, Xcode version, and whether or not the problem is specific to appscript or affects all third-party modules or third-party modules with C extensions. Also, if you're using a python.org framework build rather than the built-in Python, make sure you have the optional OS X 10.4 SDK installed.
API documentation is available through OS X's AppleScript Editor (File > Open Dictionary), appscript's ASDictionary, or other third-party AS editors. If ASDictionary is installed, you can also use appscript's built-in help() method to browse the dictionary interactively.
Scriptable applications' API docs are notoriously inadequate, however, so a good understanding of how AppleScript in general and application scripting in particular works is also necessary. Apple's own AppleScript Language Guide describes the various features involved, but doesn't say much about putting them to practical use; there are several good books available if you're willing to put down some cash (disclaimer: I've just co-written one myself).
And expect to do a fair amount of digging through online articles, discussion forums and existing scripts for clues. Doug's AppleScripts for iTunes is a great source of iTunes scripts. They're written in AppleScript, of course, but many of them can be read in AppleScript Editor so are a great source of tips, and if you're using appscript you can use ASTranslate to convert from AppleScript to appscript syntax as a starting point in writing your own.