I’m constantly finding new ways to use my Kindle e-book reader. Lately, I’ve found a way to save eye strain and trees when reading long magazine articles posted online. Instead of reading them on my laptop, and making my eyes watery and tired, or printing them out on a zillion pieces of paper, wasting all that tree pulp, I send them to my Kindle and get the best of all possible worlds.
Initially, I’d copy the text of each article, open a blank file in TextEdit, paste in the article, attach that file to an email, and send the email to my unique Kindle address. Amazon converts the file to a Kindle-readable format and sends it to my Kindle. Score.
But Apple includes a free scripting program with OS X called, logically enough, AppleScript. After a lot — way too much in fact — of grunt work figuring out the correct scripting vocabulary and so on, I wrote a script that works. Basically, it’s an adaptation of this sample from MacOSXHints for saving web text with Apple’s own create email message script.
Now all I do is highlight the text of an article and click on the script. It does all the rest of the work, creating a file and emailing it to my Kindle. Here’s the script:
tell application “Safari”
set selecTxt to (do JavaScript “(getSelection())” in document 1)
set theurl to (get URL of document 1)
set pgTitl to (do JavaScript “document.title” in document 1)
end tell
set dat to (current date) as text
set clipFil to (path to desktop folder as text) & “ToKindle.txt”
try
close access file clipFil
end try
set filRef to open for access file clipFil with write permission
write (dat & return & (theurl) & return & (pgTitl) & return & “——————-“ & return & selecTxt & return & “~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~” & ¬
return & return) to filRef starting at eof
close access filRef
tell application “Mail”
set newMessage to make new outgoing message with properties {subject:”Convert”, content:”Please convert and send” & return & return}
tell newMessage
set visible to true
set sender to “you@youremail.com”
make new to recipient at end of to recipients with properties {address:”yourkindle@kindle.com”}
make new attachment with properties {file name:alias “LunarMod:Users:gravitate:Desktop:ToKindle.txt”} at after the last paragraph
end tell
end tell
One bit you will need to customize is the location of the file ToKindle.txt. As you can see, that’s listed in my script as “LunarMod:Users:gravitate:Desktop:ToKindle.txt”. You’ll need to change “LunarMod” to the name of your hard drive and “gravitate” to your logon name. And, of course, fill in the proper the email address you’re sending from and your Kindle’s special email address (which you can find on Amazon’s web site under the account settings of your Kindle if you don’t know it).
There are a couple of annoying limitations. I haven’t figured out a way to give the created file a unique name each time I run the script. So after the script runs, you have to delete the ToKindle.txt file from your desktop. If you don’t Applescript will append the article you want to read onto the article you read last time you ran the script.
Also, there’s little info about running Applescript with Firefox 3.0 so the script only runs with Safari. As always, I’m happy to hear suggested improvements or criticism in the comments.
Leave a Reply