【发布时间】:2020-06-16 08:40:19
【问题描述】:
当我运行下面的代码时,我得到了这个错误:
文件“e:\pranil\python\doing shit with python\automating dino game.py”,第 12 行,在 如果 auto.pixelMatchesColor(i,j, (83, 83, 83)): 文件“C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python\Python38\lib\site-packages\pyscreez__init__.py”,第 559 行,以 pixelMatchesColor 为单位 pix = 像素(x, y) 文件“C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python\Python38\lib\site-packages\pyscreez__init__.py”,第 584 行,以像素为单位 返回 (r, g, b) 退出中的文件“C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python\Python38\lib\contextlib.py”,第 120 行 下一个(self.gen) 文件“C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python\Python38\lib\site-packages\pyscreez__init__.py”,第 113 行,在 __win32_openDC 引发 WindowsError(“windll.user32.ReleaseDC 失败:返回 0”) 操作系统错误:windll.user32.ReleaseDC 失败:返回 0
import pyautogui as auto
from PIL import Image, ImageColor
import time
import keyboard
auto.FAILSAFE = False
time.sleep(2)
# print(auto.position())
while True:
sshot = auto.screenshot()
for j in range(510, 514):
for i in range(316, 350):
if auto.pixelMatchesColor(i,j, (83, 83, 83)):
auto.press('up')
if keyboard.is_pressed('q'):
break
【问题讨论】:
-
这是一个错误。看到这个答案:stackoverflow.com/a/67988905/495990
-
现在是
pyscreeze-1.0.28中的fixed(pyautogui使用它以及错误所在的位置)。
标签: python python-3.x windows pyautogui