Search code examples
vbscriptclipboardcopy-paste

VBScript, Text to Clipboard to Paste in Any Field


I have put together a script that will copy my desired text into my clipboard so I can paste content in any text field.

Dim string 
String = "This Is A script that allows me to copy text contained withing these quotes directly into my clipboard. Which yes is plenty fast as it is when compared to finding file, opening file, selecting desired content, copy content, and select location to paste content."
Set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "cmd.exe /c echo " & String & " | clip", 0, TRUE

Current steps required is

  1. run script
  2. navigate to desired location
  3. paste content.

I am trying to make it so that I can use a hotkey at desired location 1. Ctrl + Alt + F1 (Or any combo) to get Text to Clipboard to Paste


Solution

  • Here's a script for reading the clipboard, Just change it to copy.

    Sub Clip
        Set ie = CreateObject("InternetExplorer.Application") 
        ie.Visible = 0
        ie.Navigate2 FilterPath & "Filter.html"
        Do 
            wscript.sleep 100
        Loop until ie.document.readystate = "complete"  
        txt=ie.document.parentwindow.clipboardData.GetData("TEXT")
        ie.quit
        If IsNull(txt) = true then 
            outp.writeline "No text on clipboard"
        else
            outp.writeline txt
        End If
    End Sub
    

    When using IE as a object you must navigate to a local file to turn off security.

    A shortcut on the Desktop or on the Start menu can have a hotkey assigned in it's properties. This will start the shortcut, or if already started, switch to that window.