Using VBScript to copy the output of the script to the Clipboard _vbs

Source: Internet
Author: User
Tags object model blank page
Ask:
Hey, scripting guy!. Is there a way to copy the script output to the clipboard?
--ZW, Marseilles, France
For:
Hello, ZW. If you don't mind using some crazy workaround, it's pretty easy to actually copy the script output to the Clipboard. First, you need to construct a string that contains the desired output. Then, create an instance of Internet Explorer and open a blank page in it. Next, take advantage of the built-in features of the Internet Explorer object model to copy the string to the Clipboard, and in particular, you can use the Clipboarddata.setdata method to implement this technique. The sample script that copies some data to the Clipboard is as follows:
Copy Code code as follows:

Strcopy = "This text has been copied to the Clipboard."
Set objIE = CreateObject ("Internetexplorer.application")
Objie.navigate ("About:blank")
ObjIE.document.parentwindow.clipboardData.SetData "Text", strcopy
Objie.quit
Run the script, then open Notepad, and then click Paste, and you should see the copied string.
By the way, all of this is happening behind the scenes, and Internet Explorer doesn't really appear on the screen. This is because, by default, any instance of IE created by scripting is hidden at run time unless you use the following statement to display it:
Objie.visible = True
For more information about Clipboarddata.setdata, see the DHTML reference documentation 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.