trumpoikot
Addict
- Joined
- Nov 16, 2021
- Posts
- 110
- Reaction
- 65
- Points
- 81
pyautogui not working if monitor is turned off, any alternative to detect pixel rgb even monitor is turned off
from PIL import ImageGrab
# Take a screenshot of the entire screen
screen = ImageGrab.grab()
# Define the region of interest
roi = (100, 100, 200, 200) # (left, top, right, bottom)
# Crop the screenshot to the region of interest
crop = screen.crop(roi)
# Get the RGB value at a specific pixel
pixel_rgb = crop.getpixel((50, 50))
print(pixel_rgb) # prints (R, G, B) tuple