pywinauto: AttributeError: WindowSpecification class has no 'GetProperties' method

pywinauto: AttributeError: WindowSpecification class has no 'GetProperties' method

我需要在编辑框中验证颜色。 这是我的代码:

def get_sn_edit_box_rgb(self):  
    tup = (1182, 227, 1884, 249)
    (x, y) = self.calculate_element_center_points(tup)
    (r,g,b)=self.get_pixel_colour(x, y)

我硬编码了盒子的矩形坐标,但我想动态获取它。

我尝试使用 'GetProperties' 和 'Rectangle' 方法但收到错误 “ WindowSpecification class 没有‘---’方法”

'get_properties' pywinauto 内部块的一些错误

我找到了,感谢 G-d!

rec = self.dlg.child_window(auto_id="tSerialNumber").element_info.rectangle

最终版本将如下所示:

 def get_sn_edit_box_rgb(self):
    rec = self.dlg.child_window(auto_id="tSerialNumber").element_info.rectangle
    mid = rec.mid_point()
    (r,g,b)=self.get_pixel_colour(mid.x, mid.y)
    return (r,g,b)