Identifying Active Applications in OS X
Question:
Obtain a list of active application bundles, especially GUI applications that the user has initiated, with information beyond the process names.
Answer:
Utilizing Apple's Swift and Cocoa frameworks, it is possible to programmatically retrieve a list of running applications in OS X.
import Foundation
import AppKit
// Get all running applications
let workspace = NSWorkspace.shared
let applications = workspace.runningApplications
for app in applications {
print(app)
}
The resulting app object is an NSApplication instance that contains the necessary information, including the desired bundle identifier.
Implementation Details:
Additional Notes:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3