获取按上次使用排序的正在运行的应用程序列表 [英] Getting the list of running applications ordered by last use
问题描述
我想按照它们在执行 ⌘ + ⇥ 时出现的相同顺序获取正在运行的应用程序列表
I'd like to get the list of running applications in the same order they appear when doing ⌘ + ⇥
即如果我使用TextEdit,然后预览,然后iCal,顺序是
I.e. if I use TextEdit, then Preview, then iCal, the order is
- iCal
- 预览
- 文本编辑
使用 [[NSWorkspace sharedWorkspace]launchApplications]
不起作用,因为应用程序是按启动日期/进程 ID 排序的.使用 GetNextProcess
枚举也不起作用,因为它也是按 pid 排序的.
Using [[NSWorkspace sharedWorkspace] launchedApplications]
does not work as applications are sorted by launch date/process id. Enumerating with GetNextProcess
does not work either as it is also ordered by pid.
注册通知和自己维护列表不是一种选择,因为我必须在应用程序启动后立即知道列表.嗯,列表的第一个元素实际上就足够了,但我认为这几乎是同一个问题.
Registering for notifications and maintaining a list myself is not an option as I must know the list right after the application launches. Well, the first element of the list would be enough actually, but I think it is pretty much the same question.
是否有一些 API 可用于获取此信息?
Is there some API available to get this information?
推荐答案
也许是这样的:
cd /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework
nm LaunchServices | grep __LSCopyApplicationArrayInFrontToBackOrder
这篇关于获取按上次使用排序的正在运行的应用程序列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!