I have fooled around with Applescript now and then, not really getting anything useful or even working done.
But using some hacks and examples I have been able to create this (I refer to it as my first) Applescript. The script saves artist and title of current song playing in iTunes to a pre-defined text file.
I listen a lot to streamed music and this is nifty for when I want to buy something I am listening to or something needs to be checked out later.
-- iPod & iTunes Hacks -- hack #92 modified -- get info from current track tell application "iTunes" if player state is not stopped then if class of current track is not URL track then tell current track to set {alb, art, nom, com} to {album, artist, name, composer} else if current stream title is not "" then set {art, nom} to my text_to_list(current stream title, " - ") set {alb, com} to {"", ""} else display dialog "Can't get data from stream." buttons {"Cancel"} default button 1 with icon 0 giving up after 30 end if set m to nom & " by: " & art set message to "We are listening to: " & m set answer to button returned of (display dialog message buttons {"Ok", "Save"} default button 2) log answer if answer is equal to "Save" then set rv to my write_to_file(m) end if end if else display dialog "No track currently playing." buttons {"Cancel"} default button 1 with icon 0 giving up after 30 end if end tell
on text_to_list(txt, delim) set saveD to AppleScript's text item delimiters try set AppleScript's text item delimiters to {delim} set theList to every text item of txt on error errStr number errNum set AppleScript's text item delimiters to saveD error errStr number errNum end try set AppleScript's text item delimiters to saveD return (theList) end text_to_list
on write_to_file(m) set newline to ASCII character 10 set the_file to (((path to desktop) as string) & "music.txt") as file specification try open for access the_file with write permission write (m & newline) to the_file starting at eof close access the_file on error try close access the_file end try end try return true end write_to_file