python - 在循环中使用 getpixel

标签 python pyautogui rpa

无论它变成什么颜色,值检查都保持不变。它应该每秒给我精确像素的 RGB 值

我尝试以递归的方式进行,简化它,在多个对象上进行测试,结果保持不变。

im = pg.screenshot()
import time

while True:
        check=im.getpixel((216, 169))
        time.sleep(1)
        print(check)

我期望根据像素的颜色(216, 169)动态改变输出。目前我每秒收到相同的 RGB 值。

最佳答案

您只截取一次屏幕截图,然后一遍又一遍地重新检查。这里

while True:
        im = pg.screenshot()
        check = im.getpixel((216, 169))
        time.sleep(1)
        print(check)

现在每秒都会拍摄新的屏幕截图。

PS - 您应该将导入保留在模块的顶部。

关于python - 在循环中使用 getpixel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56278238/

相关文章:

csv - "Read CSV"文件在 UiPath Studio 中丢失

python - 无法在 CentOS 6.10 上编译 Python(OpenSSL 错误)

python - 值错误 : Mixing dicts with non-Series may lead to ambiguous ordering

python - 如何使用 Python 控制 Minecraft 中的鼠标?

automation - 如何附加到 Automation Anywhere 10.5 中的列表?

python - 在 Python 中自动执行将 SPSS 文件 (.spv) 转换为 PDF 的任务

python - 在 C++ 中获取 Python 函数参数名称

python - 在 Python 中,如何删除特定字符周围的字符?

python - 收到 TypeError : Required argument 'object' (pos 1) not found

python - 代码可以在 pyCharm 中运行,但不能在 Visual Studio Code 中运行