VBS access to the Clipboard several methods summary _vbs

Source: Internet
Author: User
Copy Code code as follows:

Set IE = CreateObject ("Internetexplorer.application")
Ie. Navigate ("About:blank")
Set Clipboard = IE.document.parentWindow.clipboardData
' SetData set the contents of the Clipboard
Clipboard. SetData "Text", "forget, like a person's feeling"
' GetData get the contents of the Clipboard
WScript.Echo Clipboard. GetData ("text")
Ie. Quit

Practice has proved that a lot of code on the Internet is generally not good code. The SetData method is actually related to IE browser settings.

The default setting for IE8 is prompt, so a dialog box pops up when you run the script above, and if this is a disable, then the script cannot set the Clipboard contents (get unaffected).

This is not guaranteed code or a little bit of good, under Windows 7 can use Clip.exe to set the contents of the Clipboard, get word or use IE on the line.

CreateObject("WScript.") Shell "" | Clip ",0,False      

You can also set and get Clipboard contents with Word.Application

' Set the contents of the Clipboard
    CreateObject(' word.application 'False   
' Get the contents of the Clipboard
    CreateObject("Word.Application"WScript.Echo str   

The most amazing thing is to use the Microsoft Forms 2.0 Object Library.

  Set the contents of the Clipboard  Dim  form , TextBox  set  form  =  createobject< span> ( forms.form.1 )  Set  TextBox =  Form . Controls.Add ( "forms.textbox.1" ). Object  textbox.multiline =  True  textbox.text =  "Forget, like a person's feeling"  Textbox.selstart =  0 Span>textbox.sellength = textbox.textlength  textbox.copy         
' Get the contents of the Clipboard
 formCreateObject(the ' forms.form.1 'form. Controls.Add ("forms.textbox.1" EndIf       

Reference Links:

    1. [umu WSH Tutorial] (30) Accessing the Clipboard
    2. [umu WSH Tutorial] (32) Access to the Clipboard (2)

Original: http://demon.tw/programming/vbs-clipboard.html

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.