I'm trying to create a mouse loop application, I can get the start button to work inside the loop, however the end button seems to crash tkinter instead of close the application.
any advise would be appreciated
import pyautogui
from tkinter import *
import sys
window = Tk()
def start_loop():
while True:
pyautogui.moveTo(3131, 891, 1)
pyautogui.PAUSE = 180
pyautogui.moveTo(3128, 434, 1)
b1 = Button(window, text="Start Mouse", command=start_loop)
b1.grid(row=0, column=0)
def end_loop():
print(sys.exit())
b2 = Button(window, text="Stop Mouse", command=end_loop)
b2.grid(row=0, column=1)
window.mainloop()