A Clipboard Control for WSH

March 23rd, 2009

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:

Scripting the Clipboard Contents in WSH

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.

http://codecentrix.blogspot.com/2009/01/wsh-and-clipboard-access.html

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.

Related Posts:

Add to Technorati Favorites

2 Responses to “A Clipboard Control for WSH”

  1. Adrian Dorache Says:

    Thank you very much for your kind words.

  2. Nilpo Says:

    You’re most welcome.

Leave a Reply

.htaccess Apache article articles by Nilpo ASP ASP Free automation clipboard copy desktop Dev Shed docx Internet Explorer message box Microsoft PHP registry remove script scripting text tutorial tweak tweets Twitter UAC updates User Account Control VBS VBScript vista volume Windows Windows 7 Windows Guru Windows Script Windows Script Host Windows Scripting Windows Vista Windows XP Word WScript wscript.exe WSH XP