2017-07-19 32 views
0

我需要验证编辑框中的颜色。 这是我的代码:pywinauto:AttributeError:WindowSpecification类没有'GetProperties'方法

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”和“矩形”的方法,但接收到错误 “WindowSpecification类没有‘---’方法”

“get_properties”方法从pywinauto内块中的一些错误

回答

1

我发现它,感谢Gd!

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)