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
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?
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.
It does bring my Spotify to the front, but doesn’t affect play/pause state. I’m using Spotify (Premium) player version 4.3.427
I got it to work by commenting out the mouse click simulation and putting ‘keystroke ” “‘ instead 🙂
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
I’ve written a little app that lets you assign hotkeys to spotify actions, feel free to check it out and let me know what you think. 🙂
Woops, realised I haven’t linked it:
http://lifeupnorth.co.uk/lun/#5
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.
I have only just realised how irratating the scripts are when using spaces. I am working on an update that should stop the spaces jumping problem.
Anyone having any idea on whats wrong when im just getting the Spotify window to appear,, theres no change in the program itself.
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.
@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!
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
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
Aaron nice spot, completely passed me by. I have posted new updates, do you have a website so I can link??