473,581 Members | 2,209 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 18376
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. SetClipboardDat a(win32con.CF_T EXT, 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 ()
pyEmptyClipboar d()
pySetClipboardT ext("Hello from Python!")
11272196
pyCloseClipboar d()

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
5856
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. Could someone show me how to do what I need? Thanks, Dick Moores rdm@rcblue.com
3
3433
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 my Access code, Excel is terminated properly. I have seen discussions on this subject by can't find the answer to my
11
2204
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 clipboard (eg code from a web page) Open Microsoft Access MDB file Open any module Press Ctl-V to insert text Voilia, the text is gone. Opening...
5
1617
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 standard modules were all good but the compilation test halted in a Class Module on Form12 due to the error. OK, I thought, don't really wanna screw...
6
17778
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 notepad, copy it to the clipboard, then paste it in another program. The other program runs on Windows XP. Obviously, the correct answer is to have...
5
2756
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 = window.clipboardData.getData("text") ; alert( data ) ; }
1
2320
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 clipboard, then paste it into the input in the running Python program. I would like to somehow automate this, that is, have the python instance...
8
11072
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 dows only export about 65,000 at 1 time. Almost an imposible job.
4
2178
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 to exceed 12 items, the Clipboard Toolbar is added to the other toolbars at the top of the Access Window as a new row, and I get a message that the...
0
7868
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
8149
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8304
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7899
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8175
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3827
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1403
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1138
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.