【问题标题】:i got a windows error and os error while making a pyautogui program我在制作 pyautogui 程序时遇到了 windows 错误和 os 错误
【发布时间】: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

【问题讨论】:

标签: python python-3.x windows pyautogui


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-05-11
    • 2021-04-05
    • 2021-05-22
    • 2016-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-24
    • 2021-04-11
    相关资源
    最近更新 更多