iTunes 10.6.3改变了AppleScript界面​​?

我有一个简单的Ruby脚本,它使用rb-appscript gem来控制iTunes,现在我已经更新到iTunes 10.6.3,它似乎被打破了。

在10.6.3之前,这段代码将按预期工作以获取当前选定的轨道:

Appscript.app('iTunes').selection.get() 

现在它产生以下错误:

 RuntimeError: Unknown property, element or command: 'selection' 

编辑:刚刚确认这在py-appscript中也被破坏了,所以它并没有被隔离到rb-appscript。

这很奇怪,因为以下的AppleScript仍然有效:

 tell application "iTunes" to get selection 

类似的例子,例如Appscript.app('Finder').desktop.files.get()仍然有效。

我找不到任何可以解释是否或为何更改了这些信息的信息,或者我可以做些什么来更新我的脚本。 我猜它与Mountain Lion的变化有关。

看起来iTunes 10.6.3随着Mountain Lion的沙盒发布而发布。 这是一篇关于它的文章(也请阅读评论) http://www.leancrew.com/all-this/2012/06/the-first-nail-in-the-coffin-of-python-appscript/

可能会像山狮一样开始发生更多事情(如果没有一切)

我在这里为这个问题提供了一个修复:

https://github.com/mattneub/appscript/tree/master/rb-appscript

是的,他们肯定打破了它。 您可以在系统事件应用程序中使用rb-appscript来有条件地检查各种UI元素的子元素,以查看“selected”属性是否为真….例如:

 i = 0 row_exists = true selected_row = nil while row_exists && !selected_row i += 1 row_exists = app("System Events").application_processes["iTunes"].windows["iTunes"].scroll_areas[3].outlines[1].rows[i].exists if row_exists if (app("System Events").application_processes["iTunes"].windows["iTunes"].scroll_areas[3].outlines[1].rows[i].attributes["AXSelected"].value.get == true) selected_row = app("System Events").application_processes["iTunes"].windows["iTunes"].scroll_areas[3].outlines[1].rows[i] end end end 

然后,您可以从所选行的子项中提取所需信息。 不过,这将是一个非常讨厌的方式。