Created
April 5, 2018 01:56
-
-
Save LeetCodes/08449c8126fbeae9c46d821ee58f7cab to your computer and use it in GitHub Desktop.
Set, get, and clear ClipBoard text in VBScript.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Function QuickClip(input) | |
| '@description: A quick way to set and get your clipboard. | |
| '@author: Jeremy England (SimplyCoded) | |
| If IsNull(input) Then | |
| QuickClip = CreateObject("HTMLFile").parentWindow.clipboardData.getData("Text") | |
| If IsNull(QuickClip) Then QuickClip = "" | |
| Else | |
| CreateObject("WScript.Shell").Run _ | |
| "mshta.exe javascript:eval(""document.parentWindow.clipboardData.setData('text','" _ | |
| & Replace(Replace(input, "'", "\\u0027"), """", "\\u0022") & "');window.close()"")", _ | |
| 0,True | |
| End If | |
| End Function |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'CLEAR | |
| QuickClip("") | |
| 'SET | |
| QuickClip("Hello World!") | |
| 'GET | |
| Result = QuickClip(Null) | |
| '========================================================================================== | |
| Function QuickClip(input) | |
| '@description: A quick way to set and get your clipboard. | |
| '@author: Jeremy England (SimplyCoded) | |
| If IsNull(input) Then | |
| QuickClip = CreateObject("HTMLFile").parentWindow.clipboardData.getData("Text") | |
| If IsNull(QuickClip) Then QuickClip = "" | |
| Else | |
| CreateObject("WScript.Shell").Run _ | |
| "mshta.exe javascript:eval(""document.parentWindow.clipboardData.setData('text','" _ | |
| & Replace(Replace(input, "'", "\\u0027"), """", "\\u0022") & "');window.close()"")", _ | |
| 0,True | |
| End If | |
| End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment