Help with a unique project sought

Any intrepid coders want to help tackle a unique project? I am building a contextual menu module for OS X that accepts text selections only and passes that selection to an AppleScript embedded in the CMM. To help articulate this, just imagine highlighting some text then having the CMM pass that to a handler in an embedded AppleScript that displays a dialog with the text.

There is a very robust framework for OS X CMMs (minus the AS support) at:

I can get it working, sort of, but I need help. I can’t quit figure out how to only set the context to text selections (though I’m close). Despite that, I was able to work out a basic bridge to get a C > Obj-C > AppleScript method working. The problem is that the CMM architecture essentially makes the code an extension of the application and my code requires the Obj-C method to look inside its own bundle to find the AppleScript but since it’s run as the application, it looks in the application’s bundle and fails to find the script.

So, the help I need is to just limit the context to selected text and then a way to dynamically find the path to the CMM that is running the code, not the application that is calling it (which shouldn’t be too difficult since the CMM does have a unique bundle identifier).

Any help or pointers any one can give is greatly appreciated.


PS I do know about BigCat and OnMyCommand but I need to write my own unique CMM.

OK, in writing out the description of what I needed, I realized that I could just use the bundle identifier for the CMM and, lo and behold, it worked! So, I’ve got the bridge to pass the data all the way to the AppleScript, I’ve just got to figure out how to just limit the context.


Update: I got the context working fine (two, in fact–selected text & text on the clipboard) and I have been able to determine how to handle each context. So it all works except the AppleScript bridge only works in certain applications.

The examining and handling the context works everywhere but when it gets to the AppleScript bridge, it needs a host for the AppleEvent so it uses the current application. Some apps (such as BBEdit) seem to handle this without incident. Others, however, choke when they receive the AppleEvent (I think this is a Carbon issue).

I really need to get this thing going so if anyone would be willing to take a look at the source code and offer some suggestions on how to get the AppleEvent to run in all applications, or to target some process built specifically for this, please let me know.

Thanks so much,

I can’t offer help but I have an observation to offer. Big Cat Scripts Plugin, which allows users to run scripts via contextual menu, seems to work only in Carbon apps when the context is text. Maybe Cocoa doesn’t provide the support needed to do what you want to do. Here’s some material from the Big Cat FAQ.

You might drop a note to Brent Simmons ( to see if he has any concrete or updated info on this.

– Rob

Thanks Rob. I think I will contact Brent. I don’t think that is the issue, though, since the contextual menu itself show up properly in all of the apps tested and I send a log string to the console within the Obj-C method that calls the AppleScript just before it actually sends the AppleEvent. That string gets logged in every application so obviously every app sees the context, handles the context and the menu selection, but then errors out when the AppleEvent is set to run within the application (I log another string when it completes successfully).

It’s weird that it wouldn’t work in Cocoa apps, AppleScript Studio apps are Cocoa apps.