Can python access windows clipboard

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Jun 21 05:36:58 EDT 2007


En Thu, 21 Jun 2007 05:59:06 -0300, MaHL <mhl1983 at gmail.com> escribió:

> 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?

Yes, using the pywin32 extensions that you can download from Sourceforge

py> from win32clipboard import *
py> OpenClipboard()
py> EmptyClipboard()
py> SetClipboardText("Hello from Python!")
11272196
py> CloseClipboard()

Ctrl-v: Hello from Python!

-- 
Gabriel Genellina




More information about the Python-list mailing list