title: Use Python to extract ListView items from another application
body: <p>I have an application with a ListView ('SysListView32') control, from which I would like to extract data. The control has 4 columns, only textual data.</p>
  
  <p>I have been playing around the following lines (found online somewhere):</p>
  
  <pre><code>VALUE_LENGTH = 256
  bufferlength_int=struct.pack('i', VALUE_LENGTH)
  count = win32gui.SendMessage(TargetHwnd, commctrl.LVM_GETITEMCOUNT, 0, 0)
  for ItemIndex in range(count):
      valuebuffer = array.array('c',bufferlength_int + " " * (VALUE_LENGTH - len(bufferlength_int)))
      ListItems = win32gui.SendMessage(TargetHwnd, commctrl.LVM_GETITEMTEXT, ItemIndex, valuebuffer)
  </code></pre>
  
  <p>[The above code may not be entirely executable, as I stripped it from irrelevant stuff. but the gist is certainly here.]</p>
  
  <p>This seems to run ok but I must be doing something wrong - I get all sorts of mostly-zeroed data buffers in return, and none of the actual text contents I was looking for.</p>
  
  <p>Any suggestions?</p>
  
  <p>Thanks,<br>
  Yonatan</p>