Applescript - 列出所有正在运行的应用程序

发布于 2024-08-07 20:45:14 字数 561 浏览 4 评论 0原文

我如何才能按照在 applescript 中执行 ⌘ + ⇥ 时出现的相同顺序获取正在运行的应用程序列表?

即,如果我使用 TextEdit,然后 Preview,然后 iCal,顺序是

iCal、Preview、TextEdit

这个问题询问是否有一个 API 可以生成此列表并提供此答案:

$ cd /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework

$ nm LaunchServices | grep __LSCopyApplicationArrayInFrontToBackOrder

但是如何从 applescript 中访问此列表?

How can i get a list of running applications in the same order they appear when doing ⌘ + ⇥ from within an applescript?

I.e. if I use TextEdit, then Preview, then iCal, the order is

iCal, Preview, TextEdit

This question which asked if there was an API that could produce this list provided this answer:

$ cd /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework

$ nm LaunchServices | grep __LSCopyApplicationArrayInFrontToBackOrder

But how can I access this list from within an applescript?

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

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

发布评论

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

评论(2

守不住的情 2024-08-14 20:45:14

告诉应用程序“系统事件”获取每个进程的名称

看起来对我来说是按启动日期排序的,但我不知道这是否可靠。

至于使用 SO 的答案:您必须在(目标)-C 中创建一个小程序(或 OSAX)来访问该例程,使该程序可编写脚本,然后从脚本中调用该程序/OSAX。

tell application "System Events" to get name of every process

It looks sorted by launch date to me, but I don't know if that's reliable or not.

As for using the answer from SO: you would have to create a small program (or OSAX) in (Objective)-C to access that routine, make the program scriptable, then call that program/OSAX from your script.

怎樣才叫好 2024-08-14 20:45:14

不确定如何订购它们但这列出了不仅仅是后台的应用程序

tell application "System Events" to get the name of every process whose background only is false

Not sure as how to order them But this lists applications that are not background only

tell application "System Events" to get the name of every process whose background only is false
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文