PyAutoGuilocateOnScreen无法正常工作

时间:2020-07-06 14:15:02

标签: python pyautogui

我想做一个简单的机器人来学习pyautogui功能,但一开始我就遇到了一个问题。

import pyautogui
import keyboard
import time

def locate(image):
    pyautogui.locateOnScreen(image, grayscale = True, confidence = 0.9)
                             
x = pyautogui.locateOnScreen('test2.png', grayscale = True, confidence = 0.9)

y = locate('test2.png')

while keyboard.is_pressed('q') == False:   # I put locateOnScreen  \/  as a control test
    print(x, y, locate('test2.png'), pyautogui.locateOnScreen('test2.png', grayscale = True, confidence = 0.9))
    time.sleep(1)

当执行的程序返回时:

None None None Box(left=452, top=767, width=702, height=88)

因此,x, y and locate()函数似乎无法正常运行,即使它们由pyautogui.locateOnScreen组成并且具有相同的值。

0 个答案:

没有答案