I have a python program that takes control of the mouse. However, I would like to be able to cancel the program from running without wrestling the mouse away from the program. I tried to cancel using a keyboard shortcut like so:
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print('Interrupted')
try:
sys.exit(0)
except SystemExit:
os._exit(0)
However, this has the same issue, once the program has clicked away from the IDE I am unable to stop the program without fighting against the mouse. Is this even possible?