111,094
社区成员




using System.Windows.Automation;
若Windows7系统下,采用:
AutomationElement aelement =
AutomationElement.RootElement
.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.ClassNameProperty, "Shell_TrayWnd"))
.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.ClassNameProperty, "ReBarWindow32"))
.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.ClassNameProperty, "MSTaskSwWClass"))
.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.ClassNameProperty, "MSTaskListWClass"))
.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.NameProperty, 程序的标题字符串));
若XP系统下,采用:
AutomationElement aelement =
AutomationElement.RootElement
.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.ClassNameProperty, "Shell_TrayWnd"))
.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.ClassNameProperty, "ReBarWindow32"))
.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.ClassNameProperty, "ToolbarWindow32"))
.FindFirst(TreeScope.Descendants,new PropertyCondition(AutomationElement.NameProperty, 程序的标题字符串));
然后,最终获取几何坐标信息:
if (aelement != null)
{
System.Windows.Rect rect = (System.Windows.Rect)
aelement.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty);
}