How to set iTunes 11 in shuffle or repeat mode via applescript

后端 未结 7 1002
梦谈多话
梦谈多话 2020-12-13 16:42

According to http://dougscripts.com/ setting shuffle and repeat modes via applescript is broken in iTunes 11.

According to this stackoverflow answer shuffle is now a

7条回答
  •  自闭症患者
    2020-12-13 17:06

    Spent some time deconstructing all the obfuscated solutions in this post (which appear to not work anymore), here's a more readable and customizable approach that works with iTunes 12.1:

    tell application "System Events"
    
        set itunesMenuBar to process "iTunes"'s first menu bar
        set controlsMenu to itunesMenuBar's menu bar item "Controls"'s first menu
        set shuffleMenu to controlsMenu's menu item "Shuffle"'s first menu
    
        set shuffleOnMenuItem to shuffleMenu's menu item "On"
        set shuffleSongsMenuItem to shuffleMenu's menu item "Songs"
    
        tell process "iTunes"
            click shuffleOnMenuItem
            click shuffleSongsMenuItem
        end tell
    
    end tell
    

    This will turn shuffle on and set it to shuffle songs instead of albums, and it should be pretty obvious how to change it to do other things.

提交回复
热议问题