Snow Leopard default app setter - why does it open the app?
Snow Leopard default app setter - why does it open the app?
- Subject: Snow Leopard default app setter - why does it open the app?
- From: Laine Lee <email@hidden>
- Date: Thu, 24 Sep 2009 12:53:17 -0500
- Thread-topic: Snow Leopard default app setter - why does it open the app?
I pieced this together as an example of a droplet that can easily be
modified to work as an Automator Service to allow selection of a file's
intended default application from a list.
Why does it always launch the targeted application?
property appnamelist : {"Photoshop", "QuickTime Player X", "QuickTime Player
7", "TextWrangler", "Smultron"}
property appidlist : {"com.adobe.Photoshop", "com.apple.QuickTimePlayerX",
"com.apple.QuickTimePlayer", "com.barebones.textwrangler",
"org.smultron.Smultron"}
on open (theitem)
tell application "System Events"
set app_assoc to choose from list appnamelist
end tell
set theIndex to my CollectUniqueItemIndex(appnamelist, app_assoc)
set theValue to item theIndex of appidlist
set filePath to theitem
set target_file to POSIX path of filePath
set target_app to (path to (application id theValue))
tell application "System Events"
set default application of file target_file to (target_app as alias)
end tell
end open
on CollectUniqueItemIndex(theList, theitem) -- the Item can be string,
number, constant, app object or list
local aListMember
repeat with i from 1 to (count theList)
set aListMember to ((item i of theList) as text)
if aListMember = (theitem as text) then
set theIndex to i
exit repeat
end if
end repeat
return theIndex
end CollectUniqueItemIndex
--
Laine Lee
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden