Help: Win32 clipboard
Luciano ES
luc-groups at BrazilianTranslation.net
Wed Oct 23 18:43:33 EDT 2002
Hi, everyone. My name is Luciano. I am an annoying newbie. Could anyone
help me with the use of clipboard in Win32?
I am using this code, with Python 2.2:
--------------------------------
from win32clipboard import *
import win32con
import types
myClip = OpenClipboard(0)
myClip = GetClipboardData(CF_UNICODETEXT)
closethis = CloseClipboard()
print myClip
--------------------------------
hello
My biggest problem is that I have tried:
myClip = GetClipboardData(CF_UNICODETEXT)
myClip = GetClipboardData(CF_TEXT)
myClip = GetClipboardData(CF_OEMTEXT)
myClip = GetClipboardData(win32con.CF_UNICODETEXT)
myClip = GetClipboardData(win32con.CF_TEXT)
myClip = GetClipboardData(win32con.CF_OEMTEXT)
1 - I'm getting several different results, none of them right. Suppose I
copy the word "hello" and run it. Sometimes, I get 'hello' and a series of
funny symbols. Sometimes, I get 'hello' followed by about 25 spaces.
Sometimes, I get 'hello' followed by things like "d D a t a ( C F _ T E X",
" = GetCli", "d D a t a ( w i n 3 2 c", or "UnicodeError: ASCII encoding
error: ordinal not in range(128)". But I can't have Python print just
"hello". What am I doing wrong?
2 - I copied that example (like a good newbie), and used "from
win32clipboard import *". But there is no win32clipboard.py module anywhere
in my disk, and the script doesn't work if I don't add that line. Why?
3 - Not about clipboard, but intriguing: how do I run a system() command
with variables inside? For example:
my_command = 'echo *Message 2'+myClip+' | stdin2pp'
c = os.system(my_command)
I want to run a command line, part of which will be the clipboard content.
But it seems that system won't let me use a variable instead of a quoted
string. Trying to weasal os.system('concatenated'+string) in didn't work
either. Can you enlighten me, please?
Thanks,
--
Luciano ES
Santos - SP - Brasil
More information about the Python-list
mailing list