Python 3.7.1// Tk版本8.6// pywinauto-0.6.8// PyCharm社区版2020.1 x64
目标是让按钮在后台向窗口发送键。 出现问题是由于pywinauto的存在。 如果不活动:
from tkinter import *
# from pywinauto.keyboard import send_keys
def left_click(event):
# send_keys('%{TAB}')
# send_keys('{{}ENTER{}}')
print("hello")
root = Tk()
label1 = Label(root, text="Other")
label1.grid(row=0, sticky=E)
bt1_label1 = Button(root, text="Button_1", bg="red")
bt1_label1.grid(row=0, column=1)
bt1_label1.bind("<Button-1>", left_click)
root.mainloop()
手动关闭tkinter窗口时返回:
hello
Process finished with exit code 0
如果pywinauto处于活动状态(未注释):
from tkinter import *
from pywinauto.keyboard import send_keys
def left_click(event):
# send_keys('%{TAB}')
# send_keys('{{}ENTER{}}')
print("hello")
root = Tk()
label1 = Label(root, text="Other")
label1.grid(row=0, sticky=E)
bt1_label1 = Button(root, text="Button_1", bg="red")
bt1_label1.grid(row=0, column=1)
bt1_label1.bind("<Button-1>", left_click)
root.mainloop()
手动关闭tkinter窗口时返回:
hello
Process finished with exit code -1073740771 (0xC000041D)
你知道为什么会这样吗
目前没有回答
相关问题 更多 >
编程相关推荐