def do_click_pos(win_title=None, img_res_path=None, image=None, button="left", curson="Center", offsetX=0, offsetY=0, times=1, image_size=None, fuzzy=True, confidence=0.85, waitfor=WAIT_FOR_IMG): ''' 图片单击,支持全图片,opencv ''' __logger.debug(r'Ready to identify pictures.') try: starttime = time.time() while True: ''' 先使用ImageSearch查找 ''' flg = img_click_au3(win_title, img_res_path, image, button, curson, offsetY, offsetX, times, image_size, waitfor=1) if (not flg) and fuzzy: ''' 使用OpenCv查找点击''' __logger.debug( r'ImageSearch Unmistakable, OpenCV Recognition ') flg = img_click_cv(win_title, img_res_path, image, button, curson, offsetY, offsetX, times, confidence, waitfor=1) if flg: break runtime = time.time() - starttime if runtime >= waitfor: raise error.ImageNotFoundError('Image Not Found') __logger.debug(r'Picture Failure, Waiting for Next Recognition ') time.sleep(TRY_INTERVAL) except Exception as e: raise e finally: __logger.debug(u"end execute[do_click_pos]")
def img_dbclick(win_title=None, img_res_path=None, image=None, mouse_button="left", pos_curson="Center", pos_offsetY=0, pos_offsetX=0, image_size=None, waitfor=WAIT_FOR_IMG): ''' 图片双击,支持全图片,opencv ''' __logger.debug(r'Prepare double-click recognition picture') try: starttime = time.time() while True: ''' 先使用ImageSearch查找 ''' flg = img_click_au3(win_title, img_res_path, image, mouse_button, pos_curson, pos_offsetY, pos_offsetX, 2, image_size, waitfor=1) if not flg: ''' 使用OpenCv查找点击''' __logger.debug( r'ImageSearch Unmistakable, OpenCV Recognition ') flg = img_click_cv(win_title, img_res_path, image, mouse_button, pos_curson, pos_offsetY, pos_offsetX, 2, waitfor=1) if flg: break runtime = time.time() - starttime if runtime >= waitfor: raise error.ImageNotFoundError('Image Not Found') __logger.debug(r'Picture Failure, Waiting for Next Recognition ') time.sleep(TRY_INTERVAL) except Exception as e: raise e finally: __logger.debug(u"end execute[img_dbclick]")
def img_exists(win_title=None, img_res_path=None, image=None, fuzzy=True, confidence=0.85, waitfor=WAIT_FOR_IMG): '''图片是否存在''' is_exists = True __logger.debug(r'Ready img_exists ') try: starttime = time.time() while True: ''' 先使用ImageSearch查找 ''' is_exists = img_exists_au3(win_title, img_res_path, image, waitfor=1) if (not is_exists) and fuzzy: ''' 使用OpenCv查找点击''' __logger.debug( r'ImageSearch Unmistakable, OpenCV Recognition ') is_exists = img_exists_cv(win_title=win_title, img_res_path=img_res_path, image=image, confidence=confidence, waitfor=1) if is_exists: break runtime = time.time() - starttime if runtime >= waitfor: raise error.ImageNotFoundError('Image Not Found') __logger.debug(r'Picture Failure, Waiting for Next Recognition ') time.sleep(TRY_INTERVAL) except Exception as e: pass finally: __logger.debug(u"end execute[img_exists]" + str(is_exists)) return is_exists