Spotify Applescripts Version 0.4.3

1 minute read.

NEW! Updated version of the Applescripts available here

With the new version of Spotify the menus have been moved around, so I have updated the Applescripts that you can use to control Spotify with Quicksilver.
Play Next

tell application "System Events"
	set MyList to (name of every process)
end tell

tell application "System Events" to set appList to ¬
	name of application processes whose frontmost is true

set activeApp to item 1 of appList
if (MyList contains "Spotify") is true then
	tell application "Spotify" to activate
	tell application "System Events"
		tell process "Spotify"
click menu item 3 of menu 1 of menu bar item 6 of menu bar 1
		end tell
	end tell
	tell application "System Events"
		set visible of process "Spotify" to false
	end tell
end if

Play Previous

tell application "System Events"
	set MyList to (name of every process)
end tell

tell application "System Events" to set appList to ¬
	name of application processes whose frontmost is true

set activeApp to item 1 of appList
if (MyList contains "Spotify") is true then
	tell application "Spotify" to activate
	tell application "System Events"
		tell process "Spotify"
click menu item 4 of menu 1 of menu bar item 6 of menu bar 1
		end tell
	end tell
	tell application "System Events"
		set visible of process "Spotify" to false
	end tell
end if

Play/Pause

tell application "System Events"
	set MyList to (name of every process)
end tell

tell application "System Events" to set appList to ¬
	name of application processes whose frontmost is true

set activeApp to item 1 of appList
if (MyList contains "Spotify") is true then
	tell application "Spotify" to activate
	tell application "System Events"
		tell process "Spotify"
click menu item 1 of menu 1 of menu bar item 6 of menu bar 1
		end tell
	end tell
	tell application "System Events"
		set visible of process "Spotify" to false
	end tell
end if

16 Replies to “Spotify Applescripts Version 0.4.3”

  1. Interesting.. I was using the original scripts you posted and when they stopped working simply adjust the menu counts. What does the additional set MyList etc do?

  2. MyList is basically the list of currently running programs, so if you have spotify hidden or not the current active program. The apple script will go and make Spotify the foremost application so that the menu modifiers work.

  3. Add Search?

    tell application “Spotify” to activate
    tell application “System Events”
    tell process “Spotify”
    click menu item 17 of menu 1 of menu bar item 4 of menu bar 1
    keystroke “pet shop boys, it’s a sin”
    key code 36
    delay 1
    key code 48
    key code 48
    key code 36
    end tell
    end tell

  4. Great script. Really useful. What would be even better is if it could also support Spaces. Currently if I run the script it will change the current space to whichever space spotify is running in. It would be great to have it either stay in the space I am in or at least return to the space I was in.

  5. Anyone having any idea on whats wrong when im just getting the Spotify window to appear,, theres no change in the program itself.

  6. Just want to say thanks for this and that it works perfect! Was looking for a mini player to skip track without having to open Spotify, however, this solution is far better as I can now skip a song using an unused mouse button that I had. Perfect.

    @disretrospect, it does switch spaces, yes, but cross Spotify so it is closed. Now it doesn’t switch spaces when the script is ran.

  7. @Simon Nice idea of closing the Spotify window, but that does not really solve the problem. The active app still changes to Spotify (although window stays the same), but it should switch back to the program that was used when the script was activated.

    Anyone getting the Spaces to work?

    Still this is great!

  8. people with spaces problems, have you tried setting spotify to be on “All Spaces” in the options? that in theory should make it not switch

  9. Hello any/everyone, these scripts helped me out in the past and I’ve since learned Spotify has official Applescript support which makes things much easier. Hacks that bring the application in focus are no longer needed and everything can be seamlessly done just with the script running in the background.

    Here are my modified scripts: (if Spotify is not running it will not launch it)
    – Next track

    tell application “System Events”
    set MyList to (name of every process)
    end tell
    if (MyList contains “Spotify”) is true then
    tell application “Spotify” to next track
    end if

    -Pause/Play

    tell application “System Events”
    set MyList to (name of every process)
    end tell
    if (MyList contains “Spotify”) is true then
    tell application “Spotify” to playpause
    end if

    -Previous track

    tell application “System Events”
    set MyList to (name of every process)
    end tell
    if (MyList contains “Spotify”) is true then
    tell application “Spotify” to previous track
    end if

Leave a Reply