Created
August 1, 2023 11:00
-
-
Save makesomelayouts/aa73b54f029067e79b3bb20bdc92cf99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import time | |
| import threading | |
| from pynput.mouse import Controller, Button | |
| from pynput.keyboard import Listener, KeyCode | |
| toggle_key = KeyCode(char='q') | |
| clicking = False | |
| mouse = Controller() | |
| def clicker(): | |
| while True: | |
| if clicking: | |
| mouse.click(Button.left, 1) | |
| time.sleep(0.1) | |
| def toggle_event(key): | |
| if key == toggle_key: | |
| global clicking | |
| clicking = not clicking | |
| def main(): | |
| clicking_thread = threading.Thread(target=clicker) | |
| clicking_thread.start() | |
| with Listener(on_press=toggle_event) as listener: | |
| listener.join() | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment