Ever found yourself needing to perform repetitive right-click actions on your Mac? Tired of manually doing it? Here's a nifty Python script that automates this task, making your life significantly easier with just a keyboard shortcut!
Features
- Automated Right-Clicking: Use the Cmd + Z key combination to start or stop the right-click automation.
- Simple Interface: No GUI needed; everything is controlled via your keyboard and terminal feedback.
Requirements
- Python 3.x: Essential for running the script.
- pynput Library: Used for controlling mouse and keyboard inputs.
Installation
- Install Python: Ensure Python 3 is installed. Download it from Python's official site.
Install pynput:
pip install pynput
Clone the Repository:
git clone https://github.com/MuckyRat/AutoRightClick.git
cd AutoRightClick
UsageTo get started:
- Control the Clicking:
- Start/Stop Clicking: Use Cmd + Z.
- Exit Script: Use Ctrl + C in the terminal.
Run the Script:
python AutoRightClick.py
Navigate to Script Directory:
cd path/to/your/script
The Script
Here's what the script does internally:
import threading
import time
from pynput.mouse import Button, Controller as MouseController
from pynput import keyboard
clicking = False # Global control for clicking state
def click_right():
global clicking
mouse = MouseController()
while clicking:
mouse.click(Button.right)
time.sleep(0.05) # Delay for 50ms between clicks
def toggle_clicking():
global clicking
clicking = not clicking
if clicking:
threading.Thread(target=click_right, daemon=True).start()
print("Started clicking.")
else:
print("Stopped clicking.")
def on_activate():
toggle_clicking()
hotkey = keyboard.GlobalHotKeys({
'<cmd>+z': on_activate
})
hotkey.start()
print("Press Cmd + Z to start/stop right clicking.")
print("Press Ctrl + C to exit the program.")
try:
while True:
time.sleep(0.1)
except KeyboardInterrupt:
print("Exiting...")
Conclusion
This script is perfect for anyone looking to automate repetitive right-click actions on a MacBook. Whether you're testing software, automating tasks, or just saving time, this script has got you covered. Check out the full project on my GitHub.
Feel free to contribute, suggest changes, or report issues directly on the repository!
Happy automating!