[Tutor] Clipboard manager for windows
János Juhász
janos.juhasz at VELUX.com
Thu Sep 14 18:14:45 CEST 2006
Hi Derick,
>So I need a way to hijaak the Ctrl-C and Ctrl-V shortcuts and have my
>application run in the system tray. I don't need a gui other than
changing
>the context menu (which I believe is done in the registry) - although,
I'd
>probably need to use wxPython for using the system tray - unless by
catching
>the shortcut keys, I can call the program...
I have tested it without hijaak the Ctrl-C and Ctrl-V
It is seem to be easier to set up a shortcut to in-place filtering
on the current content of the clipboard.
I just have played with the sample you showed:
### text.py My small clipboard coverter ###
import win32clipboard as w
import win32con
import re
def getText():
w.OpenClipboard()
d=w.GetClipboardData(win32con.CF_TEXT)
w.CloseClipboard()
return d
def setText(aType,aString):
w.OpenClipboard()
w.EmptyClipboard()
w.SetClipboardData(aType,aString)
w.CloseClipboard()
def myFilter(text):
comma = re.compile(',')
return comma.sub('\t', text)
def myTester(text):
### context sensitivity
return ',' in text
text = getText()
if myTester(text):
setText(win32con.CF_TEXT, myFilter(text))
### My small clipboard coverter ###
I have saved this python script into my devel folder,
created a shortcut on the windows desktop,
set up a shortcut key for it with Ctrl-Alt-T.
When I start this program with the shortcut key, it simple makes
the replace in-place on the current content of the clipboard,
that can be put into excel after it.
Copy this to the clipboard:
a,b,c,d,e
1,2,3,4,5
run the script
Paste the clipboard to excel
Viola :)
You can make it with wxPython and give the choice for the
user on the visual surface to choose from more filters.
It also could be interesting, to make the tab delimited clipboard content
from the filenames.
>>> w.OpenClipboard()
>>> w.GetClipboardData(win32con.CF_HDROP)
(u'D:\\devel\\tutor\\data.txt',)
>>> w.CloseClipboard()
Yours sincerely,
______________________________
János Juhász
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060914/f86d58a9/attachment-0001.html
More information about the Tutor
mailing list