How do I have a fail safe command in python

后端 未结 3 1982
名媛妹妹
名媛妹妹 2021-01-22 10:51

So I\'m trying to make a program that randomly places my mouse in specific areas in python, and I\'m still testing it so it can get a bit crazy. I was wondering if it were poss

3条回答
  •  南方客
    南方客 (楼主)
    2021-01-22 11:25

    PyAutoGUI also has a fail-safe feature. Moving the mouse cursor to the upper-left corner of the screen will cause PyAutoGUI to raise the pyautogui.FailSafeException exception.

    Your program can either handle this exception with try and except statements or let the exception crash your program. Either way, the fail-safe feature will stop the program if you quickly move the mouse as far up and left as you can.

    >>>import pyautogui
    >>>pyautogui.FAILSAFE= True
    

    By default FAILSAFE is True, and you can also disable it.

    >>>pyautogui.FAILSAFE = False
    

提交回复
热议问题