Skip to content

Instantly share code, notes, and snippets.

@LeetCodes
Created April 5, 2018 01:56
Show Gist options
  • Select an option

  • Save LeetCodes/08449c8126fbeae9c46d821ee58f7cab to your computer and use it in GitHub Desktop.

Select an option

Save LeetCodes/08449c8126fbeae9c46d821ee58f7cab to your computer and use it in GitHub Desktop.
Set, get, and clear ClipBoard text in VBScript.
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
'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