I made an autoclicker and i can stop it by pressing b but only at the right timing. I didn't find anything that would allow me to stop the program by pressing a button at any time without accessing the console
Here's the program:
from time import sleep
import keyboard
import mouse
state=True
while state:
if keyboard.is_pressed("b"):
state=False
else:
mouse.click()
sleep(1)