Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-19 Thread Dave Angel
On 19/9/2013 11:53, Neil Cerutti wrote: > On 2013-09-18, Dave Angel wrote: >> On 18/9/2013 17:40, Neil Hodgson wrote: >> >>> Dave Angel: >>> So is the bug in Excel, in Windows, or in the Python library? Somebody is falling down on the job; if Windows defines the string as ending at >>

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-19 Thread Neil Cerutti
On 2013-09-18, Dave Angel wrote: > On 18/9/2013 17:40, Neil Hodgson wrote: > >> Dave Angel: >> >>> So is the bug in Excel, in Windows, or in the Python library? Somebody >>> is falling down on the job; if Windows defines the string as ending at >>> the first null, then the Python interface shoul

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-19 Thread random832
On Wed, Sep 18, 2013, at 16:13, Dave Angel wrote: > So is the bug in Excel, in Windows, or in the Python library? Somebody > is falling down on the job; if Windows defines the string as ending at > the first null, then the Python interface should use that when defining > the text defined with CF_

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread Dave Angel
On 18/9/2013 17:40, Neil Hodgson wrote: > Dave Angel: > >> So is the bug in Excel, in Windows, or in the Python library? Somebody >> is falling down on the job; if Windows defines the string as ending at >> the first null, then the Python interface should use that when defining >> the text defin

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread Neil Hodgson
Dave Angel: So is the bug in Excel, in Windows, or in the Python library? Somebody is falling down on the job; if Windows defines the string as ending at the first null, then the Python interface should use that when defining the text defined with CF_UNICODETEXT. Everything is performing

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread Dave Angel
On 18/9/2013 15:40, MRAB wrote: > On 18/09/2013 20:28, stephen.bou...@gmail.com wrote: >> Thanks to everyone for their help. Using everyone's suggestions, this seems >> to work: >> >> import win32clipboard, win32con >> >> def getclipboard(): >> win32clipboard.OpenClipboard() >> s = win3

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread MRAB
On 18/09/2013 20:28, stephen.bou...@gmail.com wrote: Thanks to everyone for their help. Using everyone's suggestions, this seems to work: import win32clipboard, win32con def getclipboard(): win32clipboard.OpenClipboard() s = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT)

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread stephen . boulet
Thanks to everyone for their help. Using everyone's suggestions, this seems to work: import win32clipboard, win32con def getclipboard(): win32clipboard.OpenClipboard() s = win32clipboard.GetClipboardData(win32con.CF_UNICODETEXT) win32clipboard.CloseClipboard() if '\0' in s:

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-18 Thread random832
On Fri, Sep 13, 2013, at 12:09, random...@fastmail.us wrote: > Anyway, to match behavior found in other applications when pasting from > the clipboard, I would suggest using: > > if s.contains('\0'): s = s[:s.index('\0')] > > Which will also remove non-null bytes after the first null (but if the

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-17 Thread stephen . boulet
On Thursday, September 12, 2013 6:01:20 PM UTC-5, stephen...@gmail.com wrote: > I have an excel file. When I select cells, copy from excel, and then use > win32clipboard to get the contents of the clipboard, I have a 131071 > character string. > > > > When I save the file as a text file, and u

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread random832
On Fri, Sep 13, 2013, at 10:38, stephen.bou...@gmail.com wrote: > > Hm, that gives me a "Type str doesn't support the buffer API" message. > > Aha, I need to use str(s, encoding='utf8').rstrip('\0'). It's not a solution to your problem, but why aren't you using CF_UNICODETEXT, particularly if you

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread Neil Cerutti
On 2013-09-13, stephen.bou...@gmail.com wrote: > On Thursday, September 12, 2013 10:43:46 PM UTC-5, Neil Hodgson wrote: >> Stephen Boulet: >> >> >> >> > From the clipboard contents copied from the spreadsheet, the characters >> > s[:80684] were the visible cell contents, and s[80684:] all sta

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread stephen . boulet
On Friday, September 13, 2013 9:31:45 AM UTC-5, stephen...@gmail.com wrote: > On Thursday, September 12, 2013 10:43:46 PM UTC-5, Neil Hodgson wrote: > > > Stephen Boulet: > > > > > > > > > > > > > From the clipboard contents copied from the spreadsheet, the characters > > > s[:80684] were

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-13 Thread stephen . boulet
On Thursday, September 12, 2013 10:43:46 PM UTC-5, Neil Hodgson wrote: > Stephen Boulet: > > > > > From the clipboard contents copied from the spreadsheet, the characters > > s[:80684] were the visible cell contents, and s[80684:] all started with > > "b'\x0" and lack any useful info for what

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread Neil Hodgson
Stephen Boulet: From the clipboard contents copied from the spreadsheet, the characters s[:80684] were the visible cell contents, and s[80684:] all started with "b'\x0" and lack any useful info for what I'm trying to accomplish. Looks like Excel is rounding up its clipboard allocation to

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread MRAB
On 13/09/2013 01:58, stephen.bou...@gmail.com wrote: Hi Steven. Here is my code: import win32clipboard, win32con def getclipboard(): win32clipboard.OpenClipboard() s = win32clipboard.GetClipboardData(win32con.CF_TEXT) win32clipboard.CloseClipboard() return s I use this help

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread stephen . boulet
Hi Steven. Here is my code: import win32clipboard, win32con def getclipboard(): win32clipboard.OpenClipboard() s = win32clipboard.GetClipboardData(win32con.CF_TEXT) win32clipboard.CloseClipboard() return s I use this helper function to grab the text on the clipboard and do useful

Re: Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread Steven D'Aprano
On Thu, 12 Sep 2013 16:01:20 -0700, stephen.boulet wrote: > I have an excel file. When I select cells, copy from excel, and then use > win32clipboard to get the contents of the clipboard, I have a 131071 > character string. How exactly are you using win32clipboard, and what exact result are you

Stripping characters from windows clipboard with win32clipboard from excel

2013-09-12 Thread stephen . boulet
I have an excel file. When I select cells, copy from excel, and then use win32clipboard to get the contents of the clipboard, I have a 131071 character string. When I save the file as a text file, and use the python 3.3 open command to read its contents, I only have 80684 characters. Excel (an