Re: Programatically Uncheck "Change Picture" In Desktop Settings?
Re: Programatically Uncheck "Change Picture" In Desktop Settings?
- Subject: Re: Programatically Uncheck "Change Picture" In Desktop Settings?
- From: Chunk 1978 <email@hidden>
- Date: Fri, 13 Feb 2009 19:25:16 -0500
when running my apple script i get this error:
-=-=-=-
System Events got an error: Access for assistive devices is disabled.
-=-=-=-
so if i goto system prefs and check "Enable access for assistive
devices", then running the script i get this error:
-=-=-=-
System Events got an error: Can't get application process "System Preferences".
-=-=-=-
here's my script:
-=-=-=-
tell application "System Events"
tell application process "System Preferences"
if value of checkbox "Change picture:" of group 1 of tab group 1 of
window "Desktop & Screen Saver" is 1 then
click checkbox "Change picture:" of group 1 of tab group 1 of
window "Desktop & Screen Saver"
end if
end tell
end tell
-=-=-=-
On Fri, Feb 13, 2009 at 5:34 PM, Ken Thomases <email@hidden> wrote:
> On Feb 13, 2009, at 3:30 PM, Chunk 1978 wrote:
>
>> is this possible? it seems that programatically changing
>> com.apple.desktop.plist (Background > Default > Change) from
>> TimeInterval to Never will not override the settings in System
>> Preferences. i though applescript could be an option but it seems
>> that using an applescript to accomplish this would have to open the
>> system preferences window. it's only ideal if it's done as a
>> background process.
>
> You want to target System Events rather than System Preferences with your
> AppleScript.
>
> Contrary to I. Savant, I don't think going through NSUserDefaults or
> CFPreferences will work. It still won't inform the necessary processes of
> the change in an active manner.
>
> Take a look at the LoginItemsAE sample code.
> <http://developer.apple.com/samplecode/LoginItemsAE/>
>
> Obviously, you're not working with Login Items, but it demonstrates the
> technique of sending Apple Events to System Events. Also, modifying the
> user's login items has some conceptual similarities to what you're trying to
> do. You might be tempted to modify the list of login items by manipulating
> the relevant .plist file, or by using NSUserDefaults or CFPreferences, but
> that's not appropriate. The main failing is that, if the user actually has
> the Login Items tab of the Accounts pane of System Preferences open, changes
> you make to the preferences won't be reflected there. Furthermore, the pane
> may at any time re-save what it thinks is the current state of the list,
> obliterating the change you attempted to make behind its back.
>
> (Ironically, the new shiny way to manipulate Login Items is the
> LSSharedFileList API, not this sample code. That API is currently only
> documented in <LaunchServices/LSSharedFileList.h>.)
>
> 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