using System; using System.Windows.Automation; using System.Windows; using System.Collections.Generic; namespace 패턴_검색 { class Program { static void Main(string[] args) { AutomationElement ae = AutomationElement.RootElement; Rect rect = ae.Current.BoundingRectangle; AutomationElement sae; Dictionary dictionary = new Dictionary(); for (int x = 0; x < rect.Right; x = x + 20) { for (int y = 0; y < rect.Bottom; y += 20) { sae = AutomationElement.FromPoint(new Point(x, y)); dictionary[sae.Current.NativeWindowHandle] = sae; Console.Write("."); } } Console.WriteLine("요소 개수:{0}", dictionary.Count); InvokePattern ip = null; foreach (AutomationElement dae in dictionary.Values) { try { ip = dae.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern; if (ip != null)// && dae.Current.Name != null) { Console.WriteLine(dae.Current.Name); } } catch { } } Console.ReadKey(); } } }