Ejemplo n.º 1
0
        protected override void Execute(CodeActivityContext context)
        {
            var el = Element.Get(context);

            if (el == null)
            {
                throw new ArgumentException("element cannot be null");
            }
            var doubleclick = false;

            if (DoubleClick != null)
            {
                doubleclick = DoubleClick.Get(context);
            }
            var button       = Button.Get(context);
            var virtualClick = false;

            if (VirtualClick != null)
            {
                virtualClick = VirtualClick.Get(context);
            }
            var animatemouse = false;

            if (AnimateMouse != null)
            {
                animatemouse = AnimateMouse.Get(context);
            }
            var keymodifiers = "";

            if (KeyModifiers != null)
            {
                keymodifiers = KeyModifiers.Get(context);
            }

            var disposes = new List <IDisposable>();
            var keys     = TypeText.GetKeys(keymodifiers);

            foreach (var vk in keys)
            {
                disposes.Add(FlaUI.Core.Input.Keyboard.Pressing(vk));
            }

            var _button = (Input.MouseButton)button;

            el.Click(virtualClick, _button, OffsetX, OffsetY, doubleclick, animatemouse);

            disposes.ForEach(x => { x.Dispose(); });

            TimeSpan postwait = TimeSpan.Zero;

            if (PostWait != null)
            {
                postwait = PostWait.Get(context);
            }
            if (postwait != TimeSpan.Zero)
            {
                System.Threading.Thread.Sleep(postwait);
            }
        }
Ejemplo n.º 2
0
        protected override void Execute(CodeActivityContext context)
        {
            var el           = Element.Get(context);
            var animatemouse = false;

            if (AnimateMouse != null)
            {
                animatemouse = AnimateMouse.Get(context);
            }
            var button = -1;

            if (Button != null)
            {
                button = Button.Get(context);
            }
            var x = OffsetX.Get(context);
            var y = OffsetY.Get(context);

            if (el != null)
            {
                x += el.Rectangle.X;
                y += el.Rectangle.Y;
            }
            if (button > -1)
            {
                if (button == 1) // MouseButton.Left
                {
                    NativeMethods.mouse_event(NativeMethods.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                }
                else if (button == 1) // MouseButton.Right
                {
                    NativeMethods.mouse_event(NativeMethods.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
                }
            }
            if (animatemouse)
            {
                FlaUI.Core.Input.Mouse.MoveTo(new System.Drawing.Point(x, y));
            }
            else
            {
                NativeMethods.SetCursorPos(x, y);
            }
            if (button > -1)
            {
                if (button == 1) // MouseButton.Left
                {
                    NativeMethods.mouse_event(NativeMethods.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                }
                else if (button == 1) // MouseButton.Right
                {
                    NativeMethods.mouse_event(NativeMethods.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
                }
            }
            TimeSpan postwait = TimeSpan.Zero;

            if (PostWait != null)
            {
                postwait = PostWait.Get(context);
            }
            if (postwait != TimeSpan.Zero)
            {
                System.Threading.Thread.Sleep(postwait);
            }
        }