Another AppleScript! This time is for copying the lyrics of the current playing song in iTunes to a file. I use this with Proxy, a useful program that can bind actions to keys and show result/doing something with apps/etc. I’ve configured it to display a screen box with the lyric of the song (readed from the file created by this script) just by pressing Control+2 :-)

A screenshot:
screen_apple_script

The script:
on write_to_file(this_data, target_file, append_data)
try
set the target_file to the target_file as text
set the open_target_file to ¬
open for access file target_file with write permission
if append_data is false then ¬
set eof of the open_target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
return true
on error
try
close access file target_file
end try
return false
end try
end write_to_file
tell application “iTunes”
copy (get name of current track) to trackName
copy (get artist of current track) to trackArtist
copy (get lyrics of current track) to tracklyric
end tell

set this_story to trackName & ” – ” & trackArtist & return & tracklyric
set this_file to (((path to desktop folder) as text) & “MyLir”)
my write_to_file(this_story, this_file, false)