November 19, 2003
7 hours, one line of code

Some days, the code just flows. But not when you are calling the Windows API. :-(

I've been working a bit more on Windows GUI automation, specifically on combo boxes.

The problem was with automating the selection of items in the combo. To begin with, I was just sending a CB_SETCURSEL message to the combo, like so:

win32gui.SendMessage(hwnd, win32con.CB_SETCURSEL, item, 0)

This did the selection in the combo box so far as I could see, but it wasn't sticking - the changed selection wasn't having any effect on the rest of the dialog.

Turns out, I need also to send a CBN_SELCHANGE, too. Finding this out, along with working out how to send the bloody thing, has taken all day. Sigh.

For what it's worth, here is the final (working?) selectComboboxItem() function, and the whole winGuiAuto module. This is work in progress, mind, but you're welcome to it if it's useful to you.

Posted to Python by Simon Brunning at November 19, 2003 04:56 PM
Post a comment

Email Address:



Remember info?