Keyboard shortcut for AppleScript works only when preferences window is open
As I mentioned in my comment to wch1zpink's answer "Making sure the Service's settings are correct and the shortcut key sequence is not in use by another is the first step" and mentioned afterwards by jackjr300 in his comment. Changing the keyboard shortcut to one that is not used by anything else in the system or any application (that is if 'Services receives no input in any application' is set), works for me, whether or not System Preferences is open, when using the code, as is, in the OP and a non-conflicting key sequence.

There also is no need to have any applications set in System Preferences > Security &amp; Privacy > Privacy > Accessibility for this particular use case, whether running from Automator or when using a non-conflicting keyboard shortcut in System Preferences > Keyboard > Shortcuts > Services > (Name You Gave The Service).

To resolve your issue, you must use a keyboard shortcut that is not already assigned elsewhere in the system and or any applications.

You might have to use a three or four key sequence as there are very few, if any, two key combos that aren't already in use.



On a side note, return input is not at all needed in the code in this particular use case.