Can python access windows clipboard

Ant antroy at gmail.com
Thu Jun 21 11:23:14 CEST 2007


On Jun 21, 9:59 am, MaHL <mhl1... at gmail.com> wrote:
> Can I use python to copy something(like a string) to the clipboard, so
> that I can paste it somewhere else. Is there a way to do this?

The following requires Mark Hammond's win32all package (http://
sourceforge.net/projects/pywin32/):

import win32clipboard, win32con, random

text = "Some text to stick on the clipboard"

win32clipboard.OpenClipboard()
win32clipboard.SetClipboardData(win32con.CF_TEXT, text)
win32clipboard.CloseClipboard()

--
Ant...

http://antroy.blogspot.com/





More information about the Python-list mailing list