2015-02-24 118 views
1

我已經放在一起的腳本,將我的所需文本複製到我的剪貼板,所以我可以粘貼內容在任何文本字段。VBScript,文本到剪貼板粘貼到任何字段

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 

所需電流的步驟是

  1. 運行腳本
  2. 導航到期望的位置
  3. 粘貼內容。

我試圖讓這個我可以在需要的位置 1.按Ctrl + Alt + F1(或任何組合)使用熱鍵來獲得文本到剪貼板粘貼

+0

是[這個答案]( http://stackoverflow.com/a/13371767/3898606)到以前的問題,你正在尋找的東西? – 2015-02-24 13:25:09

回答

1

下面是一個腳本閱讀剪貼板,只需將其更改爲複製。

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 

當使用IE作爲對象時,您必須導航到本地文件以關閉安全性。

桌面或「開始」菜單上的快捷方式可以在其屬性中分配熱鍵。這將啓動快捷方式,或者如果已經開始,則切換到該窗口。

+0

非常感謝,解決了我所有的問題 – Lowell 2015-03-04 03:19:01

0

要設置剪貼板的值,你可以使用這個子:

Sub SetClipboard(val) 
    Set oExcel = CreateObject("Excel.Application") 
    Set book = oExcel.Workbooks.Add() 
    Set sheet = book.Sheets("Sheet1") 
    sheet.Cells(1.1).Value = val 
    sheet.Cells(1,1).Copy 
    book.Close False 
    Set oExcel = Nothing 
End Sub 

要獲取剪貼板的值,你可以使用這個子:

Sub GetClipboard() 
    Set oExcel = CreateObject("Excel.Application") 
    Set book = oExcel.Workbooks.Add() 
    Set sheet = book.Sheets("Sheet1") 
    sheet.Paste 
    ValueInClipboard = sheet.Cells(1.1).Value 
    book.Close False 
    Set oExcel = Nothing 
    WScript.StdOut.Write ValueInClipboard 
End Sub 
相關問題