tried making an autoclicker, but cant figure out how to run another while loop with the main loop of tkinter, and threading didnt work
import tkinter
import pyautogui
import threading
clicking_status = False
def check_key(event):
if event.keysym != "F2":
return
if activate_clicker['state'] == 'active':
activate()
else:
deactivate()
def autoclicker(clicks: int):
global clicking_status
clicking_status = True
while clicking_status:
mainScreen.after(int(1/clicks * 1000), pyautogui.click())
def activate():
activate_clicker['state'] = "disabled"
deactivate_clicker['state'] = 'active'
value = ClicksPerSecond.get()
if value.isdigit():
autoclicker(int(value))
else:
return
def deactivate():
global clicking_status
activate_clicker['state'] = "active"
deactivate_clicker['state'] = 'disabled'
value = ClicksPerSecond.get()
if value.isdigit():
clicking_status = False
else:
return
mainScreen = tkinter.Tk()
mainScreen.attributes('-topmost', True)
mainScreen.bind("<KeyRelease>", check_key)
mainScreen.title("AutoClicker but worse")
mainScreen.minsize(400, 350)
descriptor = tkinter.Label(mainScreen, text="Clicks Per Second")
descriptor.place(x=5, y=0)
ClicksPerSecond = tkinter.Entry(mainScreen, width=20)
ClicksPerSecond.place(x=5, y=20)
activate_clicker = tkinter.Button(mainScreen, height=1, width=10, text="Activate", command=activate)
activate_clicker.place(x=5, y=320)
deactivate_clicker = tkinter.Button(mainScreen, height=1, width=10, text="De-Activate", command=deactivate,
state=tkinter.DISABLED)
deactivate_clicker.place(x=105, y=320)
mainScreen.mainloop()```