Пример #1
0
        public override void Invoke(Worker.State state)
        {
            INPUT[] queue = new INPUT[1];
            queue[0] = new INPUT();

            queue[0].type = InputType.Mouse;

            switch (button)
            {
                case MouseButtons.Left:
                    queue[0].u.Mouse.Flags |= MouseFlag.LeftUp;
                    break;
                case MouseButtons.Right:
                    queue[0].u.Mouse.Flags |= MouseFlag.RightUp;
                    break;
                case MouseButtons.Middle:
                    queue[0].u.Mouse.Flags |= MouseFlag.MiddleUp;
                    break;
                case MouseButtons.XButton1:
                    queue[0].u.Mouse.Flags |= MouseFlag.XUp;
                    queue[0].u.Mouse.MouseData |= (ushort)XButton.XButton1;
                    break;
                case MouseButtons.XButton2:
                    queue[0].u.Mouse.Flags |= MouseFlag.XUp;
                    queue[0].u.Mouse.MouseData |= (ushort)XButton.XButton2;
                    break;
            }
            NativeMethods.SendInput(1, queue, Marshal.SizeOf(typeof(INPUT)));
        }
Пример #2
0
        private void TypeChar(char ch)
        {
            INPUT[] queue = new INPUT[2];

            queue[0] = new INPUT();
            queue[0].type = InputType.Keyboard;
            queue[0].u.Keyboard = Utils.GetKeyInputFromChar(ch);

            queue[1] = new INPUT();
            queue[1].type = InputType.Keyboard;
            queue[1].u.Keyboard = Utils.GetKeyInputFromChar(ch);
            queue[1].u.Keyboard.Flags |= KeyboardFlag.KeyUp;

            uint ret = NativeMethods.SendInput(2, queue, Marshal.SizeOf(typeof(INPUT)));
        }
Пример #3
0
        public override void Invoke(Worker.State state)
        {
            INPUT[] queue = new INPUT[1];

            queue[0] = new INPUT();
            queue[0].type = InputType.Keyboard;
            queue[0].u.Keyboard.KeyCode = keyCode?? VirtualKeyCode.SPACE;
            queue[0].u.Keyboard.ExtraInfo = IntPtr.Zero;

            if ( scanCode ?? false )
            {
                Utils.VkToScan( queue[ 0 ].u.Keyboard );
            }
            NativeMethods.SendInput(1, queue, Marshal.SizeOf(typeof(INPUT)));
        }