Created
June 3, 2016 01:01
-
-
Save varlen/4aa66f8e22f0390e1fbb92096074d586 to your computer and use it in GitHub Desktop.
Apple Scripting Bridge example
This file contains hidden or 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
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