refarm
Not enough ratings
Save your mouse - Python Autoclicker
By Dood
A guide on how to get a python autoclicker up and running to save your mouse from clicking on all the crops that need harvesting.
   
Award
Favorite
Favorited
Unfavorite
Save your mouse with a python!
This is just a quick little python script that I got made while waiting for my crops to grow and will save your mouse from dying from all the clicks.

Once running, Click the middle mouse button to toggle the auto-clicker. If your mouse has a button 4 (The side buttons), you can click to toggle the left mouse button being held.

How to run

If you dont have python installed. Get it here [www.python.org]

Open up notepad or text editor of choice, copy and paste the code at the bottom of the guide and save it as autoclicker.py

Now... find the file you just saved, right click and open with Python.

Binding's

Middle Mouse: Toggles the autoclicker
Mouse Button 4 (Side button): Toggles hold left click
F1: Closes the program/script

Notes

I may need to give better instructions for older windows, macs... linux "ew, tbf... if you are on linux you should know how to use terminal", but seems to be the easiest way to give instructions on how to run on Windows 10.

Drop a comment if your mouse was saved!
The Code
import keyboard from pynput import mouse import threading import time # Create a mouse controller mouse_controller = mouse.Controller() # Toggles for each action toggle_left_click = False toggle_auto_clicker = False running = True def auto_clicker_thread(): """Thread function for auto clicking every 0.1 seconds.""" global toggle_auto_clicker, running while running: if toggle_auto_clicker: mouse_controller.click(mouse.Button.left) time.sleep(0.1) else: time.sleep(0.01) # Small sleep when not active to prevent high CPU usage def on_mouse_click(x, y, button, pressed): """Handles mouse button toggles.""" global toggle_w, toggle_left_click, toggle_auto_clicker if button == mouse.Button.middle and pressed: toggle_auto_clicker = not toggle_auto_clicker if toggle_auto_clicker: print("Auto Clicker ON - clicking every 0.1s") else: print("Auto Clicker OFF") if button == mouse.Button.x2 and pressed: toggle_left_click = not toggle_left_click if toggle_left_click: mouse_controller.press(mouse.Button.left) print("Holding Left Click") else: mouse_controller.release(mouse.Button.left) print("Released Left Click") def on_key_event(event): """Handles keyboard events.""" global running, toggle_s, toggle_right_click if event.name == 'f1': running = False print("Exiting...") keyboard.release('w') keyboard.release('s') mouse_controller.release(mouse.Button.left) mouse_controller.release(mouse.Button.right) # Start auto clicker thread auto_clicker_thread_obj = threading.Thread(target=auto_clicker_thread, daemon=True) auto_clicker_thread_obj.start() # Start mouse listener mouse_listener = mouse.Listener(on_click=on_mouse_click) mouse_listener.start() # Listen for key events keyboard.on_press(on_key_event) # Keep console open print("=== Mouse Click Script ===") print("Middle Mouse Button -> Toggles Auto Clicker (0.1s interval)") print("Mouse Button 4 -> Toggles Left Click hold") print("Press F1 to exit") keyboard.wait('f1') # Final cleanup - Deactivate on close. just in case mouse_controller.release(mouse.Button.left) mouse_controller.release(mouse.Button.right)