@tom: Thanks for this script. I have used a modified version to solve a problem with the clipboard management of KM and Adobes Creative apps. See this post.
For more information, see the wiki Searching the Forum for Answers section.