Пример #1
0
        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);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Process notepadProcess1 = StartNotepad();
            Process notepadProcess2 = StartNotepad();

            // Create connection handler and connection tools for Windows with double-side binding.
            var connectionHandler = new WindowsConnectionHandler(null);

            connectionHandler.AttachToProcess(notepadProcess1, IntPtr.Zero);
            connectionHandler.AttachToProcess(notepadProcess2, IntPtr.Zero);

            // Print all connected processes
            for (int i = 0; i < connectionHandler.ConnectedProcesses.Count; ++i)
            {
                IConnectedProcess connectedProcess = connectionHandler.ConnectedProcesses.ElementAt(i);
                Process           process          = connectedProcess.Process;
                Console.WriteLine($"{ i }. { process.ProcessName }, ProcessId: { process.Id }");
            }
            Console.WriteLine();

            //
            // Test - Return value from specified control. Use only in-AutoBot relations.
            //
            IWindowControlHandler        windowsControlHandler = new WindowControlHandler(connectionHandler.PlatformConnectionTools);
            IConnectedProcess            notepad1       = windowsControlHandler.PlatformConnectionTools.ConnectionHandler.ConnectedProcesses.ElementAt(0);
            IWindowControl               windowsControl = windowsControlHandler.GetWindowControl(notepad1.Process.MainWindowHandle);
            IEnumerable <IWindowControl> childs         = windowsControl.GetChildControls();

            object controlValue = windowsControl.GetControlValue();

            Console.WriteLine($"Control value: { controlValue }");

            Console.WriteLine($"Child controls values:");
            for (int i = 0; i < childs.Count(); ++i)
            {
                Console.WriteLine($"{ i } - { childs.ElementAt(i).GetControlValue() }");
            }

            Console.ReadKey();
        }