I have a Python script that reads the clipboard, processes the contents, and updates the clipboard with new information. Here's my code:
win32clipboard.OpenClipboard()
toSearch = win32clipboard.GetClipboardData()
# Do stuff
win32clipboard.SetClipboardText(result)
win32clipboard.CloseClipboard()
Reading the text afterward with GetClipboardData()
returns the text I set to it, but a normal right-click+paste or control-v returns what was previously there. Is this a bug in pywin32 or am I doing something wrong?
This will works:
result = 'Some Text'
win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText( result, win32clipboard.CF_TEXT )
win32clipboard.CloseClipboard()