How to use the ImageGrab.grab().load() function or any other function to get pixel updates?

后端 未结 1 1865
隐瞒了意图╮
隐瞒了意图╮ 2020-12-21 22:31

I have been trying to check if a pixel on the screen is changing. What do I need to do?

I have surfed the internet for a long time with no success. I have experiment

相关标签:
1条回答
  • 2020-12-21 23:27

    This works for me:

    #!/usr/bin/env python3
    
    from PIL import ImageGrab
    
    while True:
       px=ImageGrab.grab().load()
       m=px[613,296]
       print(m)
    

    I think it will be faster if you just grab one pixel though by specifying a bounding box like this so you only grab one pixel:

    #!/usr/bin/env python3
    
    from PIL import ImageGrab
    
    while True:
       screen=ImageGrab.grab(bbox=(613,296,614,297))
       px = screen.load()
       m=px[0,0]
       print(m,screen.size)
    
    0 讨论(0)
提交回复
热议问题