static void Main(string[] args) { IntPtr windowHandle = NativeMethodsHelper.GetWindowByTitle("Test Form"); /* * Test sub-controls of a window. */ IWindowControlHandler windowsControlHandler = new WindowControlHandler(null); IWindowControl window = windowsControlHandler.GetWindowControl(windowHandle); IEnumerable <IWindowControl> childs = window.GetChildControls(); object windowTitle = window.GetControlValue(); Console.WriteLine($"Window title: { windowTitle }"); Console.WriteLine($"Child controls values:"); for (int i = 0; i < childs.Count(); ++i) { IWindowControl child = childs.ElementAt(i); object childControlValue = child.GetControlValue(); Console.WriteLine($"{ i } - { childControlValue }"); // Test button clicking. if (childControlValue.Equals("Test Button Text")) { child.Click(); } } for (int i = 0; i < childs.Count(); ++i) { IEnumerable <IWindowControl> childChilds = childs.ElementAt(i).GetChildControls(); Console.WriteLine(""); } }
static void Main(string[] args) { IntPtr windowPtr = NativeMethodsHelper.GetWindowByTitle("TicTacToe"); // Find TextBox with current player char IWindowControl windowControl = new WindowControl(windowPtr, null); IEnumerable <IWindowControl> groupBoxes = windowControl.GetChildControls(); PrintTexts(groupBoxes, 1); IWindowControl control = NativeMethodsHelper.GetWindowControlByText(windowControl, "Current Player Turn"); string text = control.GetControlValue().ToString(); Console.WriteLine(text); // Check current player char IWindowControl charControl = control.GetChildControls().FirstOrDefault(); string tttChar = charControl.GetControlValue().ToString(); Console.WriteLine(tttChar); Console.ReadKey(); }