I need to launch my application on startup, but I want it to be "minimized", meaning, it will be opened in the dock but its window won't be displayed.
Same like TeamViewer, if you know this application.
I currently use launchctl
with a plist I've added to ~Library\LaunchAgents
, and indeed on startup the application is launched, and its window is shown.
How can I launch it in such a hidden / minimized state?
Uncheck visible at launch in your xib for main application window.
Implement - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
in your app delegate class.
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
{
if (!flag) {
[window makeKeyAndOrderFront:self];
return YES;
}
return NO;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With