ControlGetState return value help

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

ControlGetState return value help

Post by James Hirst » Mon Dec 18, 2006 5:52 pm

Hi guys,

I'm trying to make use of the ControlGetState function to check the status of various controls before I manipulate them. My code is loosely as follows:

Code: Select all

MyControlState = Ranorex.ControlGetState(wnd)
if MyControlState == CONTROL_INVISIBLE:
print 'Control is invisible
else:
print 'Control is visible
This falls over as the idle complains that -
'NameError: global name 'CONTROL_INVISIBLE' is not defined'

This maybe down to my lack of python knowledge...

BUT...

Do I need to add something to the beginning of the constant? Or put it in inverted commas?

Thanks for any help on this.

James Hirst
Posts: 21
Joined: Wed Dec 06, 2006 6:24 pm
Location: UK
Contact:

Solution

Post by James Hirst » Mon Dec 18, 2006 8:06 pm

Ok I've managed to get round this using a bitwise AND :D
So... instead of:

Code: Select all

    MyControlState = Ranorex.ControlGetState(wnd)
    if MyControlState == CONTROL_UNAVAILABLE:
I now have:

Code: Select all

    MyControlState = Ranorex.ControlGetState(wnd)
    if MyControlState & 1 == 1:
Had to dig around a bit to find the const values (they were in the RanorexPython module doc) but I'm left thinking there must be a way to use the consts themselves... Jeno et al, do I need to include some header file?

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

Post by admin » Mon Dec 18, 2006 11:50 pm

James Hirst wrote:do I need to include some header file?
No, you can use the bit flags as follows:

Code: Select all

state = Ranorex.ControlGetState(control)
if state & Ranorex.CONTROL_INVISIBLE:
    print ' Control invisible'
else:
    print ' Control visible'
Jenö Herget
Ranorex Team