Save Selection Serviceanoved.net logo

The Save Selection service allows you to immediately save the selected text in any application. When you invoke the service you’ll be asked where to save the selection. That’s it! No need to copy and paste into a separate text editor.

Download Save Selection Service 1.0 (33k)

The service file goes in ~/Library/Services/ and is invoked from the Services submenu of the application menu. Here is the AppleScript source code:

on process(_selection)
 tell application "System Events" to set _appname to the name of every process whose frontmost is true
 tell application (_appname as string) to set _file to choose file name with prompt "Save the selected text as:" default name "Selection.txt"
 set _fp to open for access _file with write permission
 write _selection to _fp
 close access _fp
end process

This service made with ThisService.

Posted on Sunday, May 20, 2007 at 11:06 PM

4 Comment

  1. Posted by Anonymous Anonymous on 22/9/07 11:25 PM:  

    Hey, almost what i needed! How can i make it to save as PDF?

  2. Posted by Blogger Jim on 24/9/07 6:54 PM:  

    Since the script accesses the selection through ThisService, which provides it to the script as plain text, I don't think it would be possible to save it as a PDF with the same formatting you seen on the screen.

    Would a screenshot of a selected area suffice? (See System Preferences->Keyboard & Mouse->Keyboard Shortcuts->Screen Shots.)

  3. Posted by Blogger Jean on 13/11/07 1:17 AM:  

    I select text in a safari window and I choose save selection service but no save window comes up and no file was made.

  4. Posted by Blogger Jim on 13/11/07 4:40 PM:  

    Thanks for the report, Jean. I have Mac OS X 10.4.10 and Safari 3.0.3 (it is a "beta" version). I don't know whether the service works with other versions; perhaps not.

    I do know that ThisService isn't really intended for interactive scripts. I am aware of some similar quirks, so it is quite possible you have discovered another.

    Anyway, I'm sorry it doesn't work. I'll post more information here if I ever figure out a solution.

Post a Comment