Esempio n. 1
0
        public object Execute(IUIAutomationRunner runner)
        {
            AutomationElement element = UIAutomationHelper.FindWindowControl(this, ControlType.Button, this.TimeOut);

            if (element == null)
            {
                throw new NullReferenceException(string.Format("Button element with AutomationId '{0}' and Name '{1}' can not be find.",
                                                               element.Current.AutomationId, element.Current.Name));
            }

            ThreadStart start2             = null;
            IntPtr      nativeWindowHandle = (IntPtr)element.Current.NativeWindowHandle;

            if (nativeWindowHandle != IntPtr.Zero)
            {
                HandleRef hWnd = new HandleRef(nativeWindowHandle, nativeWindowHandle);
                PostMessage(hWnd, 0xf5, IntPtr.Zero, IntPtr.Zero);
            }
            else
            {
                if (start2 == null)
                {
                    start2 = delegate
                    {
                        PatternOperator.Invoke(element);
                    };
                }
                ThreadStart start = start2;
                new Thread(start).Start();
                Thread.Sleep(0xbb8);
            }
            return(null);
        }
Esempio n. 2
0
        public object Execute(IUIAutomationRunner action)
        {
            AutomationElement element = UIAutomationHelper.FindWindowControl(this, ControlType.MenuItem, this.TimeOut);

            if (element == null)
            {
                throw new NullReferenceException(string.Format("Menu element with AutomationId '{0}' and Name '{1}' can not be find.",
                                                               element.Current.AutomationId, element.Current.Name));
            }

            ThreadStart threadStart = delegate
            {
                PatternOperator.Invoke(element);
            };

            new Thread(threadStart).Start();
            Thread.Sleep(0xbb8);
            return(null);
        }
Esempio n. 3
0
        public object Execute(IUIAutomationRunner runner)
        {
            AutomationElement element = null;

            if (IsFindByUser != true)
            {
                element = UIAutomationHelper.FindWindowControl(this, ControlType.Button, this.TimeOut);
            }
            else
            {
                element = targetElement;
            }

            if (element == null)
            {
                throw new NullReferenceException(string.Format("Element with AutomationId '{0}' and Name '{1}' can not be find.",
                                                               element.Current.AutomationId, element.Current.Name));
            }

            rect = element.Current.BoundingRectangle;

            if (IsSetPostion != true)
            {
                IncrementX = (int)(rect.Left + rect.Width / 2);
                IncrementY = (int)(rect.Top + rect.Height / 2);
            }
            else
            {
                IncrementX = (int)(rect.X + IncrementX);
                IncrementY = (int)(rect.Y + IncrementY);
            }
            //Make the cursor position to the element.
            SetCursorPos(IncrementX, IncrementY);
            Thread.Sleep(500);
            //Make the left mouse down and up.
            mouse_event(MOUSEEVENTF_RIGHTDOWN, IncrementX, IncrementY, 0, 0);
            mouse_event(MOUSEEVENTF_RIGHTUP, IncrementX, IncrementY, 0, 0);

            return(null);
        }