AppleScript可以在iTunes/Music表单中切换选择吗?
我刚从10.14迁移到蒙特雷,迁移摧毁了我的播放列表中的所有显示设置。我有200多个播放列表,因此我正在尝试编写一个将它们全部设置为默认设置的脚本,而不是Apple的默认设置。我有一部分工作,但我需要最后一点帮助。
到目前为止,我已经做了两件事:
创建了一个键盘快捷键,将播放列表视为歌曲。快捷方式“ Command-Shift-S”现在将将当前的播放列表视为歌曲。这有效。 (感谢有用的网页)。
我有一个脚本,可以通过我所有的播放列表局部局部迭代并将它们视为歌曲。 (再次感谢有用的网页)。
我需要在脚本中包含一些内容,以将视图选项切换到我想要的内容。切换会起作用,因为每次我设置播放列表以查看为歌曲时选择相同的选项时,我知道需要切换什么。带有选项的表格看起来像这样: 态 我想切换专辑,爱,评分和iCloud下载。
麻烦是,虽然我可以让我的applescript打开表单,但我不知道如何以表单切换项目,也无法找到有关如何做的文档。我尝试使用Automator录制鼠标点击,但这无处可去。希望有一些简单的语法可以切换项目。
这是我到目前为止的脚本所拥有的。该脚本只能使用一个播放列表,因为我在整个库上尝试之前对其进行了测试。通过播放列表进行迭代是我可以毫无问题的事情,我只需要对表单选项的帮助即可。延迟在那里,所以我可以在测试时逐步看到发生了什么。
tell application "Music"
activate
set theplaylist to playlist "test1"
delay 1
reveal theplaylist
try
-- use the keyboard shortcut to change the view to Songs, this works.
tell application "System Events" to keystroke "s" using {command down, shift down}
delay 1
-- open the view options form, this works.
tell application "System Events" to keystroke "j" using {command down}
-- What do I put here to toggle the checkmark for Album, Love, etc.?????
delay 1
-- this next command closes the view options form. not sure I will need this when I am going thru the entire set of playlists.
-- It may be enough to just reveal the next playlist.
tell application "System Events" to keystroke "w" using {command down}
end try
end tell
任何帮助将不胜感激。感谢所有。
I just migrated to Monterey from 10.14 and the migration destroyed all the display settings in my playlists. I have over 200 playlists, so I'm trying to write a script that will set them all to MY default setting, not Apple's default. I've got part of it working but I need help with the last bit.
so far I've done two things:
created a keyboard shortcut to set the playlist view as Songs. The shortcut "command-shift-s" will now set the current playlist view as Songs. this works. (thanks to a helpful webpage).
I've got a script which will iterate thru all my playlists and set them to view as Songs. (again thanks to the helpful webpage).
I need to include something in the script that will toggle the view options to what I want them to be. Toggling will work because every time I set a playlist to view as Songs the same options are selected so I know what needs to be toggled. The form with options looks like this:
playlist view options form
I want to toggle Album, Love, Rating and iCloud Download.
Trouble is, while I can get my applescript to open the form, I don't know how to toggle an item in the form, nor can I find the documentation on how to do it. I've tried recording mouse clicks using automator, but that went nowhere. Hopefully there is some simple syntax to toggle the items.
Here's what I have so far for my script. The script does only one playlist because I am testing it before trying it on my entire library. Iterating thru the playlists is something I can do without problem, I just need help with the form options. The delays are there so I can see what is happening step by step while testing.
tell application "Music"
activate
set theplaylist to playlist "test1"
delay 1
reveal theplaylist
try
-- use the keyboard shortcut to change the view to Songs, this works.
tell application "System Events" to keystroke "s" using {command down, shift down}
delay 1
-- open the view options form, this works.
tell application "System Events" to keystroke "j" using {command down}
-- What do I put here to toggle the checkmark for Album, Love, etc.?????
delay 1
-- this next command closes the view options form. not sure I will need this when I am going thru the entire set of playlists.
-- It may be enough to just reveal the next playlist.
tell application "System Events" to keystroke "w" using {command down}
end try
end tell
Any help would be appreciated. thanks to all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是艺术家专栏的完整示例,您可以从这里填写:
Here's a complete example for just the Artist column, and you can fill it out from here:
感谢Matt的代码示例。这是通过所有用户播放列表的最终程序,并将它们设置为“歌曲”并设置视图选项。
马特应该获得回答的信用。我是这个网站的新手,但我还没有弄清楚如何做到这一点。如果我做错了,我很抱歉。
在某些情况下,需要延迟,我会通过整个程序添加它们。
Thanks to matt for the code example. Here is the final program which goes thru all user playlists and sets them to "Songs" and sets the view options.
matt should get the credit for answering. I'm new to this site and I haven't figured out how to do that. my apologies if I've done it wrong.
the delays were needed in some cases and I enventually added them thru the whole program.