简体   繁体   English

Pywinauto 未检测到新窗口跟进问题

[英]Pywinauto Doesn't Detect New Window Follow Up Question

Referring to answer for this question pywinauto does not detect child window参考这个问题的答案pywinauto 没有检测到子窗口

I have a similar issue where I click "New" button and a window appears to key in inputs.我有一个类似的问题,我点击“新建”按钮,然后出现一个窗口来输入输入。 My problem is this new window is not listed in the print_control_identifiers().我的问题是这个新窗口没有在 print_control_identifiers() 中列出。 Below is my entire code so far right up to the new window pop up下面是我的整个代码,直到新窗口弹出

app = Application(backend="uia").connect(title_re="Celestica SpectrumPro.*", timeout=20)
dlg = app.window(title_re="Celestica SpectrumPro.*")
app.dlg.Edit2.type_keys("XXXXXXX")
app.dlg.Edit.type_keys("YYYYYY")
app.dlg.Login.click()
app.dlg.wait("exists enabled visible ready")
app.dlg.New.click()

After the last line, now I have to get the new child window that had just popped up.在最后一行之后,现在我必须得到刚刚弹出的新子窗口。 Below is attempt#1 and its error下面是尝试#1 及其错误

newDLG = app.window(title="SHOP ORDER Configuration")
dlg.newDLG.print_control_identifiers()\
pywinauto.findwindows.ElementNotFoundError: {'title_re': 'Celestica SpectrumPro.*', 'backend': 'uia', 'process': 12244}

Below is attempt#2 and its error下面是尝试#2 及其错误

newDLG = dlg.window(title="SHOP ORDER Configuration")
app.dlg.newDLG.print_control_identifiers()
pywinauto.findbestmatch.MatchError: Could not find 'newDLG' in 'dict_keys(['Button', 'SpectrumPro WEBButton', 'SpectrumPro WEB',.......])

Attempt#3 is when I tried solution from the reference stack overflow question but same issue尝试#3 是当我尝试从参考堆栈溢出问题中解决但同样的问题时

newDLG = app.dlg.child_window(title="SHOP ORDER Configuration")
app.dlg.newDLG.print_control_identifiers()
pywinauto.findbestmatch.MatchError: Could not find 'newDLG' in 'dict_keys(['Button', 'SpectrumPro WEBButton', 'SpectrumPro WEB',....])

When I use Inspect.exe, there are details of the new window buttons, text input, etc. But they don't exist in the Inspect.exe tree.当我使用 Inspect.exe 时,有新窗口按钮、文本输入等的详细信息。但它们不存在于 Inspect.exe 树中。 So I dont know who is the parent of this new window.所以我不知道这个新窗口的父级是谁。 Does anyone know how do I connect to this new window that popped up有谁知道我如何连接到这个弹出的新窗口

I found the solution in case anyone got the same issue我找到了解决方案,以防有人遇到同样的问题

I had to connect the new window using a new application().connect because only this new form window is using win32 backend.我不得不使用新的应用程序().connect 来连接新窗口,因为只有这个新的表单窗口使用了 win32 后端。

newApp = Application(backend="win32").connect(title_re="SHOP ORDER.*")

After that I was still unable to find the window using method below之后我仍然无法使用下面的方法找到窗口

newDLG = app.window(title_re="SHOP ORDER Configuration")

I had to use magic attribute names to get the window我不得不使用魔法属性名称来获取窗口

newApp.SHOPORDERConfiguration.print_control_identifiers()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM