有什么方法可以从桌面背景中获取RGB信息吗



我想要桌面背景应用程序的RGB颜色信息,在特定间隔之间输入像素。我该怎么做?

假设您在windows/macOS上,您可以使用PIL或它的分叉Pillow,如下所示:

import PIL.ImgaeGrab  # Pillow is also imported as PIL
x = y = 10
pixel = (x, y)
scrn = PIL.ImageGrab.grab()
scrn.getpixel(pixel)
>>> (246, 138, 30) # The result for me

对于其他捕捉你屏幕的方法,你可以在这里查看

对于时间间隔,只需使用time.sleep(seconds)

最新更新