private string FindCurrentPlayerChar() { IWindowControl mainControl = new WindowControl(this.WindowPtr, null); IWindowControl playerCharGroupBox = NativeMethodsHelper.GetWindowControlByText(mainControl, "Current Player Turn"); IWindowControl charControl = playerCharGroupBox.GetChildControls().FirstOrDefault(); string tttChar = charControl.GetControlValue().ToString(); return(tttChar); }
protected bool CanMakeMove() { IWindowControl mainControl = this.LearningModule.Bot.ConnectionHandler.ConnectedProcesses.ElementAt(0).WindowHandle.ToWindowControl(); IWindowControl playerCharGroupBox = NativeMethodsHelper.GetWindowControlByText(mainControl, TttSettings.CURRENT_PLAYER_TURN); IWindowControl charControl = playerCharGroupBox.GetChildControls().FirstOrDefault(); string tttChar = charControl.GetControlValue().ToString(); return(this.TttChar.Equals(tttChar)); }
private IEnumerable <IWindowControl> FindButtons() { IConnectedProcess gameProcess = this.GetGameProcess(); IntPtr windowHandler = gameProcess.WindowHandle; IWindowControl mainWindowControl = windowHandler.ToWindowControl(); IWindowControl buttonsGroupBox = NativeMethodsHelper.GetWindowControlByText(mainWindowControl, TttSettings.BUTTONS); IEnumerable <IWindowControl> buttons = buttonsGroupBox.GetChildControls(); return(buttons); }
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(); }