Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I have a simple AppleScript that works exactly as expected when run on its own, ether as an app, directly from within ScriptDebugger or Script Editor, or as an element of an Automation from within Automator:

enter image description here

However, when I attempt to run this Automation as a Service, for example by saving it as a Service and running it from the Services menu

enter image description here

nothing happens. The Service fails to run whether I use a "Run AppleScript" action in Automator, or create an application from the script, and use a Launch Application action.

Why won't my AppleScript run as a Service, when it runs perfectly in all other circumstances?

share|improve this question
    
Works for me. Have you renamed the TextWrangler application? –  ghoppe Aug 1 '12 at 20:45
    
PS. The Services menu isn't a great place for this sort of thing, imho. If you want to assign shortcuts to Applescripts, you might be interested in FastScripts –  ghoppe Aug 1 '12 at 20:52
    
@ghoppe: Why is it not a great place? –  raxacoricofallapatorius Aug 1 '12 at 20:55
1  
The Services menu is intended for context-aware processing of text, files, pictures, etc. While it's possible to shoehorn global "run anywhere" scripts that take no input in there, to me it makes more sense to keep those in the global scripts menu. I like to keep my Services menu lean so that it's more useful. –  ghoppe Aug 1 '12 at 21:01
1  
@raxacoricofallapatorius There's a bug where the shortcuts for services don't always work at first until the service has been selected once from the menu bar. Services with global shortcuts cannot be run when the frontmost application doesn't have a services menu. Editing scripts in Automator can be a pain. Services aren't as easy to share as normal scripts. –  Lri Aug 1 '12 at 21:02

1 Answer 1

up vote 1 down vote accepted

This is weird, but I have seen at least three people on Apple Support Communities who had this problem when a of process "x" and a tell application "System Events" to are on the same line.

Try this.

on run {input, parameters}
  tell application "System Events"
      tell process "TextWrangler" to set visible to not visible
  end tell
end run
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.