Use clipboard from VBScript

后端 未结 15 1471
青春惊慌失措
青春惊慌失措 2020-11-29 06:36

I am looking for a method to place some text onto the clipboard with VBScript. The VBScript in question will be deployed as part of our login script. I would like to avoid

15条回答
  •  没有蜡笔的小新
    2020-11-29 07:07

    Here is Srikanth's method translated into vbs

    function SetClipBoard(sTxt)
        Set oIe = WScript.CreateObject("InternetExplorer.Application")
        oIe.silent = true
        oIe.Navigate("about:blank")
        do while oIe.ReadyState <> 4
            WScript.Sleep 20
        loop
    
        do while oIe.document.readyState <> "complete"
            WScript.Sleep 20
        loop
    
        oIe.document.body.innerHTML = ""
        set oTb = oIe.document.getElementById("txtArea")
        oTb.value = sTxt
        oTb.select
        set oTb = nothing
        oIe.ExecWB 12,0
        oIe.Quit
        Set oIe = nothing
    End function
    
    
    function GetClipBoard()
        set oIe = WScript.CreateObject("InternetExplorer.Application")
        oIe.silent = true
        oIe.Navigate("about:blank")
        do while oIe.ReadyState <> 4
            WScript.Sleep 20
        loop
    
        do while oIe.document.readyState <> "complete"
            WScript.Sleep 20
        loop 
    
        oIe.document.body.innerHTML = ""
        set oTb = oIe.document.getElementById("txtArea")
        oTb.focus   
        oIe.ExecWB 13,0
        GetClipBoard = oTb.value
        oTb.select
        set oTb = nothing
        oIe.Quit
        Set oIe = nothing
    End function
    

提交回复
热议问题