|
|
@@ -513,11 +513,12 @@ class BaseTask(GlobalGameAssets, CostumeBase):
|
|
|
return True
|
|
|
return False
|
|
|
|
|
|
- def ocr_appear(self, target: RuleOcr, interval: float = None) -> bool:
|
|
|
+ def ocr_appear(self, target: RuleOcr, interval: float = None, exact: bool = False) -> bool:
|
|
|
"""
|
|
|
ocr识别目标
|
|
|
:param interval:
|
|
|
:param target:
|
|
|
+ :param exact: 是否只匹配完整的单个 OCR 文本
|
|
|
:return: 如果target有keyword或者是keyword存在,返回是True,否则返回False
|
|
|
但是没有指定keyword,返回的是匹配到的值,具体取决于target的mode
|
|
|
"""
|
|
|
@@ -536,7 +537,7 @@ class BaseTask(GlobalGameAssets, CostumeBase):
|
|
|
if not self.interval_timer[target.name].reached():
|
|
|
return None
|
|
|
|
|
|
- result = target.ocr(self.device.image)
|
|
|
+ result = target.ocr(self.device.image, exact=exact)
|
|
|
appear = False
|
|
|
|
|
|
if not target.keyword or target.keyword == '':
|
|
|
@@ -562,16 +563,18 @@ class BaseTask(GlobalGameAssets, CostumeBase):
|
|
|
target: RuleOcr,
|
|
|
action: Union[RuleClick, RuleLongClick] = None,
|
|
|
interval: float = None,
|
|
|
- duration: float = None) -> bool:
|
|
|
+ duration: float = None,
|
|
|
+ exact: bool = False) -> bool:
|
|
|
"""
|
|
|
ocr识别目标,如果目标存在,则触发动作
|
|
|
:param target:
|
|
|
:param action:
|
|
|
:param interval:
|
|
|
:param duration:
|
|
|
+ :param exact: 是否只匹配完整的单个 OCR 文本
|
|
|
:return:
|
|
|
"""
|
|
|
- appear = self.ocr_appear(target, interval)
|
|
|
+ appear = self.ocr_appear(target, interval, exact=exact)
|
|
|
|
|
|
if not appear:
|
|
|
return False
|
|
|
@@ -826,4 +829,4 @@ class BaseTask(GlobalGameAssets, CostumeBase):
|
|
|
logger.info(f'Push notify: {content}')
|
|
|
|
|
|
def save_image(self, task_name=None, content=None, wait_time=2, image_type=False, push_flag=False, level=3):
|
|
|
- logger.info(f'Save image: {task_name}')
|
|
|
+ logger.info(f'Save image: {task_name}')
|