DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Python (http://www.daniweb.com/forums/forum114.html)
-   -   win32clipboard problem (http://www.daniweb.com/forums/thread150469.html)

ldk Oct 10th, 2008 7:46 pm
win32clipboard problem
 
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')

Ene Uran Oct 10th, 2008 8:31 pm
Re: win32clipboard problem
 
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


All times are GMT -4. The time now is 9:26 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC