From ced12fa3b488bb0354ee68dd8e1266e210e6bcd3 Mon Sep 17 00:00:00 2001 From: Sacrezar Date: Thu, 8 Oct 2020 13:07:00 +0200 Subject: [PATCH 1/2] add autoclicker --- autoclicker/README.md | 15 ++++++++++ autoclicker/autoclicker.py | 57 ++++++++++++++++++++++++++++++++++++ autoclicker/requirements.txt | 2 ++ 3 files changed, 74 insertions(+) create mode 100644 autoclicker/README.md create mode 100644 autoclicker/autoclicker.py create mode 100644 autoclicker/requirements.txt diff --git a/autoclicker/README.md b/autoclicker/README.md new file mode 100644 index 000000000..88bbe1d7f --- /dev/null +++ b/autoclicker/README.md @@ -0,0 +1,15 @@ +# 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 \ No newline at end of file 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 From b22447aa18bbb9c035a827c8fe96479c483a5c45 Mon Sep 17 00:00:00 2001 From: Thomas S Date: Thu, 8 Oct 2020 13:08:43 +0200 Subject: [PATCH 2/2] Update README.md --- autoclicker/README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autoclicker/README.md b/autoclicker/README.md index 88bbe1d7f..325d9b7e5 100644 --- a/autoclicker/README.md +++ b/autoclicker/README.md @@ -3,7 +3,9 @@ This is a basic autoclicker, you can choose the delay you want between each clic ## Prerequisites **Python 3.8.x** + Install the requirements: + `python -m pip install -r requirements.txt --user` Then you can run the script! @@ -12,4 +14,4 @@ Then you can run the script! Key | Action --- | --- F1 | Resume / Pause -ESC | Exit the program \ No newline at end of file +ESC | Exit the program