395
396
def move_to_object(self, object_proxy):
396
397
"""Attempts to move the mouse to 'object_proxy's centre point.
398
It does this by looking for several attributes, in order. The first
399
attribute found will be used. The attributes used are (in order):
401
* globalRect (x,y,w,h)
405
:raises: **ValueError** if none of these attributes are found, or if an
406
attribute is of an incorrect type.
399
See :py:meth:`~autopilot.input.get_center_point` for details on how
400
the center point is calculated.
410
x, y, w, h = object_proxy.globalRect
411
_logger.debug("Moving to object's globalRect coordinates.")
412
self.move(x+w/2, y+h/2)
414
except AttributeError:
416
except (TypeError, ValueError):
418
"Object '%r' has globalRect attribute, but it is not of the "
419
"correct type" % object_proxy)
422
x, y = object_proxy.center_x, object_proxy.center_y
423
_logger.debug("Moving to object's center_x, center_y coordinates.")
426
except AttributeError:
428
except (TypeError, ValueError):
430
"Object '%r' has center_x, center_y attributes, but they are "
431
"not of the correct type" % object_proxy)
435
object_proxy.x, object_proxy.y, object_proxy.w, object_proxy.h)
437
"Moving to object's center point calculated from x,y,w,h "
439
self.move(x+w/2, y+h/2)
441
except AttributeError:
443
"Object '%r' does not have any recognised position "
444
"attributes" % object_proxy)
445
except (TypeError, ValueError):
447
"Object '%r' has x,y attribute, but they are not of the "
448
"correct type" % object_proxy)
403
x, y = get_center_point(object_proxy)
450
406
def position(self):