MacOS – Automator Service to insert text only available when text is selected

applescriptautomatormacosservices

I'm trying to make an Automator Service to insert the current date. I have one that works but it is only available in the Services menu when text is selected. I need it to be available when there is no text selected.

Here is the Automator Services script:

Automator Script to insert current date

The application I'm trying to use the service with is TextEdit. I'm seeing the same behavior in other applications like TextMate and Pages: few or no entries in the Services menu until I select some text, then lots of Services available.

Perhaps there is some way to do this with AppleScript, like getting the text onto the clipboard and sending a "command-V" to the application. But I would still need the AppleScript to be available in the Services menu somehow.

Best Answer

I found the answer here:

https://superuser.com/questions/589184/finder-not-enabling-use-of-services-when-changing-service-receives-selected-in

OS X sometimes ignores changes to services after they've been saved in Automator, possibly due to caching. So if the service started out as a text service, chances are your changes aren't getting picked up. To circumvent this problem, select File ยป Duplicate in Automator and save the service under a new name, and try again. Then delete the original service from ~/Library/Services.

(Answer is by Daniel Beck)

I duplicated my Service script (in Automator) as suggested above and now it shows up in the Services menu without needing to select text. I suspect when I first created the script that I had "Service receives text input" selected, and then I changed it later. Note that also checking "Output replaces selected text" should not be changed after first saving the Service.