|
|
|
@ -315,7 +315,7 @@ def BoxOverlay(inBox1, inBox2) -> bool:
|
|
|
|
|
"""
|
|
|
|
|
return not ((inBox1.left>inBox2.left + inBox2.width or inBox2.left>inBox1.left + inBox1.width) or (inBox1.top>inBox2.top + inBox2.height or inBox2.top>inBox1.top + inBox1.height))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import re
|
|
|
|
|
def BoxGetPoint(inBox, inPointRuleStr="CC") -> pyscreeze.Point:
|
|
|
|
|
"""Получить точку pyscreeze.Point по заданной прямоугольной области pyscreeze.Box и строковому параметру расположения inPointRuleStr.
|
|
|
|
|
|
|
|
|
@ -333,16 +333,26 @@ def BoxGetPoint(inBox, inPointRuleStr="CC") -> pyscreeze.Point:
|
|
|
|
|
:return: Точка на экране
|
|
|
|
|
:rtype: pyscreeze.Point
|
|
|
|
|
"""
|
|
|
|
|
lPoint = None
|
|
|
|
|
inPointRuleStr = inPointRuleStr.upper()
|
|
|
|
|
if "CC" in inPointRuleStr: return pyscreeze.Point(x=inBox.left + inBox.width/2,y=inBox.top + inBox.height/2)
|
|
|
|
|
elif "LU" in inPointRuleStr: return pyscreeze.Point(x=inBox.left,y=inBox.top)
|
|
|
|
|
elif "RU" in inPointRuleStr: return pyscreeze.Point(x=inBox.left + inBox.width,y=inBox.top)
|
|
|
|
|
elif "CU" in inPointRuleStr: return pyscreeze.Point(x=inBox.left + inBox.width/2,y=inBox.top)
|
|
|
|
|
elif "LC" in inPointRuleStr: return pyscreeze.Point(x=inBox.left,y=inBox.top + inBox.height/2)
|
|
|
|
|
elif "RC" in inPointRuleStr: return pyscreeze.Point(x=inBox.left + inBox.width,y=inBox.top + inBox.height/2)
|
|
|
|
|
elif "LD" in inPointRuleStr: return pyscreeze.Point(x=inBox.left,y=inBox.top + inBox.height)
|
|
|
|
|
elif "CD" in inPointRuleStr: return pyscreeze.Point(x=inBox.left + inBox.width/2,y=inBox.top + inBox.height)
|
|
|
|
|
elif "RD" in inPointRuleStr: return pyscreeze.Point(x=inBox.left + inBox.width,y=inBox.top + inBox.height)
|
|
|
|
|
if "CC" in inPointRuleStr: lPoint = pyscreeze.Point(x=inBox.left + inBox.width/2,y=inBox.top + inBox.height/2)
|
|
|
|
|
elif "LU" in inPointRuleStr: lPoint = pyscreeze.Point(x=inBox.left,y=inBox.top)
|
|
|
|
|
elif "RU" in inPointRuleStr: lPoint = pyscreeze.Point(x=inBox.left + inBox.width,y=inBox.top)
|
|
|
|
|
elif "CU" in inPointRuleStr: lPoint = pyscreeze.Point(x=inBox.left + inBox.width/2,y=inBox.top)
|
|
|
|
|
elif "LC" in inPointRuleStr: lPoint = pyscreeze.Point(x=inBox.left,y=inBox.top + inBox.height/2)
|
|
|
|
|
elif "RC" in inPointRuleStr: lPoint = pyscreeze.Point(x=inBox.left + inBox.width,y=inBox.top + inBox.height/2)
|
|
|
|
|
elif "LD" in inPointRuleStr: lPoint = pyscreeze.Point(x=inBox.left,y=inBox.top + inBox.height)
|
|
|
|
|
elif "CD" in inPointRuleStr: lPoint = pyscreeze.Point(x=inBox.left + inBox.width/2,y=inBox.top + inBox.height)
|
|
|
|
|
elif "RD" in inPointRuleStr: lPoint = pyscreeze.Point(x=inBox.left + inBox.width,y=inBox.top + inBox.height)
|
|
|
|
|
# Корректировка при необходимости
|
|
|
|
|
lDXInt=0
|
|
|
|
|
lDYInt=0
|
|
|
|
|
lMatchY = re.search(r'.*Y([-+]?\d*).*', inPointRuleStr)
|
|
|
|
|
if lMatchY is not None: lDYInt=int(lMatchY.group(1))
|
|
|
|
|
lMatchX = re.search(r'.*X([-+]?\d*).*', inPointRuleStr)
|
|
|
|
|
if lMatchX is not None: lDXInt=int(lMatchX.group(1))
|
|
|
|
|
lPoint = PointModify(inPoint=lPoint,inDXInt=lDXInt,inDYInt=lDYInt)
|
|
|
|
|
return lPoint
|
|
|
|
|
|
|
|
|
|
def PointModify(inPoint, inDXInt, inDYInt) -> pyscreeze.Point:
|
|
|
|
|
"""Скорректировать точку pyscreeze.Point.
|
|
|
|
@ -589,7 +599,7 @@ def ImageWaitDisappear(inImgPathStr:str, inWaitSecFloat:float=IMAGE_WAIT_SEC_FLO
|
|
|
|
|
time.sleep(inWaitIntervalSecFloat)
|
|
|
|
|
return lResultList
|
|
|
|
|
|
|
|
|
|
def ImageClick(inImgPathStr:str,inBoxIndexInt:int = 0, inPointRuleStr:str="CC", inIsGrayModeBool:bool=False, inConfidenceFloat:float=1.0):
|
|
|
|
|
def ImageClick(inImgPathStr:str,inBoxIndexInt:int = 0, inPointRuleStr:str="CC", inIsGrayModeBool:bool=False, inConfidenceFloat:float=1.0, inWaitSecFloat:float=0, inWaitIntervalSecFloat:float = 0):
|
|
|
|
|
"""Выполнить поиск прямоугольной области по изображению.
|
|
|
|
|
|
|
|
|
|
.. code-block:: python
|
|
|
|
@ -608,5 +618,13 @@ def ImageClick(inImgPathStr:str,inBoxIndexInt:int = 0, inPointRuleStr:str="CC",
|
|
|
|
|
:type inIsGrayModeBool: bool, опционально
|
|
|
|
|
:param inConfidenceFloat: Показатель точности. 1.0 - идентичное соответствие, 0.0 - полное несоответствие. По умолчанию 1.0
|
|
|
|
|
:type inConfidenceFloat: float, опционально
|
|
|
|
|
:param inWaitSecFloat: Время ожидания появления изображения в сек. По умолчанию 0
|
|
|
|
|
:type inWaitSecFloat: float, опциональный
|
|
|
|
|
:param inWaitIntervalSecFloat: Интервал повторной проверки наличия изображения. По умолчанию 0
|
|
|
|
|
:type inWaitIntervalSecFloat: float, опциональный
|
|
|
|
|
"""
|
|
|
|
|
if inWaitSecFloat > 0:
|
|
|
|
|
lBoxList = ImageWaitAppear(inImgPathStr=inImgPathStr,inWaitSecFloat=inWaitSecFloat,inWaitIntervalSecFloat=inWaitIntervalSecFloat,inIsGrayModeBool=inIsGrayModeBool,inConfidenceFloat=inConfidenceFloat)
|
|
|
|
|
if len(lBoxList)>0: PointClick(inPoint=BoxGetPoint(lBoxList[inBoxIndexInt],inPointRuleStr=inPointRuleStr))
|
|
|
|
|
else:
|
|
|
|
|
PointClick(BoxGetPoint(inBox=ImageLocateAll(inImgPathStr=inImgPathStr,inIsGrayModeBool=inIsGrayModeBool,inConfidenceFloat=inConfidenceFloat)[inBoxIndexInt],inPointRuleStr=inPointRuleStr))
|
|
|
|
|