S
Stephen Boulet
I'm using the following code in clipboard.py. The problem is that it
sets the clipboard text correctly sometimes and sometimes doesn't alter
it at all. What am I doing wrong?
import win32clipboard,sys
def getclipboard():
.....# Get current string from clipboard. If string empty, error out.
.....win32clipboard.OpenClipboard(0)
.....if win32clipboard.IsClipboardFormatAvailable(win32clipboard.CF_TEXT):
.........s = win32clipboard.GetClipboardData(win32clipboard.CF_TEXT)
.........win32clipboard.CloseClipboard()
.....else:
.........win32clipboard.CloseClipboard()
.........from wxMessageBox import showerror
.........showerror('Error!','No text on clipboard')
.........sys.exit()
.....return s
def setclipboard(s):
.....# Paste string to clipboard
.....win32clipboard.OpenClipboard(0)
.....win32clipboard.EmptyClipboard()
.....win32clipboard.SetClipboardText(s)
.....win32clipboard.CloseClipboard()
Stephen
sets the clipboard text correctly sometimes and sometimes doesn't alter
it at all. What am I doing wrong?
import win32clipboard,sys
def getclipboard():
.....# Get current string from clipboard. If string empty, error out.
.....win32clipboard.OpenClipboard(0)
.....if win32clipboard.IsClipboardFormatAvailable(win32clipboard.CF_TEXT):
.........s = win32clipboard.GetClipboardData(win32clipboard.CF_TEXT)
.........win32clipboard.CloseClipboard()
.....else:
.........win32clipboard.CloseClipboard()
.........from wxMessageBox import showerror
.........showerror('Error!','No text on clipboard')
.........sys.exit()
.....return s
def setclipboard(s):
.....# Paste string to clipboard
.....win32clipboard.OpenClipboard(0)
.....win32clipboard.EmptyClipboard()
.....win32clipboard.SetClipboardText(s)
.....win32clipboard.CloseClipboard()
Stephen