diff --git a/autoclicker/README.md b/autoclicker/README.md new file mode 100644 index 000000000..325d9b7e5 --- /dev/null +++ b/autoclicker/README.md @@ -0,0 +1,17 @@ +# AutoClicker +This is a basic autoclicker, you can choose the delay you want between each click. +## Prerequisites + +**Python 3.8.x** + +Install the requirements: + +`python -m pip install -r requirements.txt --user` + +Then you can run the script! + +## Controls +Key | Action +--- | --- +F1 | Resume / Pause +ESC | Exit the program diff --git a/autoclicker/autoclicker.py b/autoclicker/autoclicker.py new file mode 100644 index 000000000..f0091fe75 --- /dev/null +++ b/autoclicker/autoclicker.py @@ -0,0 +1,57 @@ +import pyautogui +from pynput.keyboard import Key, Listener + +# ======== Controls ======== +start_or_pause_key = Key.f1 +exit_key = Key.esc +delay = 1 # seconds + +# ==== global variables ==== +pause = True +running = True + + +def display_controls(): + + print("F1 = Start / Pause") + print("ESC = Exit\n") + + +def choose_delay(): + + try: + return float(input("Enter wanted delay (seconds): ")) + except ValueError: + print(f"You did not give a valid input, default delay : {delay}sec") + return delay + + +def key_press(key): + global running, pause + + if key == start_or_pause_key: + pause = not pause + print("< Pause >") if pause else print("< Start >") + elif key == exit_key: + running = False + print("< Exit >") + + +def main(): + + delay = choose_delay() + print(f"delay = {str(delay)}sec\n") + display_controls() + + listener = Listener(on_press=key_press) + listener.start() + + while running: + if not pause: + pyautogui.click(pyautogui.position()) + pyautogui.PAUSE = delay + listener.stop() + + +if __name__ == "__main__": + main() diff --git a/autoclicker/requirements.txt b/autoclicker/requirements.txt new file mode 100644 index 000000000..68db6c87f --- /dev/null +++ b/autoclicker/requirements.txt @@ -0,0 +1,2 @@ +pyautogui +pynput \ No newline at end of file