| View previous topic :: View next topic |
| Author |
Message |
James Hirst
Joined: 06 Dec 2006 Posts: 21 Location: UK
|
Posted: Mon Dec 18, 2006 6:52 pm Post subject: ControlGetState return value help |
|
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: click into code to enlarge
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. |
|
| Back to top |
|
 |
James Hirst
Joined: 06 Dec 2006 Posts: 21 Location: UK
|
Posted: Mon Dec 18, 2006 9:06 pm Post subject: Solution |
|
Ok I've managed to get round this using a bitwise AND
So... instead of:
Code: click into code to enlarge
MyControlState = Ranorex.ControlGetState(wnd)
if MyControlState == CONTROL_UNAVAILABLE:
I now have:
Code: click into code to enlarge
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? |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Tue Dec 19, 2006 12:50 am Post subject: |
|
| James Hirst wrote: |
| do I need to include some header file? |
No, you can use the bit flags as follows:
Code: click into code to enlarge
state = Ranorex.ControlGetState(control)
if state & Ranorex.CONTROL_INVISIBLE:
print ' Control invisible'
else:
print ' Control visible'
Jenö Herget
Ranorex Team |
|
| Back to top |
|
 |
|