Skip to content

Instantly share code, notes, and snippets.

@paulera
Created August 17, 2017 07:38
Show Gist options
  • Save paulera/b9af6f44aa553b6063d928547c26eab9 to your computer and use it in GitHub Desktop.
Save paulera/b9af6f44aa553b6063d928547c26eab9 to your computer and use it in GitHub Desktop.
VBScript to save clipboard contents to a text file.
Option Explicit
' Gets clipboard's contents as pure text and saves it
' to the file set in filePath variable.
' author https://github.com/paulera
' see https://gist.github.com/paulera/b9af6f44aa553b6063d928547c26eab9
' File path to save clipboard contents
Dim filePath : filePath = "C:\clipboard.txt"
' Use the HTML parser to have access to the clipboard and get text content
Dim text : text = CreateObject("htmlfile").ParentWindow.ClipboardData.GetData("text")
' Create the file
Dim fileObj : Set fileObj = CreateObject("Scripting.FileSystemObject").CreateTextFile(filePath)
' Overwrite the text and close the file.
fileObj.Write(text)
fileObj.Close
@paulera
Copy link
Author

paulera commented Aug 17, 2017

Save this somewhere in your disk, create a shortcut to it in the desktop and assign a shortcut. Run it after doing [Ctrl+C].

@adfadasdf-cymklajkjsk
Copy link

Doesn't work. By the way, I am very new to vbscript so there could be reasons.

@paulera
Copy link
Author

paulera commented Oct 16, 2020

Doesn't work. By the way, I am very new to vbscript so there could be reasons.

Try changing the path on Line 9 to one where you have writing permissions.

@adfadasdf-cymklajkjsk
Copy link

By the way, do you have a script for pasting as well. All I need it to do is open notepad and paste whatever is on clipboard.

@paulera
Copy link
Author

paulera commented Oct 22, 2020

By the way, do you have a script for pasting as well. All I need it to do is to open notepad and paste whatever is on the clipboard.

Not really. Anyways, Line 12 shows how to read whatever is in the Clipboard and store in a text variable. You try making a script to open notepad, wait 100 milliseconds (just for notepad to load properly), then simulate a Ctrl+V:

I found some links with a quick search in case it helps:

Good luck

@adfadasdf-cymklajkjsk
Copy link

adfadasdf-cymklajkjsk commented Oct 25, 2020 via email

@paulera
Copy link
Author

paulera commented Oct 26, 2020

this might me very off topic but do you have a script that shutdowns computer if password is incorrect or if 10 seconds are over?

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment