my python code clicks on the screen every 4 seconds, but it stops when q is pressed (once) and it continues when q is pressed again.
I also tried this with break, instead of not click, but it only works when I hold q for a while and I have to run the code again to start clicking again...
Does anyone have an idea how I don't have to hold the key and how I can prevent to many inputs?
import time
import pyautogui
import keyboard
time.sleep(5)
click = True
print(click)
while click:
if keyboard.is_pressed("q"):
print(click)
click = not click
time.sleep(4)
if click:
pyautogui.click()
Edit: the answer of @stacker works, but it doesn't click every 4 seconds...
That was my first code, but I want it to press it every 4 seconds and then their are issues...