« 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
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.



Hello, awesome graphics up there!...
Could you please help me with some apple script?

... I am using automator and the "run apple script command"

Could you please tell me the separate apple scripts for:

-Copy selected text to clipboard

-Paste text from clipboard

-Pressing Keys


Your help will be very very much appreciated,

Thank you very much for your attention and time

-Sincerely, Pastor Estrada


Pastor Estrada,

It sounds like you want some basic help on how to invoke copying, pasting, and pressing keys within an AppleScript. If, for example, you want to press Command-C (for copy) within AppleScript, use

	tell application "System Events"
		key code 8 using {command down} --Command-C
	end tell

You will need to know which key code to use, of course, and a utility such as Many Tricks' "Key Codes" will help you figure out what those codes are.

If you have further questions about AppleScript, I suggest you head over to


and ask your questions there. Lots of helpful and knowledgeable folks there.

Good luck,

Johnnie Wilcox