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
Notes
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. ↩