generate functionFri, 16 Dec 2022

to click black pixels on a screen

#! /usr/local/bin/python3 from pykeyboard import PyKeyboard from PIL import ImageGrab import time k = PyKeyboard() def clickBlackPixels(): while True: # get the screen box = (20, 20, 80, 80) im = ImageGrab.grab(box) # get the pixels from the screen pixels = im.load() # get the width & height of the screen w, h = im.size # interate each pixel for i in range(w): for j in range(h): # when pixel is black if pixels[i, j] == 0: # click the pixel k.tap_key(k.left_key) time.sleep(0.1) clickBlackPixels()

Questions about programming?Chat with your personal AI assistant