'设置剪切板的内容
Dim Form, TextBox
Set Form = CreateObject"Forms.Form.1")
Set TextBox = Form.Controls.Add"Forms.TextBox.1").Object
TextBox.MultiLine = True
TextBox.Text = "忘记了,喜欢一个人的感觉"
TextBox.SelStart = 0
TextBox.SelLength = TextBox.TextLength
TextBox.Copy
'获取剪切板的内容
Dim Form, TextBox
Set Form = CreateObject"Forms.Form.1")
Set TextBox = Form.Controls.Add"Forms.TextBox.1").Object
TextBox.MultiLine = True
If TextBox.CanPaste Then
TextBox.Paste
WScript.Echo TextBox.Text
End If
方式一:
Sub SetClipboardTextText) ‘写入信息到剪切板
Set objIE = CreateObject”InternetExplorer.Application”)
objIE.Navigate”about:blank”)
objIE.Document.ParentWindow.ClipboardData.SetData “text”, Text
objIE.Quit
End Sub
Function GetClipboardText) ‘剪切读取板信息
Set objIE = CreateObject”InternetExplorer.Application”)
objIE.Navigate”about:blank”)
GetClipboardText = objIE.Document.ParentWindow.ClipboardData.GetData”text”)
objIE.Quit
End Function
方式二:
Sub SetClipboardTextText) ‘写入信息到剪切板
Set wsShell = CreateObject”WScript.Shell”)
wsShell.Run “mshta vbscript:ClipboardData.SetData”&chr34)&”text”&chr34)&”,” &Chr34)& Text &Chr34)& “)close)”,0,True
End Sub
Function GetClipboardText) ‘剪切读取板信息
Set objHTML=CreateObject”htmlfile”) ‘xmlfile、mhtmlfile也可以
GetClipboardText = objHTML.ParentWindow.ClipboardData.GetData”text”)
End Function
注:以上方式二中的写入到剪切板也可写成:wsShell.Run “mshta vbscript:ClipboardData.SetData””text””,”&Chr34)& Text &Chr34)& “)close)”,0,True 即VBS连着写的两个双引号转义为一个引号,这样可减少使用Chr34)来替代;