Editor's note:
While this question is specifically about copying a file reference to the clipboard, its generic title led to answers about how to copy / get text.
作为 Windows 上的 Emacs 用户,经常在邮件中附加文件,我一直在寻找一个实用程序来复制文件(不是它的内容)到剪贴板,就像 Windows 资源管理器右键单击/复制一样)。
我刚刚发现this https://stackoverflow.com/a/17354470/18573就在这里,它在一个小程序中使用 System.Windows.Forms.Clipboard` 来做到这一点。但它是用 C# 编写的,我无法立即访问编译器。所以我想知道这是否可以做到以及如何做到。
我看到了一些参考资料,例如this https://stackoverflow.com/a/174725/18573在 VBScripting 中无法访问剪贴板,但在 msdn 中VB 的文档,所以我冒着这个问题的风险。
我以前从未编写过 VBScript,但在询问之前我确实尝试了一些事情,首先运行粘贴“Hello world”的副本,然后运行各种组合CreateObject
etc.
更新:我需要打电话Clipboard.SetFileDropList http://msdn.microsoft.com/en-us/library/system.windows.forms.clipboard.setfiledroplist.aspx,所以我认为我不能使用ClipboardData
正如答案所建议的,它没有这种方法。
访客更新
我最终使用的解决方案是编译C#
就其本身而言,我并不知道我已经有了一个编译器。
为访客提供的另一项更新
https://stackoverflow.com/a/29963268/18573 https://stackoverflow.com/a/29963268/18573就是我现在正在用的,非常满意。
您可以使用 html 对象来检索剪贴板的内容:
' Get clipboard text
Set objHTML = CreateObject("htmlfile")
text = objHTML.ParentWindow.ClipboardData.GetData("text")
EDIT:我使用此代码片段将文本放回剪贴板,但它需要第三方软件;一个独立的可执行文件“clip.exe”,可以在 Windows 2003 Server 上或仅在internet http://www.petri.co.il/software/clip.zip:
' Do something with the text
text = replace(text, "you ", "you and your dog ")
' Put it back to the clipboard
Set WshShell = CreateObject("WScript.Shell")
Set oExec = WshShell.Exec("clip")
Set oIn = oExec.stdIn
oIn.WriteLine text
oIn.Close
(是的,这有点 hackerdyhack)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)