I would like to display with AppleScript a dialog that shows my current title, artist and album. In addiction to that the icon of the dialog should be the album cover of the current album.
Is that possible?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
Yes it is. Here is what I came up with. It's late so it's a bit rough I'm afraid...
Pashua.scptto Applications folder
EDIT: Artwork code taken from this answer.
# # Start of code # global f, a tell application "iTunes" tell artwork 1 of current track set d to raw data if format is «class PNG » then set x to "png" else set x to "jpg" end if end tell set a to album of current track end tell set f to (((path to temporary items) as text) & "cover." & x) set b to open for access file result with write permission set eof b to 0 write d to b close access b -- Get the path to the folder containing this script tell application "Finder" set appPath to (path to applications folder) #set thisFolder to (container of (path to me)) as string set thisFolder to appPath as string if "Pashua:Pashua.app:" exists then -- Looks like the Pashua disk image is mounted. Run from there. set customLocation to "Pashua:" else -- Search for Pashua in the standard locations set customLocation to "" end if end tell set customLocation to "" log "customLocation: " & customLocation log "f: " & f try set thePath to alias (thisFolder & "Pashua.scpt") set pashuaBinding to load script thePath tell pashuaBinding -- Display the dialog try set pashuaLocation to getPashuaPath(customLocation) set dialogConfiguration to my getDialogConfiguration(f) set theResult to showDialog(dialogConfiguration, customLocation) on error errorMessage display alert "PashuaBinding: An error occurred" message errorMessage as warning end try end tell on error errStr number errorNumber display dialog errStr end try -- Returns the configuration string for an example dialog on getDialogConfiguration(pashuaLocation) if pashuaLocation is not "" then set img to "img.type = image img.x = 0 img.y = 50 img.maxwidth = 128 img.tooltip = Album Art img.path = " & (POSIX path of pashuaLocation) & return else set img to "" end if return " # Set window title *.title = Currently playing... # Introductory text txt.type = text txt.label = Track/Album Info txt.default = Album: " & a & return & " txt.height = 10 txt.width = 300 txt.x = 150 txt.y = 130 #txt.tooltip = This is an element of type “text” db.type = defaultbutton #db.tooltip = This is an element of type “defaultbutton” (which is automatically added to each window, if not included in the configuration) " & img end getDialogConfiguration # # END of CODE #