Click all positions in a given region
Question:
I currently have a rectangular on the screen, which has the position of (x,y) from (0,69) to (1918,1038)
What I want is to click all the points in this region as fast as I can, and each click has 20 pixel in difference with the old one
How can I implement that, thanks in advance!
Answers:
You can use pyautogui
for the clicking part, and a simple loop for the locations.
import pyautogui
def clickarea(start:tuple, end:tuple, diff:int) -> None:
#segregate x and y values
xloc, yloc = zip(start, end)
for x in range(*xloc, diff):
for y in range(*yloc, diff):
print(f'clicking {x},{y}')
pyautogui.click(x, y)
clickarea((0,69), (1918,1038), 20)
I currently have a rectangular on the screen, which has the position of (x,y) from (0,69) to (1918,1038)
What I want is to click all the points in this region as fast as I can, and each click has 20 pixel in difference with the old one
How can I implement that, thanks in advance!
You can use pyautogui
for the clicking part, and a simple loop for the locations.
import pyautogui
def clickarea(start:tuple, end:tuple, diff:int) -> None:
#segregate x and y values
xloc, yloc = zip(start, end)
for x in range(*xloc, diff):
for y in range(*yloc, diff):
print(f'clicking {x},{y}')
pyautogui.click(x, y)
clickarea((0,69), (1918,1038), 20)