Platforms to show: All Mac Windows Linux Cross-Platform

NSRunningApplicationMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Process MBS MacCocoa Plugin 9.7 ✅ Yes ❌ No ❌ No ❌ No Desktop, Console & Web
NSRunningApplication is a class to manipulate and provide information for a single instance of an application.
Example
dim n as new NSRunningApplicationMBS

MsgBox n.localizedName

Only user applications are tracked; this does not provide information about every process on the system.
Some properties of an application are fixed, such as the bundle identifier. Other properties may vary over time, such as whether the app is hidden. Properties that vary can be observed with key-value observing, in which case the description comment for the method notes this capability.
Properties that vary over time are inherently race-prone. For example, a hidden app may unhide itself at any time. To ameliorate this, properties persist until the next turn of the main run loop in a common mode. For example, if you repeatedly poll an unhidden app for its hidden property without allowing the run loop to run, it will continue to return false, even if the app hides, until the next turn of the run loop.
NSRunningApplication is thread safe, in that its properties are returned atomically. However, it is still subject to the main run loop policy described above. If you access an instance of NSRunningApplication from a background thread, be aware that its time-varying properties may change from under you as the main run loop runs (or not).
An NSRunningApplication instance remains valid after the application exits. However, most properties lose their significance, and some properties may not be available on a terminated application.

Requires Mac OS X 10.6.

Constants

Constant Value Description
NSApplicationActivateAllWindows 1 One of the flag constants for activateWithOptions. By default, activation brings only the main and key windows forward. If you specify NSApplicationActivateAllWindows, all of the application's windows are brought forward. more
NSApplicationActivateIgnoringOtherApps 2 One of the flag constants for activateWithOptions. By default, activation deactivates the calling app (assuming it was active), and then the new app is activated only if there is no currently active application. This prevents the new app from stealing focus from the user, if the app is slow to activate and the user has switched to a different app in the interim. However, if you specify NSApplicationActivateIgnoringOtherApps, the application is activated regardless of the currently active app, potentially stealing focus from the user. You should rarely pass this flag because stealing key focus produces a very bad user experience. more
NSApplicationActivationPolicyAccessory 1 One of the constants used for following activation policies. The application does not appear in the Dock and does not have a menu bar, but it may be activated programmatically or by clicking on one of its windows. This corresponds to value of the LSUIElement key in the application's Info.plist being 1. more
NSApplicationActivationPolicyProhibited 2 One of the constants used for following activation policies. The application does not appear in the Dock and may not create windows or be activated. This corresponds to the value of the LSBackgroundOnly key in the application's Info.plist being 1. This is also the default for unbundled executables that do not have Info.plists. more
NSApplicationActivationPolicyRegular 0 One of the constants used for following activation policies. The application is an ordinary app that appears in the Dock and may have a user interface. This is the default for bundled apps, unless overridden in the Info.plist. more

This class has no sub classes.

Some methods using this class:

Some examples using this class:

Blog Entries


The items on this page are in the following plugins: MBS MacCocoa Plugin.


NSRunLoopMBS   -   NSSavePanelMBS


The biggest plugin in space...