How to add a context-sensitive menu item (using "right click") to a file in Mac OS X finder?

I need to add a context sensitive menu to file icons in a search device. Thus, basically, if I right-click on, say, the icon “filename.txt”, the submenu should appear “Open”, “Get information”, etc., but an additional element should be added that says, for example , "My program." And if the user selects the menu item "My program", the system will execute: "my_program.rb filename.txt".

I have Mac OS 10.6 32-bit.

I checked the stack overflow and I posted the solutions there, but I'm a bit confused by them. First, according to this article , you need to “add a service that allows you to use the sharing tool,” but that scares me. What is a “service”? Is it a program with special hooks for the OS or something like that?

There is also an article for Apple to provide the service , but again, I'm a little confused by it. Can ruby ​​script be considered a "service"? Or do I need to do some weird Cocoa thing in a C object to access the submenu and then access the script there?

Is there an easier way to do this? Maybe an open source program that I have not yet encountered?

+6
source share
1 answer

You must use the services. See the Service Implementation and MakingServices Guide .

Services are functions exported by your application for the benefit of other applications. Services allow you to share the resources and capabilities of your application with other applications in the system.

Services are available from the context menu.

+4
source

Source: https://habr.com/ru/post/916765/


All Articles