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

MRAB google at mrabarnett.plus.com
Tue May 19 12:08:38 EDT 2009


zhouhaifeng wrote:
> 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)
> 
[snip]

Split the string into lines and take the eighth line (at index 7). I've
limited the number of splits to 8 because I'm not interested in any of
the following lines:

     line = text.split("\r\n", 8)[7]




More information about the Python-list mailing list