toggle Music form options in applescript
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:
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
end try
end tell
Any help would be appreciated. thanks to all.
Mac mini, macOS 12.4