通过启动服务可以使用多个应用程序,想要指定特定的一个
问题是:
我有一个要启动的应用程序名称列表。它们不包含路径(例如{“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
LSFindApplicationForInfo()
,“定位具有指定创建者签名、捆绑 ID、文件名或这些特征的任意组合的应用程序”。You can use
LSFindApplicationForInfo()
, which "Locates an application with a specified creator signature, bundle ID, filename, or any combination of these characteristics."如果您有应用程序的捆绑包 ID,则无需使用以下脚本启动应用程序即可获取应用程序的路径:
这会在事件日志中生成以下输出:
If you have the bundle ID of an application, you can get the path to the application without launching it using the following script:
This produces the following output in the Event Log: