Using win32gui.SendMessage and SysListView32 control

geskerrett at hotmail.com geskerrett at hotmail.com
Sun Dec 3 15:01:56 EST 2006


Hope someone can steer me in the right direction.

I am trying to use python to collect the values from a Win32
application's control.
I can successfull query an retreive the values ListBox, Edit and
Buttons, however, the application uses a control called a
'SysListView32' Control.  MSDN says that this descends from CListView
control and the msdn website reference for this control is;
http://msdn2.microsoft.com/en-gb/library/ms670560.aspx
(scroll to the message constants)

This page seems to imply that the control can be queried with messages,
however, my problem seems to be that pywin32.win32con does not define a
constant for the LVM series of messages.

Any other suggestions ??

I am looking for something similar to code below which does a fine job
of collecting all of the text values from a "ListBox" control;

        count = win32gui.SendMessage(hndl,win32con.LB_GETCOUNT)
        vals = []
        for i in range(count):
            strlen = win32gui.SendMessage(hndl,win32con.LB_GETTEXTLEN)
            text = ' '*(strlen+1) #Buffer for returned text -50
characters
            lentext =
win32gui.SendMessage(hndl,win32con.LB_GETTEXT,i,text)
            txt = text[0:lentext]
            print "Hndl: %8s  Class: %-10s  TxtLen:%3s TxtVal: %s   " %
(hndl,clname,lentext,txt)
            vals.append(txt.strip())

Thanks in advance.




More information about the Python-list mailing list