def mouse_click(mouse_button=_mouse_button_default): if _check_display(): _log_output('Mouse button click: ' + mouse_button) libcvautomation.xte_clickMouse(_get_display(), mouse_button) return True else: #Display not open raise LibcvDisplayNotOpen(_get_name())
def mouse_click( mouse_button = _mouse_button_default ): if _check_display(): _log_output( 'Mouse button click: ' + mouse_button ) libcvautomation.xte_clickMouse(_get_display(), mouse_button ) return True else: #Display not open raise LibcvDisplayNotOpen( _get_name() )
def mouse_doubleclick_image(image_names, search_method=_search_method_default, tolerance=_tolerance_default, timeout=_timeout_default, mouse_button=_mouse_button_default, use_wait=True, use_center=True): if _check_display(): _log_output('Mouse button doubleclick on image: Images=' + image_names + ' search_method=' + search_method + ' tolerance=' + tolerance + ' timeout=' + _timeout_default + ' mouse_button=' + ' use_wait=' + use_wait + ' use_center=' + use_center) if use_wait: #Loop through all images 'timeout' times, and click on the first match loop_check = 0 while loop_check < timeout: for image in image_names: if use_center: image_location = libcvautomation.xte_clickMouseImage_location_center( _get_display(), image, mouse_button, search_method, tolerance) else: image_location = libcvautomation.xte_clickMouseImage_location( _get_display(), image, mouse_button, search_method, tolerance) if image_location != _libcvautomation_error_location: #Make sure to click twice once we've found the image #Technically assumes that the system mouse timeout is less than #the time it takes to do two boolean compares - I think this is pretty safe libcvautomation.xte_clickMouse(_get_display(), mouse_button) #We've found our image, break out of the for loop and while loop return True loop_check += 1 else: #Just cycle through the images once for image in image_names: if use_center: image_location = libcvautomation.xte_clickMouseImage_location_center( _get_display(), image, mouse_button, search_method, tolerance) else: image_location = libcvautomation.xte_clickMouseImage_location( _get_display(), image, mouse_button, search_method, tolerance) if image_location != _libcvautomation_error_location: #We've found our image, break out of the for loop return True #No image found raise LibcvImageNotFound(image_names) else: #Display not open raise LibcvDisplayNotOpen(_get_name())
def mouse_click_rxy( x_inc, y_inc, mouse_button = _mouse_button_default ): if _check_display(): _log_output( 'Mouse button rxy click: x=' + str(x_inc) + ' y=' + str(y_inc) + ' mouse_button=' + mouse_button ) libcvautomation.xte_hoverMouseRXY(_get_display(), x_inc, y_inc ) libcvautomation.xte_clickMouse(_get_display(), mouse_button ) return True else: #Display not open raise LibcvDisplayNotOpen( _get_name() )
def mouse_click_rxy(x_inc, y_inc, mouse_button=_mouse_button_default): if _check_display(): _log_output('Mouse button rxy click: x=' + str(x_inc) + ' y=' + str(y_inc) + ' mouse_button=' + mouse_button) libcvautomation.xte_hoverMouseRXY(_get_display(), x_inc, y_inc) libcvautomation.xte_clickMouse(_get_display(), mouse_button) return True else: #Display not open raise LibcvDisplayNotOpen(_get_name())
def mouse_click_xy( x_coord, y_coord, mouse_button = _mouse_button_default ): if _check_display(): _log_output( 'Mouse button xy click: x=' + str(x_coord) + ' y=' + str(y_coord) + ' mouse_button=' + mouse_button ) current_location = libcvautomation.xte_mouseLocation(_get_display() ) x_increment = x_coord - current_location.x y_increment = y_coord - current_location.y libcvautomation.xte_hoverMouseRXY(_get_display(), x_increment, y_increment ) libcvautomation.xte_clickMouse(_get_display(), mouse_button ) return True else: #Display not open raise LibcvDisplayNotOpen( _get_name() )
def mouse_doubleclick_image( image_names, search_method = _search_method_default, tolerance = _tolerance_default, timeout = _timeout_default, mouse_button = _mouse_button_default, use_wait = True, use_center = True ): if _check_display(): _log_output( 'Mouse button doubleclick on image: Images=' + image_names + ' search_method=' + search_method + ' tolerance=' + tolerance + ' timeout=' + _timeout_default + ' mouse_button=' + ' use_wait=' + use_wait + ' use_center=' + use_center) if use_wait: #Loop through all images 'timeout' times, and click on the first match loop_check = 0 while loop_check < timeout: for image in image_names: if use_center: image_location = libcvautomation.xte_clickMouseImage_location_center(_get_display(), image, mouse_button, search_method, tolerance ) else: image_location = libcvautomation.xte_clickMouseImage_location(_get_display(), image, mouse_button, search_method, tolerance ) if image_location != _libcvautomation_error_location: #Make sure to click twice once we've found the image #Technically assumes that the system mouse timeout is less than #the time it takes to do two boolean compares - I think this is pretty safe libcvautomation.xte_clickMouse(_get_display(), mouse_button ) #We've found our image, break out of the for loop and while loop return True loop_check += 1 else: #Just cycle through the images once for image in image_names: if use_center: image_location = libcvautomation.xte_clickMouseImage_location_center(_get_display(), image, mouse_button, search_method, tolerance ) else: image_location = libcvautomation.xte_clickMouseImage_location(_get_display(), image, mouse_button, search_method, tolerance ) if image_location != _libcvautomation_error_location: #We've found our image, break out of the for loop return True #No image found raise LibcvImageNotFound( image_names ) else: #Display not open raise LibcvDisplayNotOpen( _get_name() )
def mouse_click_xy(x_coord, y_coord, mouse_button=_mouse_button_default): if _check_display(): _log_output('Mouse button xy click: x=' + str(x_coord) + ' y=' + str(y_coord) + ' mouse_button=' + mouse_button) current_location = libcvautomation.xte_mouseLocation(_get_display()) x_increment = x_coord - current_location.x y_increment = y_coord - current_location.y libcvautomation.xte_hoverMouseRXY(_get_display(), x_increment, y_increment) libcvautomation.xte_clickMouse(_get_display(), mouse_button) return True else: #Display not open raise LibcvDisplayNotOpen(_get_name())