10.6: Create new AppleScript document Service

Mar 24, '11 07:30:00AM

Contributed by: Maxikubik

Snow Leopard only hintI got tired of copy-pasting AppleScripts I found online into the AppleScript Editor, so I made a simple Automator Service to do it for me.

Just launch Automator, choose new service (that receives text), add the Run AppleScript action and replace the script body with this:

on run {input, parameters}
  
  tell application "AppleScript Editor"
    activate
    if contents of document 1 is "" then
      set contents of document 1 to (input as string)
    else
      make new document with properties {contents:(input as string)}
    end if
  end tell
  
  return input
end run
Save it as 'New AppleScript Document with selection' or whatever name you prefer.

Activate it under System Preferences » Keyboard » Keyboard Shortcuts » Services » Text » "New AppleScript Document with selection" if it does not show up in the contextual menu when you have selected some text.

[crarko adds: I tested this, and it works as described. If you have the Developer Tools installed it has a Service called Development » Make New AppleScript that does the same thing. It is disable by default so you'd need to turn it on using the Keyboard System Pref as described above. This hint provides a customizable alternative.]

Comments (10)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20110323052549880