I'm not sure wheteher I wrote the question right, but here's the problem.
I wrote a script in Python in PIL that will take a screenshot of the current screen and check a pixel. If the pixel is a certain color, then do something, if not, do something else. Here's the code.
from PIL import ImageGrab
import time
time.sleep(3)
coords = (335, 245, 753, 351)
running = True
x = 1
moved = False
while running:
image = ImageGrab.grab(bbox=coords)
isRed = image.getpixel((60, 60)) == (237, 28, 36)
if isRed:
print('1' , x)
x += 1
else:
time.sleep(3)
if not moved:
moved = True
continue
running = False
print('Stopped.')
So I wrote the script it's working as intended, but let's say it needs to keep running for quite some minutes and I want to do some other stuff on my PC, So then virtual desktops came into mind. I thought and ultimately assumed that if i make a virtual desktop (iam using win 10), The app will keep running as intended on one virtal desktop, and i can do the rest on the other one. (makes sense to me). But when I run the script, the script stops, meanning it did not find the pixels it was looking for, which means it is scanning the new virtual desktop, and not the one in which it's opened and running.
Makes no sense to me, Please tell me a way to go arround this, or if this is not possible and Im totally stupid. Thanks.
question from:
https://stackoverflow.com/questions/66052021/python-pil-functionality-broke-when-switching-virtual-desktops 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…