473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 18364
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

52
by: Dick Moores | last post by:
I need to figure out how to compute pi to base 12, to as many digits as possible. I found this reference, <http://mathworld.wolfram.com/Base.html>, but I really don't understand it well enough....
3
by: info | last post by:
After using clipboard functions in Excel controlled from Access VBA, Excel doesn't quit when I use the following ExcelApp.Quit Set ExcelApp = Nothing If I don't use the clipboard functions in...
11
by: Danny J. Lesandrini | last post by:
Has anyone else noticed this? I searched group archives and found nothing, but it's really starting to irritate me big time. Here's the steps to reproduce the problem: Copy something to the...
5
by: MLH | last post by:
I had a form (Form12) with a code error in it. I knew it was there. I even planned on fixing it (someday). I needed a comprehensive test of all my code so I clicked Debug, Compile All Modules. My...
6
by: =?Utf-8?B?TWljaGFlbCAwMw==?= | last post by:
I need to disable the clipboard function in Windows XP. We are having a problem with users using CTRL+C in one program, then using CTRL+V in another. Specifically, they type their password into...
5
by: Steve Richter | last post by:
I am using the window.clipboardData.getData javascript method to copy from the clipboard. <SCRIPT LANGUAGE="JavaScript"> function ShowClipBoard() { var data =...
1
by: Jim Langston | last post by:
Windows. Situation: Using a Python program called OpenRPG. I have a program that displays form data (a character sheet) in C++. I am able in the C++ program to build a string and copy it into the...
8
by: Irene | last post by:
Hi, I have an MS Access Database with 1 Table containing about 2 million records in Unicode (diferent languages). I would like to export the Table to a Text file (CSV, Tab, etc.) Access...
4
by: OldBirdman | last post by:
I'm working within the Access window because my program isn't quite completed. Some of my forms almost fill this space, which is as large as my monitor will support. If the Office Clipboard tries...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.