Created
May 18, 2014 14:33
-
-
Save iloveitaly/9600f22f8d747e17f855 to your computer and use it in GitHub Desktop.
Some utilities for managing iTunes preferences that are not accessible via AppleScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on ensure_playlist_sort_and_list_view() | |
-- http://stackoverflow.com/questions/4056812/how-to-change-the-order-of-a-song-within-an-itunes-playlist-by-applescript/13667549#13667549 | |
tell application "System Events" | |
tell process "iTunes" | |
-- ensure list view | |
try | |
outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "iTunes" | |
on error | |
-- then we are not in list view | |
click menu button "View" of splitter group 1 of window "iTunes" | |
delay 0.25 | |
keystroke "L" | |
delay 0.25 | |
keystroke return | |
end try | |
-- ensure ascending sorting direction | |
set sort_button to button "status" of group 1 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of window "iTunes" | |
if value of attribute "AXSortDirection" of sort_button is "AXDescendingSortDirection" then | |
perform action "AXPress" of sort_button | |
end if | |
end tell | |
end tell | |
end ensure_playlist_sort_and_list_view | |
on playlist_repeat_all() | |
tell application "System Events" to tell process "iTunes"'s menu bar 1's menu bar item "Controls"'s menu 1's menu item "Repeat"'s menu 1 | |
perform action "AXPress" of menu item "All" | |
end tell | |
end playlist_repeat_all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment