Dec-15-2022, 05:10 PM
Im kind of a beginner to coding. To be fair its my first coding besides college excercises but I've tried to write small program which purpose is to check if user clicked certain button in other application and if so, it would terminate process of that app.
Everything works pretty much as it should but I noticed that program can't get out of one of sections of the code which causes GUI to freeze. What should I do?
![[Image: 8476dac0cc93f.png]](https://zapodaj.net/images/8476dac0cc93f.png)
Im not sure if this is allowed but I'll leave one more comment to "bump" the post
Everything works pretty much as it should but I noticed that program can't get out of one of sections of the code which causes GUI to freeze. What should I do?
from pynput import * import pyautogui from tkinter import * import psutil window = Tk() window.geometry("600x300") window.title("Zamknij Lige-inator") window.iconbitmap("logo.ico") window.config(background="#525252") window.resizable(False, False) def check_coords(x1, y1, button, pressed): if pressed and pyautogui.locateCenterOnScreen("loot_icon.png", confidence = 0.9) != None: x2, y2 = pyautogui.locateCenterOnScreen("loot_icon.png", confidence = 0.9) #print("Image at: {}".format((x2, y2))) #print("Cursor at: {}".format((x1, y1))) if x2-29<=x1 and x2+29>=x1 and y2-41<=y1 and y2+41>=y1: #print("Coordinates matched!") for proc in psutil.process_iter(): if proc.name()=="LeagueClient.exe": proc.kill() is_paused = True elif pressed: #print("Image not found!") is_paused = True is_paused = False def run(): global is_paused if is_paused == False: #print("debug") with mouse.Listener(on_click = check_coords) as listen: listen.join() else: is_on = False is_on = False def switch(): global is_on if is_on == True: b1.config(background="#3eca5a", activebackground="#65c979", text="Start") is_on = False else: b1.config(background="#CA3E47", activebackground="#c95b62", text="Stop") is_on = True is_paused = False run() f1 = Frame(window, width=580, height=260) f1.grid(row=0, column=0, padx=(10,10), pady=(20,20)) f1.grid_propagate(False) f1.config(bg="#414141") l1 = Label(f1, text="Zamknij Lige-inator", font = ("Helvetica", 24), bg="#313131", fg="white") l1.grid(row=0, column=0, columnspan=3, padx=53, pady=(20,30), ipadx=98, ipady=20, sticky=EW) b1 = Button(f1, text="Start", bg="#3eca5a", fg="black", activebackground="#65c979", command=switch) b1.grid(row=1, column=0, columnspan=2, padx=(53,0), pady=(0,0), ipadx=150, ipady=40) b2 = Button(f1, text="Exit", bg="#313131", fg="white", activebackground="#525252", command=window.quit) b2.grid(row=1, column=2, padx=(0,53), pady=(0,0), ipadx=60, ipady=40) window.mainloop()
![[Image: 8476dac0cc93f.png]](https://zapodaj.net/images/8476dac0cc93f.png)
Im not sure if this is allowed but I'll leave one more comment to "bump" the post