【发布时间】:2017-10-25 14:25:18
【问题描述】:
我正在尝试自动化一个内部应用程序,但我在单击特定的“类似按钮”控件时遇到了挑战,这可以将我带到下一页。当我打印控件标识符时,它打印如下
HwndWrapper[.MainApplication.exe;;xxxxxxxxxxxxxxx] - 'MainWindow' (L0, T0, R1299, B647) ['MainWindow', 'MainWindowHwndWrapper[.MainApplication.exe;;xxxxxxxxxxxxxxx]', 'HwndWrapper[.MainApplication.exe;;xxxxxxxxxxxxxxx]'] child_window(title="MainWindow", class_name="HwndWrapper[.MainApplication.exe;;xxxxxxxxxxxxxxx]")
我得到的代码如下:
from pywinauto.application import Application import time
app = Application().Start(cmd_line=u'"<myapp>"') time.sleep(25)
hwnd = app.MainWindow
hwnd.Wait('ready')
hwnd.print_control_identifiers()
hwnd.Click()
使用“检查”应用程序,我可以找到该元素,但我无法单击该元素。
任何人都可以给我建议以进一步进行吗?
检查输出:
如何找到:鼠标移动 (156,295) hwnd=0x000D009A 32bit class="HwndWrapper[DefaultDomain;;xxxxxxxxxxxxxxxx]" 样式=0x17080000 ex=0x40000 RuntimeId: "[7.7412.5972994]" BoundingRectangle: {l:97 t:288 r:172 b:306} ProcessId: 7412 ControlType: UIA_TextControlTypeId (0xC364) LocalizedControlType: "text" Name: "Translator 1" AcceleratorKey: "" AccessKey: "" HasKeyboardFocus: false IsKeyboardFocusable: false IsEnabled: true AutomationId: "" ClassName: "TextBlock" HelpText: "" ClickablePoint: {x:134 y:297} IsControlElement:真 IsContentElement:真 IsPassword:假 ItemType: "" IsOffscreen: false 方向: 0 FrameworkId: "WPF" IsRequiredForForm: false ItemStatus: "" ProviderDescription: "[pid:7412,providerId:0x0 Main(父 链接):身份不明的提供者 (托管:MS.Internal.Automation.ElementProxy,PresentationCore, 版本=4.0.0.0,文化=中性,PublicKeyToken=xxxxxxxxx)]" IsDockPatternAvailable:假 IsExpandCollapsePatternAvailable:假 IsGridItemPatternAvailable:假 IsGridPatternAvailable:假 IsInvokePatternAvailable:假 IsMultipleViewPatternAvailable:假 IsRangeValuePatternAvailable:假 IsScrollPatternAvailable:假 IsScrollItemPatternAvailable: 假 IsSelectionItemPatternAvailable: 假 IsSelectionPatternAvailable:假 IsTablePatternAvailable:假 IsTableItemPatternAvailable:假 IsTextPatternAvailable:假 IsTogglePatternAvailable:假 IsTransformPatternAvailable:假 IsValuePatternAvailable:假 IsWindowPatternAvailable:假 IsItemContainerPatternAvailable: 假 IsVirtualizedItemPatternAvailable: false FirstChild: [null] LastChild: [null] Next: [null] Previous: [null] 其他道具:Object 没有附加属性 Children:容器没有子级 祖先:“”按钮“”窗格“”自定义“MainWindow”窗口 “桌面 1”窗格 [无父]
【问题讨论】:
-
我在 Windows 10 64 位机器上运行它,使用 Python 3 和 pywinauto 0.6.3 当我尝试使用 app.window(title="Translator 1", control_type="Text").click_input (),它会抛出异常,说找不到元素。 pywinauto.findwindows.ElementNotFoundError: {'title': 'Translator 1', 'control_type': 'Text', 'backend': 'win32', 'process': 6340}
-
我的回答是否有助于解决问题?
标签: pywinauto