Clipboard.vbs |
Option Explicit
Dim oClipboard, oShell, strClipboardText
Set oClipboard = New clsClipboard
Set oShell = CreateObject("WScript.Shell")
' Clear the clipboard
oClipboard.Clear
oShell.Popup "oClipboard.Clear clears the clipboard.",5,"Clipboard:",64
' Set text to clipboard
oClipboard.PutText = "This text is set to the clipboard..."
oShell.Popup "oClipboard.PutText writes a string to the clipboard.",10,"Clipboard:",64
' Get text from clipboard
strClipboardText = oClipboard.GetText
oShell.Popup strClipboardText & vbCrLf & vbCrLf & _
"oClipboard.GetText retrieves a string from the clipboard" & vbCrLf & _
"and assinges them to a string.",10,"Clipboard:",64
wscript.quit
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'''''''''''''''''''''' Subs / Classes / Functions '''''''''''''''''''''''''''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Class clsClipboard
''''' This class is used for manupilting the Windows clipboard.
''''' Under some versions of windows you may be prompted with a UAC message box
''''' before continuing. For an original copy of the example file showing how to
''''' call this class and other interesting scripts goto www.RichSchreiber.com
Private oHTML
Private Sub Class_Initialize
Set oHTML = CreateObject("InternetExplorer.Application")
oHTML.Navigate ("about:blank")
End Sub
' Clear Clipboard
Public Sub Clear()
oHTML.Document.ParentWindow.ClipboardData.ClearData()
End Sub
' Get text from Clipboard
Public Property Get GetText()
GetText = oHTML.Document.ParentWindow.ClipboardData.GetData("Text")
End Property
' Set text to Clipboard
Public Property Let PutText(Value)
oHTML.Document.ParentWindow.ClipboardData.SetData "Text", Value
End Property
Private Sub Class_Terminate
oHTML.Quit
Set oHTML = Nothing
End Sub
End Class