Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python pywinauto进程已完成,退出代码为-1073740771(0xC000041D)_Python_Tkinter_Pywinauto - Fatal编程技术网

Python pywinauto进程已完成,退出代码为-1073740771(0xC000041D)

Python pywinauto进程已完成,退出代码为-1073740771(0xC000041D),python,tkinter,pywinauto,Python,Tkinter,Pywinauto,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{

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()
如果pywinauto处于活动状态(未注释):


知道为什么会发生这种情况吗?

尝试反转
导入
顺序。反转导入顺序无效。在该代码中,
pywinauto
在未注释时甚至不使用,但这足以以某种方式更改返回代码。您可以尝试卸载
comtypes
并使用
import pywinauto
重试吗?如果没有
comtypes
,它根本不起作用。此时,我怀疑是Python版本和Pywinauto之间不兼容。
hello

Process finished with exit code 0
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()
hello

Process finished with exit code -1073740771 (0xC000041D)