From fc1b650298c623b7c8a80af29c269df91d07ffaf Mon Sep 17 00:00:00 2001 From: Bradlee Speice Date: Thu, 23 Aug 2012 14:52:35 -0400 Subject: [PATCH] Add a function to the Python code to get the mouse current location --- python/libcvautomation_funcs.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python/libcvautomation_funcs.py b/python/libcvautomation_funcs.py index 2c594fc..b9ec205 100644 --- a/python/libcvautomation_funcs.py +++ b/python/libcvautomation_funcs.py @@ -556,6 +556,18 @@ def mouse_drag_n_drop( drag_image, drag_to, use_center = True ): #Display not open raise LibcvDisplayNotOpen( _get_caller() ) +## \brief Get the current location of the mouse +# \details This function will return the current location of the mouse as two variables - i.e. `x, y = mouse_location()`. This is a Python-specific function. +# \returns Two variables for the \c x and \c y locations +def mouse_location(): + if _check_display(): + current_location = libcvautomation.xte_mouseLocation( _get_display() ) + _log_output( 'Mouse location: x=' + str(current_location.x) + ' y=' + str(current_location.y) ) + return current_location.x, current_location.y + else: + #Display not open + raise LibcvDisplayNotOpen( _get_caller() ) + ## \brief Enter a string of text on the keyboard # \details This function will simulate pressing the keys exactly as they are entered - unlike libcvautomation_funcs::key_down, libcvautomation_funcs::key_up, and libcvautomation_funcs::key_click, this function will display exactly what you entered: A string of \c '!' will produce a \c ! as a keypress. # \param string The string of text to enter on the keyboard