how to get the spesific line of the text in the clipboard

Z

zhouhaifeng

I want to get the eighth line in the text of the text in the clipboad,
but when I call GetClipboardData
I only get a string, how can I repair it?

thanks a lot.

My code is here :
try:
win32clipboard.OpenClipboard(hWnd)
#win32api.Sleep(500)
text = win32clipboard.GetClipboardData(win32con.CF_TEXT)
#win32clipboard.EmptyClipboard()
win32clipboard.CloseClipboard()

logging.info(len(text))

return text
except Exception, exc:
logging.info(exc)


....


def get_file_title(filename):
f = file(filename)
#f = open(filename, encoding='gb2312', mode='w+')
title = u""
line_count = 0
for line in f:
line_count = line_count + 1
if line_count == 8:
<----------------------------now I write the text of the clipboard into
file, and then read it from file, at this time, I can get line 8 , but
it so low efficiency
title = unicode(line, 'gb2312', 'ignore')
title = title.replace("\r\n", '')
break
return title
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top