from pynput.mouse import Listener, Button
import pyautogui
import time
# Global variable to store the click coordinates
click_coordinates = None
# Function called on a mouse click
def on_click(x, y, button, pressed):
global click_coordinates
# Check if the left button was pressed
if pressed and button == Button.left:
# Store the click coordinates
click_coordinates = (x, y)
print(f'Click position set at: {click_coordinates}')
# Initialize the Listener to monitor mouse clicks
with Listener(on_click=on_click) as listener:
# Wait for the user to perform a manual click
listener.join()
# Check if the click_coordinates are set
if click_coordinates:
# Get the click coordinates
x, y = click_coordinates
# Perform 100 clicks at the specified position
for _ in range(100):
pyautogui.click(x, y)
time.sleep(0.01) # 10 milliseconds between clicks
print('Spamming complete.')
else:
print('No click coordinates set.')