Add an item in Finder's contextual menu with Cocoa - macos

In Cocoa on Mac, I would like to add a menu item in the Finder's popup menu that comes when I right-click on a file or a folder, and having this item pointing to a function in my app.
How can I achieve this ?
Thanks !

A good place to start is CocoaDev: StandardService. It outlines what you are trying to accomplish and they give some source code to follow such as the MakingServices example.
2015 Update: As of Yosemite, Apple includes an extension called Finder Sync which allows you to accomplish most of what a Service used to do.
Best of luck.

Related

MacOS, how to delete unused service item in Keyboard Shortcuts

I'm a newbie to Mac OS and learning with Automator, I found it useful but not quite controllable. I made a shortcut in services but I don't know how to delete it.
The item highlighted is what I want to delete. I think I should do it with Automator but I don't find out how.
Any help will be appreciated.
crtl + mouse click on the service to get a context menu for the service.
Select Show in Finder.
This will take you to the service file by opening a new finder window and selecting it.
You then just need to remove the file from the Services folder.
When close and re-open the System Prefs. The Service will not be there anymore.
Here Are Some Good Things to Know Too
#markhunte seems to have a good answer, but here's another way:
If you are within Automator.app,
Open the Service that you want to delete. You may have to choose "Open..." from the menu and type the key-combination command-shift-period to view invisible files such as ~/Library (which is now invisible by default in Mountain Lion.)
Your services (the ones that are local to your account) are in the folder: ~/Library/Services
After opening your Service in Automator, hold down the command-key and click the title of the window. (This works in most Mac applications -- not just in Automator to reveal documents in the Finder.)
Once you've found the document in the Finder, you can simply move it to the Trash like any other document.
Also, other kinds of Automator workflows can be found in a similar manner in the following directory:
~/Library/Workflows/Applications
I think that with this sort of Thing that Apple has just made it hard.
With the folder ~/Library now being hidden by default.
With having to know the "secret-handshake" command-shift-period to be able to open hidden files.
and
To have a way to reveal documents in the Finder, but have it also a "secret-handshake" of holding down the command-key while clicking on a document window's title to be able to reveal documents in the Finder.
I think that to get Apple to change these things, the way that they listen is if many developers file a bug report:
Apple's Bug Reporter:
https://developer.apple.com/bug-reporting/
Look in ~/Library/Services or /Library/Services
In the Finder, ~/Library is now an invisible folder by default in Mountain Lion. Of course, people can google for "Mac show hidden files" and find a command to enter into the command-line to make all files and folders visible. As a programmer, I like being able to see everything.
Unix Command:
defaults write com.apple.Finder AppleShowAllFiles TRUE
Reference:
http://osxdaily.com/2009/02/25/show-hidden-files-in-os-x/

How to add right click menu like dropbox for my specific application

Problem:
I need to have a right click menu on a specific folder, that shows my application submenu. Something like dropbox does.
I did try to google a lot and found Services which provides to create right click menu, but it creates generic menu not on a specific file or folder. How does dropbox does it? Does it use some python script? Any help would be very much appreciated.
Kapil

How to add customized right click menu like dropbox does on macintosh (cocoa or any programming language)

Is there any way to add customized right click menu like dropbox does. I did check services in Automator but did not find it useful (actually i am not sure how to use automator only for a group of files within a folder).
Does anyone has customize the right click menu in Macintosh?

applescript choose file title

I have got a choose file in my applescript. How do I change the title of the Choose a File window that comes up. I am aware of with prompt, but it doesn't change the title.
Edit: ulvund answered I'm afraid with prompt is the best you can do, but are there any other ways to get a choose file without applescript? Also, are there any hacks?
Edit 2: Red_Menace answered (look below) but are there any good tutorials on how to do this in Cocoa-Applescript?
P.S. Look at my comments.
Edit 3: I have put this into another question.
The dialog in plain AppleScript doesn't have that option, but you can access various Cocoa methods in Snow Leopard and Lion using AppleScriptObjC. In Lion, you can create a Cocoa-AppleScript Applet from the template in the AppleScript Editor, then create your own dialog, for example using NSOpenPanel.
I'm afraid with prompt is the best you can do:
http://docs.info.apple.com/article.html?path=AppleScript/2.1/en/as309.html
An answer to the edited question: You can use Automator.
Ask for Finder Items action in Files & Folders library will show the choose file dialog. You can change the title of the dialog of this action.

Adding item to the Desktop context menu in Windows

I want to add an item into the Desktop context menu (the menu you see when you right-click on an empty space on the Windows Desktop).
Something like Catalyst Control Center in this screenshot:
I know how to add items to files' and folders' context menus through registry, but the Desktop seems to work differently: I didn't even find the text in the registry.
So, how can I add a new item into the Desktop menu and how can I associate some code with it?
I think the solution is language independent, if it's not, I'd appreciate any code that helps.
Such a handler must be registered in HKCR\Directory\Background, instead of usual locations like HKCR\Directory, HKCR\Folder, etc.
Check out Creating Shell Extension Handlers in MSDN.
There's a series of articles on CodeProject that details writing Shell Extensions and is very good:
http://www.codeproject.com/KB/shell/shellextguide1.aspx

Resources