How do I create a Cocoa app that runs in the background (not in the dock, and not in the menu bar either; just in the background).
Does the app need admin privileges? I hope not. Actually it shouldn't, because it's enough that the app runs in the background for that user only, i.e. not for all users.
And I guess I can make it "launch when log-in" by just adding it to the user's Account Preferences, so that shouldn't be a problem.
In your Info.plist set LSBackgroundOnly to 1.
In your Info.plist, set LSUIElement to the string “1”.
The main difference is that a UI-element agent can have a UI (order in a window). A background-only app should be completely faceless; whatever UI it has should exist in a separate application or preference pane.
Related
Is there any way by which I can prevent a windows metro app from going to background since it goes in suspended state when in backgroud?
Else how can I show a alert message when I am trying to put app in the background?
Not programmatically: apps cannot override the user's choice here.
Once the app's window is deactivated it is too late for it to show an alert message.
From a system configuration standpoint the Assigned Access feature allows an admin to set up kiosk with a single app which the user can't switch away from.
I create a automator application and set it to run at logon, and I check the "Hide" box, but it still shows up (the gear icon) in the status bar. How can I hide it?
I check the "Hide" box here:
but the gear icon is still shown (the worse part is that it never stops rotating!)
Is it possible to hide this icon, or let it stop rotating?
control-click on it, and choose Show Package Contents from the pop-up menu. Inside the Contents folder, open up Info.plist, and change LSUIElement from No to Yes (if using Property List Editor) — or change the line after the LSUIElement key line to (if using a text editor). Save Info.plist.
Now when the alarm triggers, the Automator plugin will run in the background, without a Dock icon or a menu bar, and the focus will remain on the application you’re using.
Three things to note:
You might have to move the plug-in out of the iCal folder and back in
for this to work. Tiger caches the LSUIElement info; moving the app
forces Tiger to renew the cache.
You probably do not want to do this with any iCal plugin that has
dialogs or requires user interaction! This works best for maintenance
actions, automated downloads, and that sort of thing.
Third, this will work with any Automator workflow that is saved as an
application, not just with iCal plugins.”
Then Clear your Cache
With windows 8, is it possible to create an application that is always visible? For instance, in previous versions of windows, there is the task bar with quick launch icons. Can I create something similar to the quick launch icons that are always on the screen?
If you are referring to a Windows 8 Store app then the answer is no. You can have a live tile and toast notifications that provides updates to the user which may cause the user to launch your application.
A good article to read to understand how your Windows Store apps will run on Windows 8 go here to learn about Application lifecycle (Windows Store apps). This will explain the App execution state.
It is not possible in the RT version, but the same is possible in the desktop version. If you have a desktop app, you can pin it to the taskbar. But any Window store app cannot be pinned to the taskbar. What you can do instead is move the app to the beginning of your Home screen, so anytime you click the Windows button your app will be visible right in front.
Do you mean always visible in the Star Menu screen? If so, you can add tile updating functionality to your application. As long as the user has the application pinned to the Start Menu, he would see the updates. Check the link below for an introductory tutorial.
http://blogs.msdn.com/b/windowsappdev/archive/2012/04/16/creating-a-great-tile-experience-part-1.aspx
"Quick Launch" has a very specific meaning, which you may or may not have been referring to in your question.
Below is the Quick Launch bar in Windows 8 - essentially a toolbar pointing to a location in your %AppData% directory. Prior to Windows 7 it was available by default, but the ability to now pin items directly to the taskbar rather supersedes it. Here's how you can restore Quick Launch if you really want to :)
It's, of course, available only in the Desktop mode and not on the Modern UI, where pinning a tile is the best you can hope for, and it's all up to the user to pin it AND to determine where it shows up on their Start Screen.
Another option worth mentioning (although more like system tray than quick launch) is lock screen presence. If the user chooses so and your app supports that, he can add it to his lock screen:
either as a a badge (up to 7 apps)
or as a tile notification (single app only)
This is not a way for the user to quickly start your app (other answers have already covered these options) but a way to stay visible and keep your user informed.
It's possible to show/hide the application's icon from both the Dock and the Task Switcher by setting the "Application is agent (UIElement)" property to YES/NO.
However, is it possible to have an application show in the Task Switcher (Cmd + Tab), but not appear in the Dock?
Thanks.
I'm reasonably certain that this is impossible, and that the dock and the app switcher are using the exact same list to decide what should appear in them.
The reason for my believing this is that there's actually a procedure for removing an app's icon from the Dock, while the target app is running, that has nothing to do with the LSUIElement key. (It consists, essentially, of renaming/moving the app bundle and then restarting the Dock.) Even doing that, though, the app doesn't appear in the switcher.
(You can find the full procedure on macosxhints.com, if you're interested.)
How would I go about locking a screen like Keychain does, meaning preventing all access to Dock, menubar, desktop, etc. Basically just a black screen that I can add a password field to, for the user to return to the desktop? I am well aware of the Carbon method, but I want the NSApplication method because this is an all Cocoa application.
Thanks~
If you can get away with not writing this code yourself, all for the better. It is usually a terrible idea to write your own code to lock the screen, considering the number of vulnerabilities that have been found in screen locking code over the years. If you have a Carbon call that can do it, go ahead and use that... don't worry about the "purity" of your Cocoa code.
However, if you decide to write this yourself, here's what you do:
First, capture all the screens using CoreGraphics. See: http://developer.apple.com/mac/library/documentation/GraphicsImaging/Conceptual/QuartzDisplayServicesConceptual/Articles/DisplayCapture.html
Next, create a new NSWindow and put it in front of the window that's used for capturing the screens. You'll have to call a CG function to get the "order" of the black window covering each screen, and order the new window in front of that. Normally, the black window has an order so far forward that everything is behind it. Put a password field in the window. Do NOT use an ordinary text field or write your own code for password input. The password input field has a ton of special code in it so you can't copy text out of it, and other programs can't listen to keystrokes while you're typing into a password field. So use the one that Apple provides.
Last, put the computer in "kiosk mode". This mode allows you to disable alt-tab, user switching, the menubar and dock, and even the ability to force quit. See: http://developer.apple.com/mac/library/technotes/KioskMode/Introduction/Introduction.html
It's not a lot of code, it just uses a few different APIs so you'll spend most of your time bouncing between API docs. I suggest writing the screen lock code as its own application (just add a new application target to your Xcode project) and then put the screen locker inside your application bundle. This used to be (as of 10.4) how Apple Remote Desktop implemented the "Lock Screen" functionality, but I can't find the app anymore.
I believe the Cocoa replacement to the SetSystemUIMode API was not introduced until 10.6.
If you can live with Snow-Leopard-only code, the answer is - setPresentationOptions: on NSApplication.