I would like to record and append to a list the x and y coordinates of limited number of mouse clicks (10 in this case (This will be a variable)). The script needs to record the clicks over the desktop, browsers or applications in general.
I am basically trying to create a list of coordinates for a flexible simple macro section of a larger program for desktop automation (Very simple and repetitive work but the layout does change that is why re-recording the coordinates is key).
I have searched through "Automate the boring stuff" and cant get pyautogui to record the positions (It does execute mouse positions perfectly but not the pre-recording list). Also this cannot be limited to a single frame as seems to be the case in pygame.
Im a noob any advice would be appreciated. I have included an image of the error I receive. The list portion is not included yet I will add that later.
from pynput import mouse
NumberOfMouseClicks = 0
def on_click(x, y, button, pressed):
print(x, y)
pynput.mouse.Listener.stop
while NumberOfMouseClicks < 10 :
NumberOfMouseClicks = NumberOfMouseClicks + 1
with mouse.Listener(on_click=on_click) as listener:
listener.join()