PDA

View Full Version : Creating a text file with clipboard data



ylaviolette
October 15th, 2009, 01:18 PM
I'm looking for ideas on the simplest way to create a .txt file containing whatever is in the clipboard? could this be done through a script as i'd like to avoid using mouse, window or keyboard emulation.

IE, if clipboard contents is "this is a test", I'd like a script that would create
C:\test.txt
which would contain a single line: this is a test

Any help is greatly appreciated,

ylaviolette
October 21st, 2009, 10:18 AM
anyone? Thx

Rob H
October 21st, 2009, 05:17 PM
Well, you can get the text that is in the clipboard using win.ClipboardGetText()

So all you need to do then is write that to a file e.g.


local text = win.ClipboardGetText()
local handle = io.open([[c:\test.txt]], "w+")
handle:write(text)
handle:close()

ylaviolette
October 22nd, 2009, 09:00 PM
Works great, thank you!