This blog has moved to rhult.github.com

Getting HideOnLaunch right

Tuesday, June 30, 2009
In a previous post I described how to set up an app to launch automatically on login. After posting that, I've noticed that it seems like the "Hide on launch" property often seems to be mixed up with the kLSSharedFileListItemHidden key (for an example, see this thread from 2008 on Cocoa-dev).

So in an attempt to improve chances of people finding the right answer when searching for the incorrect key kLSSharedFileListItemHidden, here is the relevant snippet again:

NSDictionary *properties =
[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
// NOTE, notice the key name:
forKey:@"com.apple.loginitem.HideOnLaunch"];

LSSharedFileListItemRef itemRef =
LSSharedFileListInsertItemURL(loginItemsListRef,
kLSSharedFileListItemLast,
NULL,
NULL,
(CFURLRef)bundleURL,
(CFDictionaryRef)properties,
NULL);
...

1 comments:

Unknown said...

Just wanted to thank you for this snippet, that info was hard to find!

Post a Comment