How to make an existing AppleScript file to work as a service?

Yes, Automator is the best option here. To create the service follow these steps:

  1. Open Automator and select Service:

    enter image description here

  2. Search 'applescript' and drag the action to the right pane:

    enter image description here

  3. Change Service receives selected text to Service receives no input so that it always appears in the Services menu:

    enter image description here

  4. Replace (* Your script goes here *) with:

    do shell script "/usr/bin/osascript /path/to/your/script.scpt"
    

    if you wish to execute your existing .scpt file. Note that osascript can't handle user interaction like displaying a dialog window:

    enter image description here

    To overcome this limitation either use this workaround or simply replace (* Your script goes here *) with the contents of your script.

  5. Save it:

    enter image description here

  6. If you wish, you can assign a shortcut to your new service. Select Services>Services Preferences in Finder (or any open application):

    enter image description here

  7. Assign a not so common shorcut:

    enter image description here

  8. Now your service is accessible from any application through the shortcut you assigned in the previous step:

    enter image description here

If you ever want to get rid of the service open ~/Library/Services, delete the service and empty the trash:

enter image description here


In the script, add an on run argument:

on run
    -- do whatever the script does
end run

Then you can use the Automator "Run Shell Script" action, with the osascript command:

osascript /path/to/script.scpt

osascript is a command which executes AppleScript in the shell. You need the lines in the script to allow the script to be executed outside AppleScript editor.


Perhaps you'd want to take a look at This Service, which allows you to "create Mac OS X services from any script."