“讲述”使用 Applescript 的特定完整路径的特定应用程序

发布于 2024-11-11 15:15:55 字数 78 浏览 0 评论 0原文

我希望告诉应用程序“xyz”,但通过指定应用程序的完整路径。这是因为系统上不同位置可能存在不同版本的应用程序,但名称相同。 如果这可能的话?

I am looking to tell application "xyz", but by specifying a full path to the application. This is because there may be various versions of the app on the system in different places, but with the same name.
If this possible?

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

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

发布评论

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

评论(2

辞别 2024-11-18 15:15:55

你尝试过吗?它适用于 posix 样式路径或 mac 样式路径,那么问题是什么?这再简单不过了。

set posixCalculatorPath to "/Applications/Calculator.app"
set macCalculatorPath to (path to applications folder as text) & "Calculator.app"

tell application posixCalculatorPath to activate

delay 2

tell application "Calculator" to quit

delay 2

tell application macCalculatorPath to activate

您可能不知道如何做的一件事是找到您想要定位的应用程序的路径。我创建了一个在此处找到的工具,如果您将路径提供给它文件,然后它将返回可以打开该文件的所有应用程序的路径。因此,该结果会告诉您是否有多个同名的应用程序,然后您可以选择使用哪一个。

Have you tried it? It works with either a posix style path or mac style path, so what's the issue? It couldn't be easier.

set posixCalculatorPath to "/Applications/Calculator.app"
set macCalculatorPath to (path to applications folder as text) & "Calculator.app"

tell application posixCalculatorPath to activate

delay 2

tell application "Calculator" to quit

delay 2

tell application macCalculatorPath to activate

One thing that you might not know how to do is to find the path to the application you want to target. I have created a tool found here which, if you feed it the path to a file then it will return the paths to all of the applications that could open that file. So that result would tell you if there is multiple applications with the same name and then you could choose which one to use.

霓裳挽歌倾城醉 2024-11-18 15:15:55
launch application ":Applications:TextEdit.app"

tell application ":Applications:TextEdit.app" to launch
launch application ":Applications:TextEdit.app"

tell application ":Applications:TextEdit.app" to launch
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文