473,387 Members | 3,810 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,387 software developers and data experts.

Using PythonWin32 to copy text to Windoze Clipboard for Unix-style random .sig rotator?

Can you tell I miss Unix?

I want to write a Python script that, when launched, will choose a
random .sig (from a list of about 30 cool ones I've devised), and store
the .sig text in the Windows Clipboard, so I can then paste it into any
Windows application.

This way, it'll work for Outlook e-mails, Yahoo, Gmail, etc.

Also, could I use Python to programmatically set key combos to do
certain things?

Should I buy the Python on Win32 book? Are all my answers there? Or is
there a good PyWin32 FAQ where all (that I'm interested in with this
particular e-mail) will be revealed?

Spammity-spam, y'all.

Thanks.

Dana

Apr 6 '06 #1
1 1750
da*****@yahoo.com wrote:
Can you tell I miss Unix?
by your early-nineties spelling of Windows ?
I want to write a Python script that, when launched, will choose a
random .sig (from a list of about 30 cool ones I've devised), and store
the .sig text in the Windows Clipboard, so I can then paste it into any
Windows application.


since most Python distributions comes with Tkinter, you can use Tkinter's
clipboard interface. unfortunately (at least for this use case), Tkinter re-
moves things it has added to the clipboard when the program terminates,
so you have to make sure that the program is still running when you need
the text.

here's a fortune generator that keeps posting important stuff to the clip-
board at random intervals:

import Tkinter
import random, time

# get some phrases
import StringIO, sys
stdout = sys.stdout
try:
sys.stdout = StringIO.StringIO()
import this
FORTUNES = sys.stdout.getvalue().split("\n")[2:]
finally:
sys.stdout = stdout

# create an invisible (well, not really) window
root = Tkinter.Tk()
root.withdraw()

def refresh():
fortune = random.choice(FORTUNES)
root.clipboard_clear()
root.clipboard_append(fortune)
root.after(random.randint(100, 1000), refresh)

refresh()

root.mainloop()

(since this will make it impossible to use the clipboard for anything else, you
might wish to use a button instead of a timer to update the clipboard...)

</F>

Apr 6 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: tabonni | last post by:
Hello All I am creating an ASP page. There are a list of filename and checkbox next to it. When user checked all the documents they want and click ADD TO CLIPBOARD button. All filepaths will be...
4
by: Risto Heinonen | last post by:
Hi. I have a web page that has images and text. I can carefully select one image and the on the right of the image and then copy & paste to Word. Is it possible to make javascript do the same:...
7
by: rihad | last post by:
Hi, I have this problem: when reading a M$ Windows text file under Windows in text mode (fopen("blah", "r")) the Windows newline sequence, \r\n is returned as is, i.e. it's not replaced by a single...
2
by: Hariharan Subramony | last post by:
Hello Guys, I have an important issue and need solution at the earliest. Thanks in advance. I have a RichTextBox named say, ' rtb' that has the text "Hello, I am fine." To place it in the...
6
by: XmlAdoNewbie | last post by:
Hi All, I would like to put a method for copy, cut and paste into my application and this seems to be easy enough except that it's not working the way i would like it to, I thought someone might...
3
by: Tor Inge Rislaa | last post by:
Copy, Cut and Paste How to code the Copy, Cut and Paste functionality in VB.NET. In VB 6.0 I used the following code: 'For Copy Clipboard.Clear Clipboard.SetText...
5
by: DraguVaso | last post by:
Hi, I'm looking for a way to Copy and Paste Files to the clipboard. I found a lot of articles to copy pieces of text and bitmaps etc, but nog whole files. Whay I need is like you have in...
2
by: Keith | last post by:
I'm trying to come up with a way to create a contextmenu that will do all the "standard" functions (cut, copy, paste, undo, etc). There seems to be a lot of information out there - but nothing...
3
by: SAL | last post by:
I have the following VB.net Class/Function that I call from an ASP.net page: Public Class MyTestClass Public Function embedHyperlink(ByVal fileID As Integer, ByVal fileName As String) As String...
3
by: MLH | last post by:
Say I have a string value in Access - perhaps "ABCDE". How do I copy it to Windoze clipboard? This is not a repost, but is related to a 7/26/06 post entitled "Probs running DoCmd.RunCommand...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.