Scripting Bridge and System Events
Scripting Bridge and System Events
- Subject: Scripting Bridge and System Events
- From: Kevin Wojniak <email@hidden>
- Date: Tue, 23 Dec 2008 16:17:52 -0500
I am trying to write a method to set the Desktop picture using
Scripting Bridge and System Events.
Header is generated via:
sdef /System/Library/CoreServices/System\ Events.app | sdp -fh --
basename SystemEvents
The working AppleScript is:
set picture of desktop 1 to POSIX file "/Some/file.jpg"
Here's the code I have:
SystemEventsApplication *systemEvents = [SBApplication
applicationWithBundleIdentifier:@"com.apple.systemevents"];
NSDictionary *props = [NSDictionary dictionaryWithObject:[NSURL
fileURLWithPath:@"/Some/file.jpg"] forKey:@"URL"];
SystemEventsDiskItem *picture = [[[[systemEvents
classForScriptingClass:@"disk item"] alloc] initWithProperties:props]
autorelease];
[[systemEvents diskItems] addObject:picture];
When I add it to the diskItems array, it pukes:
*** Terminating app due to uncaught exception 'NSGenericException',
reason: 'Apple event returned an error. Event =
'core'\'crel'{ 'kocl':'ditm', 'insh':'insl'{ 'kobj':'obj
'{ 'want':'file', 'from':'null'(), 'form':'indx',
'seld':'abso'($206C6C61$) }, 'kpos':'end ' }, 'prdt':{ 'url ':'furl'("file://localhost/Some/file.jpg
") } }
Error info = {
ErrorNumber = -10000;
I've tried several variations, with using key @"path" and
@"POSIXPath". I've tried creating the object with just init instead of
initWithProperties. No luck.
Any tips?
Thanks,
Kevin
_______________________________________________
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