Copy the Script output to the clipboard Using VBScript

Source: Internet
Author: User
Tags blank page

Q:
Hi, scripting guy! Is there a way to copy the Script output to the clipboard?
-- ZW, Marseilles, France
A:
Hello ZW. If you don't mind using some crazy solutions, it is quite easy to copy the Script output to the clipboard. First, you need to construct a string containing the desired output. Create an Internet Explorer instance and open a blank page. Next, use the built-in functions of the Internet Explorer Object Model to copy strings to the clipboard. In particular, you can use the clipboardData. setdata method to implement this technique. The following is an example script for copying data to the clipboard: CopyCodeThe Code is as follows: strcopy = "this text has been copied to the clipboard ."
Set objie = Createobject ("internetexplorer. application ")
Objie. navigate ("about: blank ")
Objie.doc ument. parentwindow. clipboardData. setdata "text", strcopy
Objie. Quit

Run the script, open notepad, and click paste. The copied string is displayed.
By the way, all this is happening behind the scenes, and Internet Explorer does not actually appear on the screen. This is because, by default, any ie instance created using the script is hidden at runtime, unless you use the following statement to display it:
Objie. Visible = true
For more information about clipboardData. setdata, see the DHTML reference document on msdn.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.