PDA

View Full Version : Opening list of tracks in non-scriptable app


Juneappal
07-12-2003, 05:19 AM
I am trying to write (my first ever) applescript to open selected tracks in Amazing Slow Downer. AMSL (Filename: Amazing X) is not Applescriptable, but I think the finder shuold be able to open files with it. Here is what I have come uip with so far:


tell application "iTunes"
activate
set trackList to the selection in browser window 1
set i_max to the count of trackList
repeat with i from 1 to i_max
set track_i to item i of trackList
copy (get track_i's location) to trackpath

tell application "Finder"
open (trackpath as alias) using application "Amazing X"
end tell

end repeat
end tell




I have tried a number of variations, and had no positive results. If I change

open (trackpath as alias) using application "Amazing X"
to
open trackpath

then it opens in iTunes, but if I try:
open trackpath using application "iTunes"

it tells me the handler can't handle it.


Any help? - this seems like it should be easy

Doug Adams
07-12-2003, 09:45 AM
It's not unusual for non-scriptable apps to fail at this sort of coerce. Your variables are all okay, note that the Finder will work with the RED commands (I altered some variables, but it's more or less the same code as your previous snippet):

tell application "iTunes"
activate
copy selection to sel
set i_max to the count of sel
repeat with i from 1 to i_max
set track_i to item i of sel
copy (get track_i's location) as string to trackpath
tell application "Finder"
get info for alias trackpath
open container of alias trackpath
end tell
end repeat
end tell


I tried using a couple of non-scriptable applications to open a file this way and none worked. I even tried using Audio 3, which is scriptable and could not open the file this way.

Will continue to investigate :)

Doug Adams
07-12-2003, 10:54 AM
Try this, note code in red:
tell application "iTunes"
activate
copy selection to sel
set i_max to the count of sel
repeat with i from 1 to i_max
set track_i to item i of sel
copy (get track_i's location) to trackpath

using terms from application "Finder"
tell application "some_application"
open (trackpath as alias)
end tell
end using terms from

end repeat
end tell


I'm anxious to know if this works for you with Amazing Slow Downer.

Juneappal
07-12-2003, 02:03 PM
Hey cool! It works! Thanks a million, Doug.

That "using terms from finder" is weird business. Does work because the finder can resolve aliases where the other apllications' open/save routines can't?

This (or some version of this) should be on the big page of scripts. I scoured the pages, downloading a dozen scripts to see what I could scavenge to write this. There doesn't seem to be any other script that opens selected itunes tracks with another application. Maybe in the tips and tricks page?.....

Well, it works for me anyways...Thanks again,

-Adam


The final, fully functional version for Amazing Slow Downer:


tell application "iTunes"
activate
copy selection to sel
set i_max to the count of sel
repeat with i from 1 to i_max
set track_i to item i of sel
copy (get track_i's location) to trackpath

using terms from application "Finder"
tell application "Amazing X"
open (trackpath as alias)
end tell
end using terms from

end repeat
end tell

Doug Adams
07-12-2003, 02:19 PM
Hooray!

I had never run in to a situation where "using terms from" was required. I had seen it used when attempting to use the Finder on another remote machine. It didn't occur to me until now to try it like this.

I will definetly write up a note on it!

By the way, if you'd care to submit your script to be posted at the site, I'd happily accept it. Put together a little read me and how you use the script with Amazing Slow Downer and that'd be great. You can email it to me. To escape any spam dredgers, my email looks sorta like this: dougadams ampersand mac.com