在制作pyautogui程序时,我得到了一个windows错误和操作系统错误的问题。

问题描述 投票:0回答:1

当我运行下面的代码时,我得到了这个错误。

文件 "e:\pranil\python\doing shit with python\automating dino game.py", 第12行, in if auto.pixelMatchesColor(i,j, (83, 83, 83)): 文件 "C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python\Python38\libsite-packages\pyscreeze__init__.py", 第559行, in pixelMatchesColor pixel = pixel(x, y) 文件 "C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python38\libsite-packages\pyscreeze__init__.py", 第559行, in pixelMatchesColor pixel(x, y) 文件 "C:\Users\Pranil.DESKTOP-TLQKP4G.000\AppData\Local\Programs\Python38\pyscreeze__init__.py 文件 "C:\Users\\Pranil.DESKTOP-TLQKP4G.000AppData\Local\Programs\Python\Python38\lib\site-packages\pyscreeze__init__.py",第584行,在像素中返回(r,g,b)文件 "C:\Users\Pranil.DESKTOP-TLQKP4G.000AppData\Local\Programs\Python\Python38\lib\contextlib.py",第120行。退出 next(self.gen) 文件 "C:Users/Pranil.DESKTOP-TLQKP4G.000/AppData/Local/Programs/Python/Python38/lib/sit-packages/pyscreeze__init__.py",第113行,在__win32_openDC中引发WindowsError("windll.user32.ReleaseDC failed : return 0")OSError: windll.user32.ReleaseDC failed : return 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
python python-3.x windows pyautogui
1个回答
0
投票

我建议你把你的python从3.8降级到3.7,因为这就解决了我的问题。

© www.soinside.com 2019 - 2024. All rights reserved.