[英]how to get pixel color on screen in python
我真的真的開始/ nooby在這里,我試圖檢測我的屏幕上的綠色,當它出現時單擊鼠標按鈕。 我也使用崇高的文字2,但我也有空閑。
import ImageGrab
import time
time.clock()
image = ImageGrab.grab()
for y in range(0, 100, 10):
for x in range(0, 100, 10):
color = image.getpixel((x, y))
print(time.clock())
我試過這個,但它只是給了我“ModuleNotFoundError:沒有名為'ImageGrab'的模塊”我一直在互聯網上搜索littarl小時,我只是找不到任何有助於安裝枕頭的教程。 這是非常復雜的,我即將放棄
代替
import ImageGrab
采用
from PIL import ImageGrab
您應該已經安裝了PIL。 PIL是“Python圖像庫”,可以從https://www.pythonware.com/products/pil/下載
請注意,PIL很老,似乎只適用於Python 2.x(甚至更舊)。 您也可以使用Python包Pillow,它是PIL的一個分支。 這可以使用pip install Pillow
(最近版本的)Python 2以及3來安裝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.