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

Tim Golden tim.golden at viacom-outdoor.co.uk
Thu Apr 6 06:11:17 EDT 2006


[dananrg at yahoo.com]
| 
| 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.

Very quick and untested answer. Look at the win32clipboard
module. Something like this (very untested):

<code>
import win32clipboard

sig = "whatever you got from your file"

win32clipboard.OpenClipboard ()
try:
  win32clipboard.SetClipboardText (sig)
finally:
  win32clipboard.CloseClipboard ()

</code>

| 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?

You want to look at the WM_HOTKEY message. There's an
example here:

http://timgolden.me.uk/python/win32_how_do_i/catch_system_wide_hotkeys.h
tml

HTH
TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________



More information about the Python-list mailing list