日期:2014-05-17 浏览次数:21134 次
//UIAutomation获得 表格内容
AutomationElement desktop = AutomationElement.RootElement;
Condition InputCondition = new PropertyCondition(AutomationElement.NameProperty, "Form1");
AutomationElement aeMainWindow = desktop.FindFirst(TreeScope.Children, InputCondition);
InputCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataGrid);
AutomationElementCollection Aus = aeMainWindow.FindAll(TreeScope.Subtree, InputCondition);
for (int i = 0; i < Aus.Count; i++)
{
AutomationElement txt = Aus[i];
GridPattern ipClickButton1 = (GridPattern)txt.GetCurrentPattern(GridPattern.Pattern);
//这里应该怎么写了呢?我想获得表格文本内容
}