I have created an Applescript that will favorite the current track. I saved it as a service, and gave it a shortcut.

on run {input, parameters}

    tell application "iTunes"
        set loved of current track to true
    end tell

    return input
end run

enter image description here

However, it only works when the iTunes window is in focus. If I press the shortcut when iTunes is not the window in focus, I don't even see the Services gear appear in the system tray, indicating that the script is not running.

How do I make the script run regardless of what window has focus?

  • 1
    I'd guess you need to use a shortcut that isn't common in other apps. Cmd/Shift/F, for instance is 'All My Files' in Finder. – Tetsujin Sep 10 '16 at 17:40
  • Tetsujin makes a very important point however you have omitted information in your post surrounding the setting used in your Automator Service. Yes, you included the AppleScript code but not the Service Settings, e.g.: Service receives selected ..., etc. Probably set it to "no input" and "any application", however you should always include complete information in cases such as this. That said, if set to those settings then Tetsujin's comment is on favorite track (pun intended). – user3439894 Sep 10 '16 at 18:11

It was a set up as a service that takes no input and runs in any application.

But that wasn't the problem. Indeed, @Tetsujin seems to be correct. It was a conflict with a keyboard shortcut in the application that had keyboard focus. I used a different shortcut and it works.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .