How can I automate running a Wordservice function?

I’d like to assign “Remove line endings” to a function key … or a macro … or an Applescript … or an Automator workflow. Anything to avoid having to open the App menu, click on Services, then click on Format, then click on Remove Line Endings.

I’d like to make Remove Line Endings a quick and easy one-click operation. Any ideas how to do this?

There’s probably far better ways of doing it, but the following script should click the Services menu item for you. You need to save it as a script from Script Editor and then assign it to a keyboard shortcut in Quicksilver (using the Triggers setup) or similar launcher application. It’ll only work for DT, and only on the currently selected text. It’s a quick and dirty solution but works for me.

tell application “DEVONthink Pro” to activate
tell application “System Events”
tell process “DEVONthink Pro”
tell menu bar 1
tell menu bar item “DEVONthink Pro”
tell menu “DEVONthink Pro”
tell menu item “Services”
tell menu “Services”
tell menu item “Format”
tell menu “Format”
click menu item “Remove Line Endings”
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell

I should probably note that the above script will only function as expected if you have the ‘Remove Line Endings’ service in the default location, that is: Services>Format>Remove Line Endings

This is a long-running complaint of mine. I even emailed Jobs about it a couple years ago. I don’t know how Services are used on a programming level (I’ve never gotten that far with Cocoa), but if DTP 2 included some kind of AppleScript way of calling a particular service on passed text, well, I’d kiss the developers.

solved this by using QuicKeys, a macro program. Among other things, it allows you to use Menu actions as part of a macro, so it was fairly easy. Now, with one keystroke, it selects an entire paragraph, then drills down through the Services menu to remove line endings.