Back in August of 2007 I wrote an entry about Scripting the Clipboard Contents in WSH in which I addressed a means of using Internet Explorer automation for setting and retrieving the contents of the Windows clipboard. One of my readers, Adrian Dorache, made mention of that post while unveiling a COM object he has written to streamline the process. In return for his gracious inclusion, I wanted to offer him some exposure as well.
In case you missed my original post, you can find that here:
Adrian has produced a very simple ActiveX component that can set or retrieve the clipboard contents in just a couple of short lines. Here’s an example of how simple it is to retrieve the current contents of the clipboard as test.
Set objCBHelper = CreateObject("ClipboardHelper.ClipBoard") WScript.Echo objCBHelper.GetClipboardText
I personally tend to avoid the use of third-party controls in favor of native methods in order to maintain script compatibility across multiple systems and avoid the need for installing controls on every system that I wish to run my scripts on. However, if this isn’t a concern for you, this COM object provides a much cleaner method for scripting the Windows clipboard. Adrian also correctly mentions that the Internet Explorer method can raise errors in Windows Vista.
The compiled object as well as the source code are available at the link below.
I’d like to thank Adrian for mentioning my post and I urge you all to stop by and thank him for all of his hard work.[donotprint] [/donotprint] Please use the trackback link when linking to this post.