Re: Cocoa, Finder Preferences & Blank Media (CD-R etc) ...
Re: Cocoa, Finder Preferences & Blank Media (CD-R etc) ...
- Subject: Re: Cocoa, Finder Preferences & Blank Media (CD-R etc) ...
- From: Ken Thomases <email@hidden>
- Date: Thu, 19 Feb 2009 14:36:35 -0600
On Feb 19, 2009, at 3:47 AM, Mic Pringle wrote:
When I pop a blank cd/dvd Finder prompts a window asking what to do
with it ie which application to use to open it. I also know that you
can also set these preferences using the CD/DVD preference pane in
System Preferences.
However, what I'd like to know is if you can set these via Cocoa, and
if so how ?
I'm writing a small cd-burning application which is almost complete,
and would like to offer the end user an option to associate my app
with any blank media inserted so that it automatically opens, like
iTunes does when I pop in a music cd.
This is similar to the recent thread on setting the desktop picture
rotation preference. The answer is to script System Events.
tell application "System Events"
tell blank DVD of CD and DVD preferences
set insertion action to open application
set custom application to POSIX file "/Applications/MyApp.app"
end tell
end tell
To learn more, open /Applications/AppleScript/Script Editor.app. Open
the Library window. From the Library, open the dictionary for System
Events. In the containment view (center option in the View segmented
control), click on application to see that it has a CD and DVD
preferences property. The class of this is "CD and DVD preferences
object". Click on that to see the properties of the that class.
Besides "blank DVD", there are also "blank CD", "music CD", "picture
CD", and "video DVD". Each of those is an "insertion preference".
Click on that to see its properties.
Do not attempt to set preferences for system-wide things like this by:
rewriting a .plist file on disk; using CFPreferences, NSUserDefaults,
or the "defaults" command to set a key in the relevant domain; or
scripting the GUI of System Preferences. Go down these routes will
only end in heartbreak.
Cheers,
Ken
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden