通过热键启动我的应用程序并从Finder(macOS)传递它的参数

时间:2021-10-22 22:06:35

I'm only starting macOS programming. Did some tutorials, reading docs at developers.apple.com. Trying to implement a simple(?) thing, but can't seem to get the whole picture for now. I want to be able to launch my app by pressing some hot keys combination. The app itself is just a window with a text field that has a list of selected files in Finder (if any). Naturally, I'm not asking for a concrete implementation. But some hints and directions on the general structure, or on what concepts and classes to inspect would be very helpful. macOS 10.13.4, Xcode 9.3.1, Swift 4

我只是开始macOS编程。做了一些教程,在developers.apple.com上阅读文档。试图实现一个简单的(?)的东西,但现在似乎无法全面了解。我希望能够通过按一些热键组合来启动我的应用程序。应用程序本身只是一个带有文本字段的窗口,其中包含Finder中所选文件的列表(如果有)。当然,我不是要求具体实施。但是一般结构的一些提示和指示,或者要检查的概念和类别将是非常有帮助的。 macOS 10.13.4,Xcode 9.3.1,Swift 4

1 个解决方案

#1


0  

Probably the best approach is to implement a "service". See the Services Implementation Guide.

可能最好的方法是实施“服务”。请参阅“服务实施指南”。

A service is a tool that appears in the Services submenu of the application menu and in contextual menus. It can be configured to be invoked by a hot key. The active application at the time the service is invoked cooperates by providing the current selection.

服务是显示在应用程序菜单的“服务”子菜单和上下文菜单中的工具。它可以配置为由热键调用。调用服务时的活动应用程序通过提供当前选择来协作。

#1


0  

Probably the best approach is to implement a "service". See the Services Implementation Guide.

可能最好的方法是实施“服务”。请参阅“服务实施指南”。

A service is a tool that appears in the Services submenu of the application menu and in contextual menus. It can be configured to be invoked by a hot key. The active application at the time the service is invoked cooperates by providing the current selection.

服务是显示在应用程序菜单的“服务”子菜单和上下文菜单中的工具。它可以配置为由热键调用。调用服务时的活动应用程序通过提供当前选择来协作。