[python-win32] win32clipboard.GetClipboardData does not return latest data after using type_keys('^C')

SamLee 2938617010 at qq.com
Tue Apr 10 04:43:57 EDT 2018


Dear pywin32 group:

Recently i bump into a case where i cannot get text from a window field directly.
So i try to type ctrl+a and ctrl+c , and then use win32clipboard to read data from clipboard
However, i always get data from the previous "ctrl+a ctrl+c", not the latest one
In order to get the latest clipboard data , i have to perform "ctrl+a ctrl+c" in another thread
Should this be a bug?

FYI ,I'm using Windows10 , Python 3.6.4rc1
def chooseAndCopyResult(app,windowName,editIdx): 	allEdits = app.window(title_re='.*{}.*'.format(windowName)).children(control_type='Edit') 	allEdits[editIdx].set_focus().type_keys('^A').type_keys('^C') #this one does not return the latest clipboard but the previous clipboard def readResultFromOCR(app,windowName,editIdx): 	chooseAndCopyResult(app,windowName,editIdx) 	win32clipboard.OpenClipboard() 	data = win32clipboard.GetClipboardData() 	win32clipboard.CloseClipboard() 	return data # this one works, and get the latest data from clipboard def readResultFromOCRWorking(app,windowName,editIdx): 	thread = Thread(target=chooseAndCopyResult,args=(app,windowName,editIdx)) 	thread.start() 	thread.join() 	win32clipboard.OpenClipboard() 	data = win32clipboard.GetClipboardData() 	win32clipboard.CloseClipboard() 	return data
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20180410/fa2cbcc3/attachment.html>


More information about the python-win32 mailing list