Ranorex

ControlGetState return value help

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexPython
View previous topic :: View next topic  
Author Message
James Hirst



Joined: 06 Dec 2006
Posts: 21
Location: UK

PostPosted: 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
View user's profile Send private message Visit poster's website
James Hirst



Joined: 06 Dec 2006
Posts: 21
Location: UK

PostPosted: Mon Dec 18, 2006 9:06 pm    Post subject: Solution
Ok I've managed to get round this using a bitwise AND Very Happy
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
View user's profile Send private message Visit poster's website
admin
Site Admin


Joined: 05 Jul 2006
Posts: 351

PostPosted: 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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexPython All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum