jld*_*ont 2 macos itunes objective-c appleevents
我想通过Objective-C来控制iTunes(我只是无法appscript在我的OS/X 10.6.3系统上正确安装Python ......这本来是我的首选).
根据我收集的内容,Cocoa上的IPC基于Apple Events:是否有:
我知道有关AppleScript编辑/打开字典功能,但我不知道如何翻译我看到到IPC通话信息.
注意:我已经尝试过通过PyObjC制定解决方案,但我所追求的主要功能是跟踪搜索,我无法弄清楚.
免责声明: OS/X超级新手在这里.
Mic*_*sai 11
您是否考虑过使用Scripting Bridge?它内置于操作系统中,也适用于PyObjC.没有明确的搜索API,因为搜索内置于AppleScript(其子句)中,该脚本映射到Scripting Bridge中的NSPredicate.
>>> from Foundation import *
>>> from ScriptingBridge import *
>>> itunes = SBApplication.applicationWithBundleIdentifier_(u"com.apple.itunes")
>>> tracks = itunes.sources()[0].libraryPlaylists()[0].tracks()
<SBElementArray @0x468a630: every ITunesTrack of ITunesLibraryPlaylist 0 of ITunesSource 0 of application "iTunes" (157)>
>>> predicate = NSPredicate.predicateWithFormat_(u'artist == "Pink Floyd"')
>>> tracks.filteredArrayUsingPredicate_(predicate)
<SBElementArray @0x457b6c0: ITunesTrack whose 'cmpd'{ 'relo':'= ', 'obj1':'obj '{ 'want':'prop', 'from':'exmn'($$), 'form':'prop', 'seld':'pArt' }, 'obj2':'utxt'("Pink Floyd") } of ITunesLibraryPlaylist 0 of ITunesSource 0 of application "iTunes" (157)>
Run Code Online (Sandbox Code Playgroud)
此外,如果您是AppleScript的新手,我强烈推荐Script Debugger的词典资源管理器.
| 归档时间: |
|
| 查看次数: |
1917 次 |
| 最近记录: |