Download PasteToFile.vbs or PasteToFile.zip
'----------------------------------------------------------------------------------------------------------
'title: PasteToFile v1.0
'author: Rick Companje
'email: PasteToFile@companje.nl
'website: www.companje.nl
'date: 29 June 2005
'copyright: Use it, spread it, change it and please send me an email if you like it.
'----------------------------------------------------------------------------------------------------------
'description: This VBScript saves the Windows clipboard text data to a textfile by pressing a shortcut key
'----------------------------------------------------------------------------------------------------------
'usage
' 1. Place the .vbs file in 'My Documents' (or in a subfolder)
' 2. Create a shortcut to the script on the desktop (important if you want to use a shortcut key)
' 3. Set a shortcut key (ie. Ctrl+Shift+V)
' 4. Select some text and copy it to clipboard
' 5. Paste it to file by pressing your shortcut key
' 6. Use default filename (PasteToFile-2005-06-29.txt) or choose another name ('Cancel' aborts the script)
' 7. Set showDialogs to false if you don't want the inputbox and the feedback
'----------------------------------------------------------------------------------------------------------
'declare vars and consts
Dim sDate, sTime, sLongDate, sFileName, sDefaultFileName, fso, f, html, sClipboardData, sMessage
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const showDialogs = true
'date stuff
sDate = year(now) & "-" & right("0" & month(now), 2) & "-" & right("0" & day(now), 2)
sLongDate = formatDateTime(now, vbLongDate)
sTime = right("0" & hour(now), 2) & ":" & right("0" & minute(now), 2) & ":" & right("0" & second(now), 2)
'filename
sFileName = "PasteToFile-" & sDate & ".txt" 'change this default filename and path if you want
if showDialogs then sFileName = inputBox("Enter filename for saving clipboard data: ", "PasteToFile", sFileName)
if not isEmpty(sFileName) then 'abort when user chooses Cancel at the inputBox
'add .txt extension to filename if needed
if lcase(right(sFileName,4))<>".txt" then sFileName = sFileName & ".txt"
'create objects
set fso = CreateObject("Scripting.FileSystemObject")
set f = fso.OpenTextFile(sFileName, ForAppending, true)
set html = CreateObject("htmlfile")
'get text data from clipboard
sClipboardData = html.ParentWindow.ClipboardData.GetData("text")
'append clipboard data to file
f.write "Added on " & sLongDate & " at " & sTime & vbCrlf
f.write "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" & vbCrLf
f.write sClipboardData & vbCrlf
f.write "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" & vbCrLf
f.write vbCrLf
f.close
'show messagebox with summary and filename
sMessage = left(sClipboardData, 200) & "..."
sMessage = replace(replace(sMessage,vbTab," ")," "," ")
sMessage = "Added to """ & sFileName & """" & vbCrLf & vbCrlf & sMessage
if showDialogs then msgBox sMessage, vbOkOnly, "PasteToFile"
'clear objects
set fso = nothing
set f = nothing
set html = nothing
end if