I did some Windows Script Host programming recently and I was pleasantly surprised by its power, features and flexibility. One thing that I couldn't accomplish was accessing the clipboard from WSH. Digging the internet I found some solutions like this one based on Internet Explorer Automation. There are several problems with this approach as you can read in my article about Internet Explorer Automation: What's wrong with Internet Explorer Automation?
My solution for scripting the clipboard content in WSH is a regular COM object created with VC++ and ATL.
Download full source code and compiled DLL: WSH_clipboard.zip
To install the COM object run register.bat
I found scripting the clipboard useful enough to add this feature to the next release of Twebst Web Automation Library.
Subscribe to:
Post Comments (Atom)
8 comments:
John G
(Russia, Ekaterinburg)
Excellent Object. Thanks
You are welcome!
Since the code highlighting isn't supported here, I thought I would link to a post I made at your codeproject.com entry:
http://www.codeproject.com/KB/clipboard/wshclipbrd.aspx?msg=3377847#xx3377847xx
Any advice or perhaps I'm doing something wrong (I'm new at coding so I wouldn't be surprised.) ;)
Cheers,
HI CC. thank you for sharing this. I am super-newbie at C(++/#) so you can quickly tell me... does your clipboard handle only teext, or can it handle any clipboard objects, such as a filesystem object (a file, folder, etc)?
Cheers,
TwoHawks
To Clarify... my intention is to create a simple script allows me to right-click on a file or folder "shortcut" and copy the target (not the .lnk). Then when the user navigates to the desired directory its a simple native-system right-click paste to copy the shortcut target object to there.
cheers, TwoHawks
The COM clipboard object I presented here can only handle text. In C++/C# you have specific API to work with clipboard.
http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard.aspx
Thank you.
Post a Comment