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:
- [umu WSH Tutorial] (30) Accessing the Clipboard
- [umu WSH Tutorial] (32) Access to the Clipboard (2)
Original: http://demon.tw/programming/vbs-clipboard.html