Tab Controls (without control names)

Class library usage, coding and language questions.
James Hirst
Posts: 21
Joined: Wed Dec 06, 2006 6:24 pm
Location: UK

Tab Controls (without control names)

Post by James Hirst » Wed Dec 06, 2006 6:42 pm

Hi guys,

I'm scripting the windows display properties dialog.

Most of this is pretty stratight forward with the controlname functions but when they aren't present it gets a tad confusing. This is true in the case of the tabs (Settings, Screen Saver, Themes etc). I'm led to believe from looking at the forum that I should be using the element functionality to achieve this. Sound about right?

I'm not only a novice at Ranorex but also a novice with Python but can code in other languages.

Just seeking some direction here.


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

Post by webops » Wed Dec 06, 2006 8:16 pm

The display properties dialog is an old windows control, it's not a .NET control so it has no control names.
You can only use the FormFindChildClassName and FormFindChildControlId functions to find a control in the form. You can also use the element functions to find the elements in the tab pages.

The following code finds and activates the 'Display Properties' dialog, reads and activates all tabs, searches the 'Display' element and reads the text of it.

Code: Select all

form = Ranorex.FormFindTitle('Display Properties')
if form == 0:
    print 'Error: Form not found'        
    return 4
print '   Form found, form=' + hex(form)

print '--------------------------------------------------------------------'
print ' Searching and testing a tab control'
print '---------------------------------------------------------------------'
print '   Searching tabControl1 by control name'
tabControl = Ranorex.FormFindChildClassName(form,'SysTabControl32')
if tabControl == 0:
    print 'ERROR: tabControl1 not found'
    return 5
print '      tabControl=' + hex(tabControl)

print '  Moving the mouse to the tab control'

selectedIndex = Ranorex.TabControlGetSelectedIndex(tabControl)
if selectedIndex != -1:
    print '   SelectedIndex=' + str(selectedIndex)
selectedText = Ranorex.TabControlGetSelectedText(tabControl)
if selectedText != None:
    print '   SelectedText=' + str(selectedText)

itemCount = Ranorex.TabControlGetItemCount(tabControl)
print '   ItemCount=' + str(itemCount)
for i in range(itemCount):
    text = Ranorex.TabControlGetItemText(tabControl,i)
    print '     Tabtext ' + str(i) + '=' + text

element = Ranorex.ControlGetElement(form)
display = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_STATICTEXT, 'Display:', 'ComboBox')
if display == None:
    print 'ERROR: display not found'
    return 5
print Ranorex.ElementGetValue(display)
Use RanorexSpy to get the control and element properties.

Jenö Herget
Ranorex Team