Skip to content

Instantly share code, notes, and snippets.

@varlen
Created June 3, 2016 01:01
Show Gist options
  • Save varlen/4aa66f8e22f0390e1fbb92096074d586 to your computer and use it in GitHub Desktop.
Save varlen/4aa66f8e22f0390e1fbb92096074d586 to your computer and use it in GitHub Desktop.
Apple Scripting Bridge example
from Foundation import *
from ScriptingBridge import *
# Returns the methods of the object
def __methods( theObject ):
return [method for method in dir(theObject) if callable(getattr(theObject, method))]
# Elements present in one list but not in the other
def __diffList( A, B):
return list( set( A ) - set( B ) )
# Elements presents in both lists
def __bothList( A, B):
return list( set( A) & set( B ) )
# To get the aplication code
# $osascript -e 'id of app "Spotify"'
spotify = SBApplication.applicationWithBundleIdentifier_("com.spotify.client")
spotify.play()
track = spotify.currentTrack()
print track.artist() + " " + track.name()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment