AppleScript可以在iTunes/Music表单中切换选择吗?

发布于 2025-02-04 20:21:58 字数 1433 浏览 4 评论 0原文

我刚从10.14迁移到蒙特雷,迁移摧毁了我的播放列表中的所有显示设置。我有200多个播放列表,因此我正在尝试编写一个将它们全部设置为默认设置的脚本,而不是Apple的默认设置。我有一部分工作,但我需要最后一点帮助。

到目前为止,我已经做了两件事:

  1. 创建了一个键盘快捷键,将播放列表视为歌曲。快捷方式“ Command-Shift-S”现在将将当前的播放列表视为歌曲。这有效。 (感谢有用的网页)。

  2. 我有一个脚本,可以通过我所有的播放列表局部局部迭代并将它们视为歌曲。 (再次感谢有用的网页)。

我需要在脚本中包含一些内容,以将视图选项切换到我想要的内容。切换会起作用,因为每次我设置播放列表以查看为歌曲时选择相同的选项时,我知道需要切换什么。带有选项的表格看起来像这样: 态 我想切换专辑,爱,评分和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:

  1. 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).

  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不离久伴 2025-02-11 20:21:58

我在这里放置什么来切换专辑,爱等的复选标记

这是艺术家专栏的完整示例,您可以从这里填写:

tell application "Music"
    activate
    tell application "System Events"
        tell process "Music"
            try
                click (get menu item "Show View Options" of menu 1 of menu bar item "View" of menu bar 1)
            end try
            get checkbox "Artist" of scroll area 1 of window 1
            if value of result = 0 then
                click result
            end if
        end tell
    end tell
end tell

What do I put here to toggle the checkmark for Album, Love, etc

Here's a complete example for just the Artist column, and you can fill it out from here:

tell application "Music"
    activate
    tell application "System Events"
        tell process "Music"
            try
                click (get menu item "Show View Options" of menu 1 of menu bar item "View" of menu bar 1)
            end try
            get checkbox "Artist" of scroll area 1 of window 1
            if value of result = 0 then
                click result
            end if
        end tell
    end tell
end tell
旧情勿念 2025-02-11 20:21:58

感谢Matt的代码示例。这是通过所有用户播放列表的最终程序,并将它们设置为“歌曲”并设置视图选项。

马特应该获得回答的信用。我是这个网站的新手,但我还没有弄清楚如何做到这一点。如果我做错了,我很抱歉。

在某些情况下,需要延迟,我会通过整个程序添加它们。

    tell application "Music"
        activate
        -- first user playlist is the music library so skip it
        repeat with i from 2 to (count of every user playlist)
            reveal user playlist i
            delay 0.1
            tell application "System Events"
                tell process "Music"
                    tell application "System Events" to keystroke "s" using {command down, shift down}
                    delay 0.1
                    tell application "System Events" to keystroke "j" using {command down}
                    delay 0.1
                    --              click (get menu item "Show View Options" of menu1 of menu bar item "View" of menu bar 1)
                    -- the above line worked but for some reason occasionally crashed. using cmd-j did not. I don't understand that and it could have been caused by something entirely unrelated.

                    get checkbox "Album" of scroll area 1 of window 1
                    if value of result = 1 then
                        click result
                    end if
                    delay 0.1
                    get checkbox "Track Number" of scroll area 1 of window 1
                    if value of result = 0 then
                        click result
                    end if
                    delay 0.1
-- put in as many options as you like 
                    tell application "System Events" to keystroke "w" using {command down}
                end tell
            end tell
        end repeat
    end tell

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.

    tell application "Music"
        activate
        -- first user playlist is the music library so skip it
        repeat with i from 2 to (count of every user playlist)
            reveal user playlist i
            delay 0.1
            tell application "System Events"
                tell process "Music"
                    tell application "System Events" to keystroke "s" using {command down, shift down}
                    delay 0.1
                    tell application "System Events" to keystroke "j" using {command down}
                    delay 0.1
                    --              click (get menu item "Show View Options" of menu1 of menu bar item "View" of menu bar 1)
                    -- the above line worked but for some reason occasionally crashed. using cmd-j did not. I don't understand that and it could have been caused by something entirely unrelated.

                    get checkbox "Album" of scroll area 1 of window 1
                    if value of result = 1 then
                        click result
                    end if
                    delay 0.1
                    get checkbox "Track Number" of scroll area 1 of window 1
                    if value of result = 0 then
                        click result
                    end if
                    delay 0.1
-- put in as many options as you like 
                    tell application "System Events" to keystroke "w" using {command down}
                end tell
            end tell
        end repeat
    end tell
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文