Combobox selecting

Class library usage, coding and language questions.
Posts: 1
Joined: Thu Apr 26, 2007 11:37 am

Combobox selecting

Post by RPodmore » Thu Apr 26, 2007 2:22 pm


Having some problems getting anything in a combo box selected, in this instance via the WDP Power Options in windows:

def SetTimePeriod(self): = PropertyPage.PropertyPage(), 0), "Home/Office Desk", 1)

which uses:

def SelectComboboxItem(self, parent, item, instance):
""" Requires the parent window’s title and the name of the combobox item """
""" i.e. SelectComboboxItem(“Display Properties”, "Medium (16 bit)") selects 16bit colour depth in the WDP """
form = Ranorex.FormFindTitle(parent)
ComboBox = Ranorex.FormFindChildClassName(form, 'ComboBox', instance)
Ranorex.ComboBoxSetSelectedText(ComboBox, item)

Please help if you can, what happens is the cursor is seen to move towards the required combo box, then stops at its border, nothing changes or happens and no errors are thrown.

Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Thu Apr 26, 2007 7:43 pm

It's better to use the FormFindChildControlId function in the standard windows dialogs.
(if the Id of the control is a unique identifier).

I tried the following code with the "Display Properties" Dialog and it worked for me:

Code: Select all

comboBox = Ranorex.FormFindChildControlId(form,1807)
if comboBox == 0:
    print 'ERROR: comboBox not found'
print '  comboBox = ' + hex(comboBox)
print '   moving the mouse to the comboBox'

itemcount =  Ranorex.ComboBoxGetItemCount(comboBox)
print '  itemcount=' + str(itemcount)
for i in range(itemcount):
    text = Ranorex.ComboBoxGetItemText(comboBox,i)
    print '    text=' + str(text)
Ranorex Team