I Hate GUI Scripting Except When I Don't
Sometimes the only way to script anything that isn't explicitly in an app's scripting definition is to use GUI Scripting. I always look for some other way before resorting to GUI Scripting since it can get pretty oogly and is dependent on the app's GUI; if the developer changes the GUI then the script can be rendered useless. With that said, a Correspondent writes:
"In iTunes, I utilize checkboxes to determine what songs are synced to my iPhone. I do not utilize playlists because I want to keep complete playlists in my iTunes library while still syncing them to my iPhone, minus any unchecked songs. The problem is that iTunes will not play unchecked songs continuously, which annoys me. I recently discovered, however, a preference called "Show list checkboxes". Unchecking this will hide the checkboxes column and allow me to play my songs uninterrupted, but when I want to sync my iPhone I have to show the checkboxes again so that it won't try to sync my entire huge library.
I was wondering if there was any way that you could create a script that toggles this preference on & off, in order to reduce the number of clicks required to switch between playing all of my music and syncing my iPhone. This would be much appreciated."
There's no explicit command to toggle this behavior, but this bit of GUI Scripting'll do it:
tell application "iTunes" to activate
tell application "System Events"
tell process "iTunes"
click menu item 3 of menu 2 of menu bar 1
click button 1 of UI element 5 of window 1
click UI element 25 of group 1 of window 1
click UI element 1 of window 1
end tell
end tell
You must have set up GUI Scripting using the instructions found here. And be warned that if the Preferences panel of iTunes changes in the future this script may no longer work.
As usual, works best with a keyboard shortcut.