通过启动服务可以使用多个应用程序,想要指定特定的一个

发布于 2024-08-28 00:17:13 字数 491 浏览 5 评论 0原文

问题是:

我有一个要启动的应用程序名称列表。它们不包含路径(例如{“VLC”,“Microsoft Word”}。我在不同的目录中有两个不同的VLC副本。我希望启动服务仅从/Applications/打开一个,而不是从/启动Applications/AnotherDirectory

我想获取这些的路径,并测试以查看启动服务想要启动什么(通过带有“open”的 bash 或通过“tell ___ to launch”或 [NSWorkspace launch...] 的 applescript)

唯一的方法我想出测试即将由启动服务启动的文件的路径是:

Applescript:

tell application "Finder" to return the (posix path of (path to application "VLC" as alias))

工作正常,但启动了应用程序(我根本不想要

建议)。

Here's the issue:

I have a list of App names that I want to launch. They do not include a path (e.g. {"VLC","Microsoft Word"}. I have two different copies of VLC in different directories. I would like Launch Services to ONLY open the one from /Applications/ and not EVER launch from /Applications/AnotherDirectory

I want to get the path of these, and test to see what Launch Services wants to launch (via bash with "open" or applescript via "tell ___ to launch" or [NSWorkspace launch...])

The only way that I have come up with to test the path of a file about to be launched by launch services is:

Applescript:

tell application "Finder" to return the (posix path of (path to application "VLC" as alias))

That works fine, but launches the app (which I don't want at all).

Suggestions?

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

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

发布评论

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

评论(2

无言温柔 2024-09-04 00:17:13

您可以使用 LSFindApplicationForInfo(),“定位具有指定创建者签名、捆绑 ID、文件名或这些特征的任意组合的应用程序”。

You can use LSFindApplicationForInfo(), which "Locates an application with a specified creator signature, bundle ID, filename, or any combination of these characteristics."

甜心 2024-09-04 00:17:13

如果您有应用程序的捆绑包 ID,则无需使用以下脚本启动应用程序即可获取应用程序的路径:

tell application "Finder"
    URL of application file id "org.videolan.vlc"
end tell

这会在事件日志中生成以下输出:

tell application "Finder"
    get URL of application file id "org.videolan.vlc"
        "file://localhost/Applications/VLC.app/"
end tell

If you have the bundle ID of an application, you can get the path to the application without launching it using the following script:

tell application "Finder"
    URL of application file id "org.videolan.vlc"
end tell

This produces the following output in the Event Log:

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