• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Snow Leopard default app setter - why does it open the app?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Snow Leopard default app setter - why does it open the app?
      • From: Christopher Nebel <email@hidden>
  • Prev by Date: Re: Open folders in new window
  • Next by Date: Re: Open folders in new window
  • Previous by thread: Re: Photoshop CS3 and CS4 [was Re: AppleScript & inDesign CS4 & 10.6]
  • Next by thread: Re: Snow Leopard default app setter - why does it open the app?
  • Index(es):
    • Date
    • Thread