Hello,

I have a weird problem... When I use the clipboard, code runs without error.

Attempt to paste directly after run in any application does not work.
Pasting in the python shell works fine.
After pasting in the python shell, pasting in any other application works fine !!!

Need help fast...

Thanks...

(working with python 2.5 on Vista...)


code (justed picked of the web)
import win32clipboard

def txtToClipboard(iTxt):
win32clipboard.OpenClipboard(0)
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(iTxt)
win32clipboard.CloseClipboard

txtToClipboard('blahblah')

Works great with an XP, so it could be Vista that srews things up.

# send text to the clipboard

import win32clipboard

def txtToClipboard(iTxt):
    win32clipboard.OpenClipboard(0)
    win32clipboard.EmptyClipboard()
    win32clipboard.SetClipboardText(iTxt)
    win32clipboard.CloseClipboard

txtToClipboard('text to paste')

# test
# or use paste in the editor window
data = win32clipboard.GetClipboardData()
print data
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.