Пример #1
0
        private void Click(string xpath, ClickTypeEnum button)
        {
            UIA3Automation automation = new UIA3Automation();

            if (automation is null)
            {
                return;
            }
            try
            {
                var e1 = automation.GetDesktop();
                var e2 = e1.FindFirstByXPath(xpath);
                if (xpath.ToUpper().Contains("/WINDOW"))
                {
                    e2.SetForeground();
                }
                switch (button)
                {
                case ClickTypeEnum.SingleLeft:
                    e2.Click();
                    break;

                case ClickTypeEnum.SingleRight:
                    e2.RightClick();
                    break;

                case ClickTypeEnum.DoubleLeft:
                    e2.DoubleClick();
                    break;

                case ClickTypeEnum.DoubleRight:
                    e2.RightDoubleClick();
                    break;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(this.DisplayName + ":" + ex.ToString());
                //throw ex;
            }
        }
        public ClickBehaviourBase CreateClickBehaviour(ClickTypeEnum clickType)
        {
            switch (clickType)
            {
            case ClickTypeEnum.None:
                return(new EmptyClickBehaviour());

            case ClickTypeEnum.LeftClick:
                return(new LeftButtonClickBehaviour());

            case ClickTypeEnum.RightClick:
                return(new RightButtonClickBehaviour());

            case ClickTypeEnum.LeftDoubleClick:
                return(new DoubleClickBehaviour(new LeftButtonClickBehaviour()));

            case ClickTypeEnum.RightDoubleClick:
                return(new DoubleClickBehaviour(new RightButtonClickBehaviour()));

            default:
                throw new NotImplementedException();
            }
        }
Пример #3
0
        public IMouseClicker CreateClicker(ClickDelayEnum clickDelay, ClickAreaEnum clickArea, ClickTypeEnum clickType)
        {
            var clickerConfig    = _clickerConfigFactory.CreateClickerConfig(clickArea);
            var clickerBehaviour = _clickBehaviourFactory.CreateClickBehaviour(clickType);
            var clickerInterval  = _clickerIntervalFactory.CreateClickerInterval(clickDelay);

            var clicker = new Clicker(clickerInterval, clickerConfig, clickerBehaviour);

            return(clicker);
        }