469,366 Members | 2,286 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

Can python access windows clipboard

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?

Thanks very much!

Jun 21 '07 #1
4 18106
Ant
On Jun 21, 9:59 am, MaHL <mhl1...@gmail.comwrote:
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/
Jun 21 '07 #2
En Thu, 21 Jun 2007 05:59:06 -0300, MaHL <mh*****@gmail.comescribió:
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

pyfrom win32clipboard import *
pyOpenClipboard()
pyEmptyClipboard()
pySetClipboardText("Hello from Python!")
11272196
pyCloseClipboard()

Ctrl-v: Hello from Python!

--
Gabriel Genellina

Jun 21 '07 #3
MaHL 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?
If you're using Cygwin Python you can just open /dev/clipboard and work
on that.
--
Michael Hoffman
Jun 21 '07 #4
thanks a lot!

Jun 21 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

52 posts views Thread by Dick Moores | last post: by
11 posts views Thread by Danny J. Lesandrini | last post: by
6 posts views Thread by =?Utf-8?B?TWljaGFlbCAwMw==?= | last post: by
5 posts views Thread by Steve Richter | last post: by
1 post views Thread by Jim Langston | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.