我由鼠标自动化程序和我有以下功能,其I“后”的方法(root.after(1000,start_mouse))如何停止Python中的Windows鼠标处理程序?
def start_mouse():
"""Staring the mouse click recording"""
global root, FLAG, CLICKS, T, q, timeList, clickThreadId
q = Queue.Queue()
threading.Thread(target=stack).start()
clickThreadId = win32api.GetCurrentThreadId()
def onclick(event):
"""Mouse handler"""
global timeList, T, FLAG, q
timeList.append(int(round(time.time() * 1000)))
Tt = timeList[-1] - timeList[-2]
print event.Position[0],event.Position[1], Tt
if FLAG == 2:
temp_l =str(event.Position[0])+","+str(event.Position[1])+","+str(Tt)+"\n"
q.put_nowait(str("x: "+str(event.Position[0])+" "+"y: "+str(event.Position[1])+" "+"t: "+str(Tt)+"\n"))
CLICKS.append(temp_l)
return True
问题是我不能阻止与Tkinter的调用与(后面的按钮)功能的过程:
win32api.PostThreadMessage(clickThreadId, win32con.WM_QUIT, 0, 0)
所以一切工作正常,但是当我打电话root.destroy()我留下了两个后台进程和我的光标冻结约5秒钟。 有没有人知道处理这个问题的方法?
我不认为你可以自己发布'WM_QUIT',并且没有'PostThreadQuitMessage()'。尝试将其他进程的主窗口改为“WM_CLOSE”。 – andlabs