From 5faa85c0601d50c91761185c59aeb7baa918cd72 Mon Sep 17 00:00:00 2001 From: Theonefoster Date: Thu, 21 May 2020 10:59:47 +0100 Subject: [PATCH] Fix performance issues when paused the "while running:" loop was using 100% CPU when the autoclicker was paused. Adding a small sleep has fixed the issue and it now uses nearly no cpu while paused. --- autoclicker.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/autoclicker.py b/autoclicker.py index c48c1db..30627b8 100644 --- a/autoclicker.py +++ b/autoclicker.py @@ -1,5 +1,9 @@ import pyautogui +import ctypes from pynput.keyboard import * +from time import sleep + +ctypes.windll.kernel32.SetConsoleTitleW("Autoclicker") # set the title of the window, otherwise it'll be generic "python" or similar # ======== settings ======== delay = 1 # in seconds @@ -46,8 +50,10 @@ def main(): if not pause: pyautogui.click(pyautogui.position()) pyautogui.PAUSE = delay + else: + sleep(delay) # otherwise it uses 100% CPU lis.stop() if __name__ == "__main__": - main() \ No newline at end of file + main()