Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Using PythonWin32 to copy text to Windoze Clipboard for Unix-style random .sig rotator?

Reply
Thread Tools

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

 
 
dananrg@yahoo.com
Guest
Posts: n/a
 
      04-06-2006
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

 
Reply With Quote
 
 
 
 
Fredrik Lundh
Guest
Posts: n/a
 
      04-06-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) 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>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clipboard - Copy Text To Clipboard Mahsha Javascript 3 06-01-2009 08:19 PM
Clipboard - Copy Image To Clipboard Mahsha Javascript 1 06-01-2009 05:06 PM
Windoze XP or windoze 2003 Server Ronit Bhattacharya MCSE 3 01-22-2005 10:49 AM
Using VB.Net or C#, utilizing the clipboard object, how to copy an MS Excel graphic from the clipboard to an image control and obtain its source reference TC ASP .Net 5 09-01-2004 04:49 AM
Windoze XP over Windoze NT/ME The InteŽnet Devil Computer Support 0 02-13-2004 04:46 PM



Advertisments