# HG changeset patch # User Dan Stowell # Date 1286888346 -3600 # Node ID d0c6a13ae6d25224759a591b4b9e44e891d1cb63 # Parent 726e1c1382f32c83a7f52df649e349ddd519d055 applescript to actually grab itunes current track diff -r 726e1c1382f3 -r d0c6a13ae6d2 osx/svitunes.mm --- a/osx/svitunes.mm Tue Oct 12 13:04:50 2010 +0100 +++ b/osx/svitunes.mm Tue Oct 12 13:59:06 2010 +0100 @@ -37,7 +37,22 @@ NSAppleScript *scriptObject = [[NSAppleScript alloc] initWithSource:@" \ tell application \"System Events\" to set iTunesIsRunning to (name of processes) contains \"iTunes\" \n\ if iTunesIsRunning is false then return \"\" \n\ -return \"twelve-bar blues track\"" +\ +tell application \"iTunes\" \n\ + if player state is not stopped then \n\ + set aTrack to current track \n\ + else \n\ + set sel to selection \n\ + if sel is not {} then --and (length of sel) is 1 then \n\ + set aTrack to item 1 of sel \n\ + else \n\ + return \"\" \n\ + end if \n\ + end if \n\ + \ + return the POSIX path of (location of aTrack as text) \n\ +end tell \n\ +" ]; NSLog([scriptObject source]);