Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to hide the dock icon programmatically

Is it possible to hide dock icon programmatically on demand. I know one way by which defining property "Application is agent (UIElement)" in plist we make the cocoa app as user agent. But this result in hiding the dock icon permanently.

I am looking for a way where i can control visibility of dock icon. Any idea ?

like image 680
Unicorn Avatar asked May 14 '10 09:05

Unicorn


1 Answers

Unfortunately not. You can transform a background-only app to a foreground app using the TransformProcessType() function but you can't go from a foreground app to a background app.

Here's how to go from background to foreground:

ProcessSerialNumber psn = { 0, kCurrentProcess }; 
OSStatus returnCode = TransformProcessType(&psn, kProcessTransformToForegroundApplication);
if( returnCode != 0) {
    NSLog(@"Could not bring the application to front. Error %d", returnCode);
}
like image 91
Rob Keniger Avatar answered Sep 28 '22 15:09

Rob Keniger