예제 #1
0
        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("");
            }
        }
        public GUI_window(GUI_Base guiBase, Window window, WindowControlHandler controlHandler, WindowCloseHandler closeHandler)
        {
            GuiBase            = guiBase;
            WindowRect         = window.windowRect;
            TitleText          = window.titleText;
            ControlHandler     = new WindowControlHandler(controlHandler);
            CloseHandler       = new WindowCloseHandler(closeHandler);
            _hasMoveable       = window.hasMoveable;
            _hasMinimizeButton = window.hasMinimizeButton;
            _hasCloseButton    = window.hasCloseButton;
            _hasToolTipButton  = window.hasToolTipButton;
            _HasTimeInTitle    = window.hasTimeInTitle;

            ID      = window.windowID;
            Enabled = window.enabled;
            PreInitWindow();
        }
예제 #3
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();
        }