Connecting Tech Pros Worldwide Forums | Help | Site Map

-- Pythonic control of Windows GUI application: tabs and listviews

zapazap
Guest
 
Posts: n/a
#1: Jul 18 '05
-- Pythonic control of Windows GUI application: tabs and listviews

Dear Snake-charming Gurus,

I have learned to manipulate some controls ("Button", "ComboBox", etc)
through such means as:

win32gui.SendMessage(hwnd, win32con.BM_GETCHECK, 0 ,0)
win32gui.SendMessage(hwnd, win32con.CB_GETCOUNT, 0 ,0)

provided by Python Win32 Extensions, and understand that such
constants as:

win32con.BM_GETCHECK
win32con.CB_GETCOUNT

corresponding to distinct messages (documented at [1] and [2]) that
can be sent to such controls.

For the "List-View" and "Tab" controls then, I expected to find the
constants

win32con.LVM_GETCHECK
win32con.TCM_GETITEMCOUNT

corresponding to the distinct messages documented at [3] and [4].
Unfortunately the module win32com module does not have any LVM_* or
TCM_* attributes, and I have not found reference to such constants in
the Extensions documentation.


I want to control a windows app through the GUI, but I do *not* want
to resort to 'mouseclick/keypress recorder' type tools. For now, I
seem to be able to work the Button and Combobox controls for a target
window while another window is running full screen mode, and I want to
keep it that way. But some of the controls I need can be reached only
by mamipulating Tab and Listview controls.

Do you have any advice on how I might control these controls in a way
similar to my controling Buttons and Comboboxes? Or, failing that, do
you have an entirely different route for me controlling one app while
a second is running maximized?

Much thanks!!
- Bryan Hann


[1] http://msdn.microsoft.com/library/de...m_getcheck.asp
[2] http://msdn.microsoft.com/library/de...b_getcount.asp
[3] http://msdn.microsoft.com/library/de...titemcount.asp
[4] http://msdn.microsoft.com/library/de...titemcount.asp

Thomas Heller
Guest
 
Posts: n/a
#2: Jul 18 '05

re: -- Pythonic control of Windows GUI application: tabs and listviews


zapazap@yahoo.com (zapazap) writes:
[color=blue]
> -- Pythonic control of Windows GUI application: tabs and listviews
>
> Dear Snake-charming Gurus,
>
> I have learned to manipulate some controls ("Button", "ComboBox", etc)
> through such means as:
>
> win32gui.SendMessage(hwnd, win32con.BM_GETCHECK, 0 ,0)
> win32gui.SendMessage(hwnd, win32con.CB_GETCOUNT, 0 ,0)
>
> provided by Python Win32 Extensions, and understand that such
> constants as:
>
> win32con.BM_GETCHECK
> win32con.CB_GETCOUNT
>
> corresponding to distinct messages (documented at [1] and [2]) that
> can be sent to such controls.
>
> For the "List-View" and "Tab" controls then, I expected to find the
> constants
>
> win32con.LVM_GETCHECK
> win32con.TCM_GETITEMCOUNT
>
> corresponding to the distinct messages documented at [3] and [4].
> Unfortunately the module win32com module does not have any LVM_* or
> TCM_* attributes, and I have not found reference to such constants in
> the Extensions documentation.[/color]

These constants are defined in the 'commctrl' module:

Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.[color=blue][color=green][color=darkred]
>>> import commctrl
>>> commctrl[/color][/color][/color]
<module 'commctrl' from 'C:\Python23\lib\site-packages\win32\lib\commctrl.pyc'>[color=blue][color=green][color=darkred]
>>> commctrl.LVM_GETITEMCOUNT[/color][/color][/color]
4100[color=blue][color=green][color=darkred]
>>> commctrl.TCM_GETITEMCOUNT[/color][/color][/color]
4868

Thomas
Mark Hammond
Guest
 
Posts: n/a
#3: Jul 18 '05

re: -- Pythonic control of Windows GUI application: tabs and listviews


zapazap wrote:
[color=blue]
> For the "List-View" and "Tab" controls then, I expected to find the
> constants
>
> win32con.LVM_GETCHECK
> win32con.TCM_GETITEMCOUNT[/color]

FYI, A good source of sample code for working with tree-view controls
can be found in the SpamBayes project, specifically:
http://cvs.sourceforge.net/viewcvs.p...py?view=markup

Working with these win32gui structures is a complete PITA (as it needs
to be done via the 'struct' module) - I'd like to integrate support for
ctypes structures to make this more readable. In fact, I'd love to see
ctypes structure support as a standard library module, but that is for
another thread in a another forum <wink>

Mark

Closed Thread