Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

brentley

macrumors newbie
Original poster
Apr 16, 2012
1
0
I want to know how I can write an application similar to f.lux and Dropbox that runs straight from the upper-righthand tool bar (not from the dock). Where/what should I read about in order to understand how to run an app that:

1. Runs from the toolbar in the upper-righthand corner
2. Runs all the time, even after reboot

Thanks.
 

Xcallibur

macrumors 6502a
Jul 24, 2011
520
9
Manchester
1. Runs from the toolbar in the upper-righthand corner
2. Runs all the time, even after reboot

Thanks.

This isn't a definitive answer more of a few hints, since I don't currently develop using Objective-C/OSX SDK. But I would think that although the application is running in the toolbar, it is still running, so is like any other application. So hiding the application from the dock whilst using a specific OSX API command for displaying a context menu from the toolbar may satisfy the first requirement.

The second, is the setting of an applications automatic run status, in Windows, you add values to the registry which equate to applications to be run at the startup of the system. So in OSX, there is probably a property that can be set using the OSX SDK to add the application to the list of applications to run at the startup of the system.

Maybe someone more familiar with OSX programming can give you more specific information.
 

anedwar

Contributor
Feb 10, 2012
33
3
North Carolina
Been a while since I had to do this but the basic steps are.

1. Get the system status bar
2. Tell the status bar to give you a status item
3. Create a new menu and assign it to the status item

so something like the following would probably work.
Code:
NSStatusBar *systemStatusBar = [NSStatusBar systemStatusBar];
NSStatusItem *test = [systemStatusBar statusItemWithLength: NSVariableStatusItemLength];
[test setTitle: @"Hello"];
       
NSMenu *testMenu = [[NSMenu alloc] init];
[testMenu setAutoenablesItems: YES];
[testMenu  addItem: [[NSMenuItem alloc] initWithTitle: @"1" action: @selector(menuItemPressed:) keyEquivalent:@""]];
[testMenu  addItem: [[NSMenuItem alloc] initWithTitle: @"2" action: @selector(menuItemPressed:) keyEquivalent:@""]];
    
[test setMenu: testMenu];
to make your application run in the background just assign the "Application is background only" property in your application info.plist

To get the application to run at start up have the user add a "Login Item" for you application. I'm sure there is a way to do this programmatically but I have not done so.

To do this manually go to System Preferences -> Users and Groups
Select the user you want and click the "Login Items" tab.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.