OS X Dock API?检索 OS X 活动应用程序的图标以及徽章和其他修改

发布于 2024-08-27 08:46:49 字数 692 浏览 5 评论 0 原文

是否有 API 用于检索 Mac OS X 上当前打开的应用程序的图标?我正在尝试检索活动应用程序的所有图标以及应用程序顶部的任何徽章(即邮件中的新消息数或传输中的当前下载速率)。有某种 Dock API 吗?

我能找到的唯一提到用于检索当前活动应用程序信息的 OSX API 是 Process Manager API,其中没有提到轮询 Dock 或检索图标数据的功能。

就应用程序图标而言,我找到的唯一文档与 NSWorkspace 相关: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Workspace/introduction.html

Is there an API for retrieving the icons of the currently open apps on Mac OS X? I am trying to retrieve all the icons of the active applications along with any badges on top of the application (i.e. number of new messages in mail, or current download rate in Transmission). Is there some sort of Dock API?

The only mention of an OSX API for retrieving information about currently active applications I have been able to find is the Process Manager API, which does not mention the ability to poll the dock or retrieve icon data.

As far as application icons, the only documentation I have found is related to NSWorkspace: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Workspace/introduction.html

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

要走干脆点 2024-09-03 08:46:49

看起来Theocacao 有一个详细记录的 NSWorkspace 示例,用于获取打开的应用程序并检索其图标 。没有提及这是否也会检索应用程序图标的徽章/修改,或者是否有办法订阅与图标更新相关的通知。

检索活动应用程序:

NSWorkspace * ws = [NSWorkspace sharedWorkspace];
NSArray * apps = [ws launchedApplications];
NSLog (@"%@", apps);

检索应用程序的图标:

NSWorkspace * ws    = [NSWorkspace sharedWorkspace];
NSString    * path  = [ws fullPathForApplication:@"Safari"];
NSImage     * icon  = [ws iconForFile: path];

Looks like Theocacao has a well documented sample of NSWorkspace being used to obtain open applications and retrieve their icons. There isn't any mention of whether this will also retrieve badges/modifications to the application's icon or if there is a way to subscribe to notifications related to updates of the icon.

Retrieving active applications:

NSWorkspace * ws = [NSWorkspace sharedWorkspace];
NSArray * apps = [ws launchedApplications];
NSLog (@"%@", apps);

Retrieving an application's icon:

NSWorkspace * ws    = [NSWorkspace sharedWorkspace];
NSString    * path  = [ws fullPathForApplication:@"Safari"];
NSImage     * icon  = [ws iconForFile: path];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文