Reputation: 23
I used this function below to keep the Python program pressing 'enter" over and over again, but when I click with the mouse, a window appears with "Python Not Responding" and then I have to close the program, so my question is; is there any way for me to catch that with Python?
Code:
def stop():
pyautogui.FAILSAFE = False
while True:
pyautogui.press('enter')
Thanks in advance!
Upvotes: 0
Views: 106
Reputation: 1627
You cannot catch
your program crashing as if it were an exception. What you can do in add a delay between sending each key press:
import time
def stop():
pyautogui.FAILSAFE = False
while True:
pyautogui.press('enter')
time.sleep(0.1)
Upvotes: 1