« Convert RTF Clipboard Contents to Plain Text | Main | Back to Business »

Paste Clipboard Contents as Plain Text: An AppleScript

The MacOSXHints community has responded to the script I provided in my last entry with two excellent observations.1 First, it doesn't make much sense just to transform the contents of the clipboard. Better would be to paste the transformed contents. Second, my script did not preserve Unicode text, a serious shortcoming for non-English character sets.

The following addresses both issues. I hope you find it useful.2

end of article
Notes
1 They also demoted the ranking of my hint from 4.5 to 3.5. Suckers.
2 Line 7, key code 48 using {command down}, and Line 8, key code 9 using {command down}, are respectively Command-Tab and Command-V, OS X keyboard shortcuts codes for switching to the previous program and pasting the contents of the clipboard. Switching programs is necessary because invoking the AppleScript causes the program from which the Applescript is invoked to lose focus. To discover the corresponding Unicode key codes for any key, one can use the freeware Ukelele.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)