Using the clipboard in WSH

How to get the text from the clipboard

set objIE = CreateObject("InternetExplorer.Application")
objIE.Navigate("about:blank")
textFromClipboard = objIE.document.parentwindow.clipboardData.GetData("text")
objIE.Quit
WScript.Echo textFromClipboard

How to put the text into clipboard

textIntoClipboard = "Some text" & VbCrLf & "Some more text"
 
Set objIE = WScript.CreateObject("InternetExplorer.Application")
objIE.Navigate "about:blank"
Do Until objIE.ReadyState = 4
    WScript.Sleep 100
Loop
 
objIE.document.ParentWindow.ClipboardData.SetData "text", textIntoClipboard
objIE.Quit

The detailed explanation could be found here.

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>