CastImage = pag.locateCenterOnScreen('Cast.png', region=(426, 579, 643, 676))
PullImage = pag.locateCenterOnScreen('pull.png', region=(426, 579, 643, 676))
stopper = pag.locateCenterOnScreen('stopper.png')
ensure = pag.locateCenterOnScreen('ensure.png', region=(154, 88, 624, 132))
我希望这部分代码更快,因为在屏幕上搜索照片会耗费太多时间(我甚至指定了要搜索这些照片的区域,但没有帮助)。也许我应该去别的图书馆?如何更快地在屏幕上定位图像
以下是我的完整代码:
import pyautogui as pag
import time
def cast():
flag = True
while flag:
CastImage = pag.locateCenterOnScreen('Cast.png', region=(426, 579, 643, 676))
print('searching for cast image')
if CastImage is not None:
time.sleep(0.2)
click = pag.click(CastImage)
print('clicking cast image')
flag = False
def pull():
flag = True
while flag:
PullImage = pag.locateCenterOnScreen('pull.png', region=(426, 579, 643, 676))
print('searching for pull image')
if PullImage is not None:
time.sleep(0.2)
click1 = pag.click(PullImage)
print('clicking pull image')
flag = False
def strength():
flag = True
stopper = pag.locateCenterOnScreen('stopper.png')
ensure = pag.locateCenterOnScreen('ensure.png', region=(154, 88, 624, 132)) # ensures that this is right window(with game)
while flag:
print('Searching for strengthBAR')
strengthgreen = pag.locateOnScreen('strength.png', region=(355, 304, 774, 528))
if strengthgreen is None and ensure is not None:
clickPull = pag.mouseDown(534, 634) # FIXED VALUE
print('PULLING')
if stopper is not None:
flag = False
print('Stopping strength function')
while True:
cast()
pull()
strength()
目前没有回答
相关问题 更多 >
编程相关推荐