Clearing the clipboard using VBScript

随声附和 提交于 2019-12-21 17:48:17

问题


How can the clipboard be cleared using VBScript on Win32?


回答1:


It can not be done directly, but you can let an application do the work. This will clear the clipboard, using the command-line tool clip:

Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe /c echo. >NUL  | clip", 0, True

Another way is to use applications that have a COM interface and that can manipulate the clipboard. E.g. Microsoft Word and Internet Explorer.

This will work, using Internet Explorer, but may throw a user dialog:

Set slaveApplication = CreateObject("InternetExplorer.Application")
slaveApplication.Navigate("about:blank")
slaveApplication.document.parentwindow.clipboardData.SetData "text", ""
slaveApplication.Quit


来源:https://stackoverflow.com/questions/2396109/clearing-the-clipboard-using-vbscript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!