|
@@ -46,13 +46,13 @@ def binarize_image(image):
|
|
return threshold
|
|
return threshold
|
|
|
|
|
|
|
|
|
|
-def waitFindImg(imgPath, waitTime, preWaitTime):
|
|
|
|
|
|
+def waitFindImg(imgPath, waitTime, preWaitTime, isCV=False):
|
|
if preWaitTime > 0:
|
|
if preWaitTime > 0:
|
|
myTimeSleep(preWaitTime)
|
|
myTimeSleep(preWaitTime)
|
|
#sleep 0.2s per times
|
|
#sleep 0.2s per times
|
|
curTime = 0
|
|
curTime = 0
|
|
while waitTime == -1 or curTime < waitTime:
|
|
while waitTime == -1 or curTime < waitTime:
|
|
- ret, pos_cur = pcacc_img.find_imgs(imgPath)
|
|
|
|
|
|
+ ret, pos_cur = pcacc_img.find_imgs(imgPath, isCV)
|
|
if ret:
|
|
if ret:
|
|
return ret, pos_cur
|
|
return ret, pos_cur
|
|
else:
|
|
else:
|
|
@@ -61,35 +61,18 @@ def waitFindImg(imgPath, waitTime, preWaitTime):
|
|
|
|
|
|
return False, None
|
|
return False, None
|
|
|
|
|
|
-def waitFindImg_withBool(imgPath, waitTime, preWaitTime):
|
|
|
|
- ret, pos = waitFindImg(imgPath, waitTime, preWaitTime)
|
|
|
|
|
|
+def waitFindImg_withBool(imgPath, waitTime, preWaitTime, isCV=False):
|
|
|
|
+ ret, pos = waitFindImg(imgPath, waitTime, preWaitTime, isCV)
|
|
return ret
|
|
return ret
|
|
|
|
|
|
-def waitFindImgPosition(imgPath, waitTime, preWaitTime):
|
|
|
|
- if preWaitTime > 0:
|
|
|
|
- myTimeSleep(preWaitTime)
|
|
|
|
- #sleep 0.2s per times
|
|
|
|
- curTime = 0
|
|
|
|
- while waitTime == -1 or curTime < waitTime:
|
|
|
|
- ret, pos_cur = pcacc_img.find_img_position(imgPath)
|
|
|
|
- if ret:
|
|
|
|
- return ret, pos_cur
|
|
|
|
- else:
|
|
|
|
- myTimeSleep(0.2)
|
|
|
|
- curTime = curTime + 0.2
|
|
|
|
- return False, None
|
|
|
|
-
|
|
|
|
-def waitFindImgPosition_withBool(imgPath, waitTime, preWaitTime):
|
|
|
|
- ret, pos = waitFindImgPosition(imgPath, waitTime, preWaitTime)
|
|
|
|
- return ret
|
|
|
|
|
|
|
|
-def waitClickImg_noWait(imgPath, waitTime, preWaitTime):
|
|
|
|
|
|
+def waitClickImg_noWait(imgPath, waitTime, preWaitTime, isCV=False):
|
|
if preWaitTime > 0:
|
|
if preWaitTime > 0:
|
|
myTimeSleep(preWaitTime)
|
|
myTimeSleep(preWaitTime)
|
|
#sleep 0.2s per times
|
|
#sleep 0.2s per times
|
|
curTime = 0
|
|
curTime = 0
|
|
while waitTime == -1 or curTime < waitTime:
|
|
while waitTime == -1 or curTime < waitTime:
|
|
- ret, pos_cur = pcacc_img.find_imgs(imgPath)
|
|
|
|
|
|
+ ret, pos_cur = pcacc_img.find_imgs(imgPath, isCV)
|
|
if ret:
|
|
if ret:
|
|
pcacc_mouse.click(pos_cur[0], pos_cur[1])
|
|
pcacc_mouse.click(pos_cur[0], pos_cur[1])
|
|
myTimeSleep(0.5)
|
|
myTimeSleep(0.5)
|
|
@@ -99,8 +82,8 @@ def waitClickImg_noWait(imgPath, waitTime, preWaitTime):
|
|
curTime = curTime + 0.2
|
|
curTime = curTime + 0.2
|
|
return False, (-1, -1)
|
|
return False, (-1, -1)
|
|
|
|
|
|
-def waitClickImg_noWait_withBool(imgPath, waitTime, preWaitTime):
|
|
|
|
- ret, pos = waitClickImg_noWait(imgPath, waitTime, preWaitTime)
|
|
|
|
|
|
+def waitClickImg_noWait_withBool(imgPath, waitTime, preWaitTime, isCV=False):
|
|
|
|
+ ret, pos = waitClickImg_noWait(imgPath, waitTime, preWaitTime, isCV)
|
|
return ret
|
|
return ret
|
|
|
|
|
|
|
|
|
|
@@ -130,34 +113,34 @@ def waitclickMultiImg(imgArr, waitTime, preWaitTime):
|
|
return False, (-1, -1)
|
|
return False, (-1, -1)
|
|
|
|
|
|
|
|
|
|
-def waitClickImg(imgPath, waitTime, preWaitTime):
|
|
|
|
|
|
+def waitClickImg(imgPath, waitTime, preWaitTime, isCV=False):
|
|
if preWaitTime > 0:
|
|
if preWaitTime > 0:
|
|
myTimeSleep(preWaitTime)
|
|
myTimeSleep(preWaitTime)
|
|
#sleep 0.2s per times
|
|
#sleep 0.2s per times
|
|
curTime = 0
|
|
curTime = 0
|
|
while waitTime == -1 or curTime < waitTime:
|
|
while waitTime == -1 or curTime < waitTime:
|
|
- ret, pos_cur = pcacc_img.find_imgs(imgPath)
|
|
|
|
|
|
+ ret, pos_cur = pcacc_img.find_imgs(imgPath, isCV)
|
|
if ret:
|
|
if ret:
|
|
pcacc_mouse.move_mouse(pos_cur[0], pos_cur[1])
|
|
pcacc_mouse.move_mouse(pos_cur[0], pos_cur[1])
|
|
- ret, pos_cur2 = pcacc_img.find_imgs(imgPath)
|
|
|
|
|
|
+ ret, pos_cur2 = pcacc_img.find_imgs(imgPath, isCV)
|
|
if ret:
|
|
if ret:
|
|
pcacc_mouse.click(pos_cur2[0], pos_cur2[1])
|
|
pcacc_mouse.click(pos_cur2[0], pos_cur2[1])
|
|
else:
|
|
else:
|
|
pcacc_mouse.click(pos_cur[0], pos_cur[1])
|
|
pcacc_mouse.click(pos_cur[0], pos_cur[1])
|
|
myTimeSleep(0.5)
|
|
myTimeSleep(0.5)
|
|
- ret, pos_cur = pcacc_img.find_imgs(imgPath)
|
|
|
|
|
|
+ ret, pos_cur = pcacc_img.find_imgs(imgPath, isCV)
|
|
if ret == False:
|
|
if ret == False:
|
|
return True, pos_cur
|
|
return True, pos_cur
|
|
|
|
|
|
pcacc_mouse.move_mouse(pos_cur[0], pos_cur[1])
|
|
pcacc_mouse.move_mouse(pos_cur[0], pos_cur[1])
|
|
- ret, pos_cur2 = pcacc_img.find_imgs(imgPath)
|
|
|
|
|
|
+ ret, pos_cur2 = pcacc_img.find_imgs(imgPath, isCV)
|
|
if ret:
|
|
if ret:
|
|
pcacc_mouse.click(pos_cur2[0], pos_cur2[1])
|
|
pcacc_mouse.click(pos_cur2[0], pos_cur2[1])
|
|
else:
|
|
else:
|
|
pcacc_mouse.click(pos_cur[0], pos_cur[1])
|
|
pcacc_mouse.click(pos_cur[0], pos_cur[1])
|
|
|
|
|
|
myTimeSleep(0.5)
|
|
myTimeSleep(0.5)
|
|
- ret, pos_cur = pcacc_img.find_imgs(imgPath)
|
|
|
|
|
|
+ ret, pos_cur = pcacc_img.find_imgs(imgPath, isCV)
|
|
if ret == False:
|
|
if ret == False:
|
|
return True, pos_cur
|
|
return True, pos_cur
|
|
else:
|
|
else:
|
|
@@ -167,8 +150,8 @@ def waitClickImg(imgPath, waitTime, preWaitTime):
|
|
curTime = curTime + 0.2
|
|
curTime = curTime + 0.2
|
|
return False, (-1, -1)
|
|
return False, (-1, -1)
|
|
|
|
|
|
-def waitClickImg_withBool(imgPath, waitTime, preWaitTime):
|
|
|
|
- ret, pos = waitClickImg(imgPath, waitTime, preWaitTime)
|
|
|
|
|
|
+def waitClickImg_withBool(imgPath, waitTime, preWaitTime, isCV=False):
|
|
|
|
+ ret, pos = waitClickImg(imgPath, waitTime, preWaitTime, isCV)
|
|
return ret
|
|
return ret
|
|
|
|
|
|
def myTimeSleep(curTime , FunStatus=None):
|
|
def myTimeSleep(curTime , FunStatus=None):
|