Adding template as Service menu item

How can I add one of the existing DEVONthink templates as a Mac OS X menu item? I know there are already some that are service items, but I’d like to add a different one.

thanks for your assistance!

They are menu items, under Data.

If you want to add a keyboard shortcut, take a look at the way that’s done for the Annotation smart template.

Thanks - I see how add a command to run it.

But what I’m really trying to do is create an Apple Service. For example, highlight a block of text, right click -> services -> DEVONthink Pro Office: templateName

I know how you can make a service in automator, but trying to figure out how I could add the text to a specific template.

ideas?

It depends on the template. DEVONthink templates can be as simple as making a new document from an document stored in DEVONthink’s Templates folder. Or they can be complex documents generated by an AppleScript. A service made out of a simple document-based template will not take input text and insert it into the document. To do that, you will need to create or modify one of the AppleScript templates – examples are the DEVONthink templates with the “.templatescriptd” extension. The script is necessary to handle the interactivity that you want in your service. Services created with Automator and that use AppleScripts generally are wrapped in this code block

on run (input, parameters)
(* your code goes here
include a block to tell DEVONthink
what to do *) 
end run

Of course, services can be built out of Ruby, Python, etc., if you’re interested in that route.

Making a DEVONthink template into a service is straightforward task, but not simple.

Still not getting there …

Let’s say for example, I wanted to take DEVONthink Pro’s Annotation template, and turn it into a service item. How would I do it?

I actually haven’t been able to locate where DEVONthink installs its built-in service items like “Take Rich Note”. They aren’t stored in the usual Services director for either root or ~ User.

Ideas?

Assuming you have some experience with coding and Automator, Rewrite the code in that template to take input from the “on run…” wrapper. There are 23 or so lines of code to rewrite. With the customized script, build your service with Automator or This Service. With Automator, you would need a new RTF template and 4 actions.

In the DEVONthink application package.

I tried writing a script in Automator as you suggested - based on the Annotation script, but it didn’t work. I had it accepting input from clipboard - but for whatever reason, I was not able to get it to work.

That is why I was hoping I could find the files for any of the built in Services (not services from the script menu - I know where those are) Services that are system wide (context menu). I have not been able to locate them.

I look in the App package - but have not been able to find the. (like Take Note)

thanks!

Why not post the script here? Maybe a reader would have time to debug it. Without code, It’s impossible to say what’s wrong.

(Just curious: why does it matter to convert the template to a service? It’s a major undertaking to do, is not simple to do, and having an “annotation service”, IMO, is no better from a workflow perspective than using the as-is template and/or using the Take/Append note services and or customizing the template to fit needs.)

The bundled Services are compiled into the main application binary, not separate files, with references in …/Contents/Info.plist under the app bundle, e.g.:

[…]
<key>NSMenuItem</key>
<dict>
        <key>default</key>
        <string>DEVONthink Pro/Take Rich Note</string>
</dict>
<key>NSMessage</key>
<string>takeRichNoteService</string>
[…]