示例#1
0
        private INPUT GetMouseButtonUpInput(MouseButtons button)
        {
            MOUSEEVENTF buttonFlag = MOUSEEVENTF.MOUSEEVENTF_LEFTDOWN;

            switch (button)
            {
            case MouseButtons.Left:
                buttonFlag = MOUSEEVENTF.MOUSEEVENTF_LEFTUP; break;

            case MouseButtons.Right:
                buttonFlag = MOUSEEVENTF.MOUSEEVENTF_RIGHTUP; break;

            case MouseButtons.Middle:
                buttonFlag = MOUSEEVENTF.MOUSEEVENTF_MIDDLEUP; break;
            }

            INPUT buttonInput = new INPUT
            {
                type = InputType.INPUT_MOUSE,
            };

            buttonInput.Inputs.mi.dwFlags = buttonFlag;

            return(buttonInput);
        }
示例#2
0
        private INPUT GetMouseMovementInput(int x, int y, bool isAbsolute)
        {
            MOUSEEVENTF moventFlag = MOUSEEVENTF.MOUSEEVENTF_MOVE;

            if (isAbsolute)
            {
                // MOUSEEVENTF_ABSOLUTE 값을 지정하면
                // 좌표가 (0, 0) ~ (65535, 65535)로 맵핑된다.
                x = (x * m_MappingValue) / m_System_CoordinateX + 1;
                y = (y * m_MappingValue) / m_System_CoordinateY + 1;

                moventFlag |= MOUSEEVENTF.MOUSEEVENTF_ABSOLUTE;
            }

            INPUT movementInput = new INPUT
            {
                type = InputType.INPUT_MOUSE,
            };

            movementInput.Inputs.mi.dwFlags = moventFlag;
            movementInput.Inputs.mi.dx      = x;
            movementInput.Inputs.mi.dy      = y;

            return(movementInput);
        }
示例#3
0
        public void ButtonUp(Buttons button)
        {
            MOUSEEVENTF button_code = MOUSEEVENTF.LEFTUP;

            switch (button)
            {
            case Buttons.LMB: button_code = MOUSEEVENTF.LEFTUP; break;

            case Buttons.RMB: button_code = MOUSEEVENTF.RIGHTUP; break;

            case Buttons.MMB: button_code = MOUSEEVENTF.MIDDLEUP; break;
            }

            //mouse_event(button_code, 0, 0, 0, 0);

            INPUT[] inputs = new INPUT[] { new INPUT()
                                           {
                                               dwType = INPUTTYPE.MOUSE,
                                               union  = new INPUT.UnionTag()
                                               {
                                                   mi = new MOUSEINPUT()
                                                   {
                                                       dx          = 0,
                                                       dy          = 0,
                                                       dwExtraInfo = UIntPtr.Zero,
                                                       dwFlags     = button_code,
                                                       mouseData   = 0
                                                   }
                                               }
                                           } };

            SendInput((uint)inputs.Length, inputs, Marshal.SizeOf(inputs[0]));
        }
示例#4
0
        private static void DoMouse(MOUSEEVENTF flags, Point newPoint, int scrollSize = 0)
        {
            INPUT[] inputs = new INPUT[]
            {
                new INPUT
                {
                    type = INPUT_MOUSE,
                    u    = new InputUnion
                    {
                        mi = new MOUSEINPUT
                        {
                            // mouse co-ords: top left is (0,0), bottom right is (65535, 65535)
                            // convert screen co-ord to mouse co-ords...
                            dx          = newPoint.X * 65535 / Screen.PrimaryScreen.Bounds.Width,
                            dy          = newPoint.Y * 65535 / Screen.PrimaryScreen.Bounds.Height,
                            mouseData   = scrollSize * 120,
                            dwFlags     = flags,
                            time        = 0,
                            dwExtraInfo = IntPtr.Zero,
                        }
                    }
                }
            };


            int cbSize = Marshal.SizeOf(typeof(INPUT));
            int result = SendInput(1, inputs, cbSize);

            if (result == 0)
            {
                Debug.WriteLine(Marshal.GetLastWin32Error());
            }
        }
示例#5
0
        /**************************************************************************************************************************/
        /* Credit where credit is due: SendMouseInput shamelessly taken from UI Verify - http://uiautomationverify.codeplex.com/ */
        /**************************************************************************************************************************/

        /// <summary>
        /// Inject pointer input into the system
        /// </summary>
        /// <param name="x">x coordinate of pointer, if Move flag specified</param>
        /// <param name="y">y coordinate of pointer, if Move flag specified</param>
        /// <param name="data">wheel movement, or mouse X button, depending on flags</param>
        /// <param name="flags">flags to indicate which type of input occurred - move, button press/release, wheel move, etc.</param>
        /// <exception cref="ProdOperationException">Thrown if Security permissions won't allow execution</exception>
        ///
        /// <exception cref="Win32Exception">Thrown if SendInput call fails</exception>
        ///
        /// <outside_see conditional="false">
        /// This API does not work inside the secure execution environment.
        ///   <exception cref="System.Security.Permissions.SecurityPermission"/>
        ///   </outside_see>
        /// <remarks>
        /// x, y are in pixels. If Absolute flag used, are relative to desktop origin.
        /// </remarks>
        internal static void SendMouseInput(double x, double y, int data, MOUSEEVENTF flags)
        {
            int intflags = (int)flags;

            try
            {
                if ((intflags & (int)MOUSEEVENTF.MOUSEEVENTFABSOLUTE) != 0)
                {
                    int vscreenWidth  = NativeMethods.GetSystemMetrics((int)SystemMetric.SMCXVIRTUALSCREEN);
                    int vscreenHeight = NativeMethods.GetSystemMetrics((int)SystemMetric.SMCYVIRTUALSCREEN);
                    int vscreenLeft   = NativeMethods.GetSystemMetrics((int)SystemMetric.SMXVIRTUALSCREEN);
                    int vscreenTop    = NativeMethods.GetSystemMetrics((int)SystemMetric.SMYVIRTUALSCREEN);

                    // Absolute input requires that input is in 'normalized' coords - with the entire
                    // desktop being (0,0)...(65535,65536). Need to convert input x,y coords to this
                    // first.
                    //
                    // In this normalized world, any pixel on the screen corresponds to a block of values
                    // of normalized coords - eg. on a 1024x768 screen,
                    // y pixel 0 corresponds to range 0 to 85.333,
                    // y pixel 1 corresponds to range 85.333 to 170.666,
                    // y pixel 2 corresponds to range 170.666 to 256 - and so on.
                    // Doing basic scaling math - (x-top)*65536/Width - gets us the start of the range.
                    // However, because int math is used, this can end up being rounded into the wrong
                    // pixel. For example, if we wanted pixel 1, we'd get 85.333, but that comes out as
                    // 85 as an int, which falls into pixel 0's range - and that's where the pointer goes.
                    // To avoid this, we add on half-a-"screen pixel"'s worth of normalized coords - to
                    // push us into the middle of any given pixel's range - that's the 65536/(Width*2)
                    // part of the formula. So now pixel 1 maps to 85+42 = 127 - which is comfortably
                    // in the middle of that pixel's block.
                    // The key ting here is that unlike points in coordinate geometry, pixels take up
                    // space, so are often better treated like rectangles - and if you want to target
                    // a particular pixel, target its rectangle's midpoint, not its edge.
                    x = ((x - vscreenLeft) * 65536) / vscreenWidth + 65536 / (vscreenWidth * 2);
                    y = ((y - vscreenTop) * 65536) / vscreenHeight + 65536 / (vscreenHeight * 2);

                    intflags |= (int)MOUSEEVENTF.MOUSEEVENTFVIRTUALDESK;
                }

                NPUT mi = new NPUT
                {
                    Type = (int)InputStructType.InputMouse
                };
                mi.Union.MouseInput.DX          = (int)x;
                mi.Union.MouseInput.DY          = (int)y;
                mi.Union.MouseInput.MouseData   = data;
                mi.Union.MouseInput.DWFlags     = intflags;
                mi.Union.MouseInput.Time        = 0;
                mi.Union.MouseInput.DWExtraInfo = new IntPtr(0);

                if (NativeMethods.SendInput(1, ref mi, Marshal.SizeOf(mi)) == 0)
                {
                    throw new Win32Exception(Marshal.GetLastWin32Error());
                }
            }
            catch (Exception e)
            {
                throw new ProdOperationException(e.Message, e);
            }
        }
示例#6
0
        private void Screen_MouseButton(object sender, MouseButtonEventArgs e)
        {
            if (handler.tcpClient == null || handler.tcpClient.Client.Connected == false || power == POWER.OFF)
            {
                return;
            }

            ClientPacket clientPacket = new ClientPacket(PacketType.Screen);

            clientPacket.screen       = new ClientPacket.Screen(POWER.ON);
            clientPacket.screen.mouse = new ClientPacket.Screen.Mouse();
            MOUSEEVENTF mouseeventf = 0;

            if (e.ChangedButton == MouseButton.Left)
            {
                mouseeventf |= e.ButtonState == MouseButtonState.Pressed ? MOUSEEVENTF.LEFTDOWN : MOUSEEVENTF.LEFTUP;
            }
            if (e.ChangedButton == MouseButton.Right)
            {
                mouseeventf |= e.ButtonState == MouseButtonState.Pressed ? MOUSEEVENTF.RIGHTDOWN : MOUSEEVENTF.RIGHTUP;
            }
            if (e.ChangedButton == MouseButton.Middle)
            {
                mouseeventf |= e.ButtonState == MouseButtonState.Pressed ? MOUSEEVENTF.MIDDLEDOWN : MOUSEEVENTF.MIDDLEUP;
            }
            clientPacket.screen.mouse.dwFlags = (int)mouseeventf;
            handler.packetStream.Send(clientPacket);
        }
示例#7
0
 private MOUSEINPUT(int dx, int dy, uint mouseData, MOUSEEVENTF flags)
 {
     _dx          = dx;
     _dy          = dy;
     _mouseData   = mouseData;
     _dwFlags     = flags;
     _time        = 0;
     _dwExtraInfo = IntPtr.Zero;
 }
示例#8
0
    public static void SendMouse(MOUSEEVENTF flag)
    {
        INPUT[] Inputs = new INPUT[1];
        INPUT   Input  = new INPUT();

        Input.type         = 0; // 0 = Mouse Input
        Input.U.mi.dwFlags = flag;
        Inputs[0]          = Input;
        SendInput(1, Inputs, INPUT.Size);
    }
示例#9
0
 public static void SendMouseClick(MOUSEEVENTF type)
 {
     INPUT[] input = new INPUT[1];
     input[0].type           = 0;
     input[0].U.mi.mouseData = 0;
     input[0].U.mi.dx        = 0;
     input[0].U.mi.dy        = 0;
     input[0].U.mi.dwFlags   = type;
     SendInput(1, input, Marshal.SizeOf(typeof(INPUT)));
 }
示例#10
0
        public void PressMouse(MOUSEEVENTF m)
        {
            if (!GetWindowInFocus().StartsWith("Titanfall 2"))
            {
                return;
            }
            var inputs = new INPUT[1];
            var input  = new INPUT();

            input.type         = 0; // 0 = Mouse Input
            input.U.mi.dwFlags = m;
            inputs[0]          = input;
            SendInput(1, inputs, INPUT.Size);
        }
示例#11
0
        private unsafe static void SendMouseInput(int x, int y, MOUSEEVENTF flags)
        {
            if ((flags & MOUSEEVENTF.ABSOLUTE) != 0)
            {
                int vscreenWidth  = GetSystemMetrics(SystemMetric.SM_CXVIRTUALSCREEN);
                int vscreenHeight = GetSystemMetrics(SystemMetric.SM_CYVIRTUALSCREEN);
                int vscreenLeft   = GetSystemMetrics(SystemMetric.SM_XVIRTUALSCREEN);
                int vscreenTop    = GetSystemMetrics(SystemMetric.SM_YVIRTUALSCREEN);

                const int DesktopNormalizedMax = 65536;

                // Absolute input requires that input is in 'normalized' coords - with the entire
                // desktop being (0,0)...(65535,65536). Need to convert input x,y coords to this
                // first.
                //
                // In this normalized world, any pixel on the screen corresponds to a block of values
                // of normalized coords - eg. on a 1024x768 screen,
                // y pixel 0 corresponds to range 0 to 85.333,
                // y pixel 1 corresponds to range 85.333 to 170.666,
                // y pixel 2 corresponds to range 170.666 to 256 - and so on.
                // Doing basic scaling math - (x-top)*65536/Width - gets us the start of the range.
                // However, because int math is used, this can end up being rounded into the wrong
                // pixel. For example, if we wanted pixel 1, we'd get 85.333, but that comes out as
                // 85 as an int, which falls into pixel 0's range - and that's where the pointer goes.
                // To avoid this, we add on half-a-"screen pixel"'s worth of normalized coords - to
                // push us into the middle of any given pixel's range - that's the 65536/(Width*2)
                // part of the formula. So now pixel 1 maps to 85+42 = 127 - which is comfortably
                // in the middle of that pixel's block.
                // The key ting here is that unlike points in coordinate geometry, pixels take up
                // space, so are often better treated like rectangles - and if you want to target
                // a particular pixel, target its rectangle's midpoint, not its edge.
                x = ((x - vscreenLeft) * DesktopNormalizedMax) / vscreenWidth + DesktopNormalizedMax / (vscreenWidth * 2);
                y = ((y - vscreenTop) * DesktopNormalizedMax) / vscreenHeight + DesktopNormalizedMax / (vscreenHeight * 2);

                flags |= MOUSEEVENTF.VIRTUALDESK;
            }

            var mouseInput = new INPUT();

            mouseInput.type                      = INPUTENUM.MOUSE;
            mouseInput.inputUnion.mi.dx          = x;
            mouseInput.inputUnion.mi.dy          = y;
            mouseInput.inputUnion.mi.mouseData   = 0;
            mouseInput.inputUnion.mi.dwFlags     = flags;
            mouseInput.inputUnion.mi.time        = 0;
            mouseInput.inputUnion.mi.dwExtraInfo = IntPtr.Zero;

            SendInput(1, &mouseInput, Marshal.SizeOf(mouseInput));
        }
示例#12
0
        internal static void ToTypeAndButton(MOUSEEVENTF flags, out CGEventType type, out CGMouseButton button)
        {
            EventEntry e;

            if (EventTypes.TryGetValue((MOUSEEVENTF)((uint)flags & 0x1FFFF), out e))
            {
                type   = e.type;
                button = e.button;
            }
            else
            {
                type   = CGEventType.Null;
                button = 0;
            }
        }
示例#13
0
        internal static void SendMouseInput(MOUSEEVENTF dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo)
        {
            INPUT input = new INPUT
            {
                mi   = new MOUSEINPUT(),
                type = INPUT_TYPE.INPUT_MOUSE
            };

            input.mi.dwFlags     = dwFlags;
            input.mi.dx          = (int)dx;
            input.mi.dy          = (int)dy;
            input.mi.mouseData   = dwData;
            input.mi.time        = 0;
            input.mi.dwExtraInfo = dwExtraInfo;
            SendInput(1, new INPUT[] { input }, Marshal.SizeOf(typeof(INPUT)));
        }
示例#14
0
 static INPUT GetMouseEvent(int x, int y, MOUSEEVENTF m, int t)
 {
     return(new INPUT()
     {
         type = 0,
         U = new InputUnion()
         {
             mi = new MOUSEINPUT()
             {
                 dx = x,
                 dy = y,
                 mouseData = 0,
                 dwFlags = m,
                 time = (uint)t,
                 dwExtraInfo = UIntPtr.Zero
             }
         }
     });
 }
示例#15
0
    public static async void ClickOnPoint(IntPtr wndHandle, POINT clientPoint, MOUSETYPE mouseType, bool right = false, bool dblclick = false)
    {
        if (wndHandle != IntPtr.Zero)
        {
            ClientToScreen(wndHandle, ref clientPoint);
        }

        SetCursorPos(clientPoint.x, clientPoint.y);
        await Task.Delay(100);

        MOUSEEVENTF edown = MOUSEEVENTF.LEFTDOWN;
        MOUSEEVENTF eup   = MOUSEEVENTF.LEFTUP;

        if (right)
        {
            edown = MOUSEEVENTF.RIGHTDOWN;
            eup   = MOUSEEVENTF.RIGHTUP;
        }

        switch (mouseType)
        {
        case MOUSETYPE.MOUSEDOWN:
            SendMouse(edown);
            break;

        case MOUSETYPE.MOUSEUP:
            SendMouse(eup);
            break;

        case MOUSETYPE.MOUSECLICK:
            SendMouse(edown);
            SendMouse(eup);
            if (dblclick)
            {
                await Task.Delay(100);

                SendMouse(edown);
                SendMouse(eup);
            }
            break;
        }
    }
示例#16
0
        private void SendMouseInput(int x, int y, MOUSEEVENTF flags)
        {
            INPUT input = new INPUT
            {
                type = (int)INPUTTYPE.MOUSE,
                u = new InputUnion
                {
                    mi = new MOUSEINPUT
                    {
                        dx = x,
                        dy = y,
                        mouseData = 0,
                        dwFlags = (uint)flags,
                        time = 0, // the system will provide its own time stamp.
                        dwExtraInfo = this.winUser.GetMessageExtraInfo(),
                    }
                }
            };

            this.winUser.SendInput(1, new INPUT[] { input }, Marshal.SizeOf(typeof(INPUT)));
        }
示例#17
0
        private void SendMouseInput(int x, int y, MOUSEEVENTF flags)
        {
            INPUT input = new INPUT
            {
                type = (int)INPUTTYPE.MOUSE,
                u    = new InputUnion
                {
                    mi = new MOUSEINPUT
                    {
                        dx          = x,
                        dy          = y,
                        mouseData   = 0,
                        dwFlags     = (uint)flags,
                        time        = 0, // the system will provide its own time stamp.
                        dwExtraInfo = this.winUser.GetMessageExtraInfo(),
                    }
                }
            };

            this.winUser.SendInput(1, new INPUT[] { input }, Marshal.SizeOf(typeof(INPUT)));
        }
        private void MouseEvent(MOUSEEVENTF arg, uint dwData = 0)
        {
            var pos = GetCursorPosition();

            mouse_event((uint)arg, (uint)pos.X, (uint)pos.Y, dwData, 0);
        }
示例#19
0
 public static extern void mouse_event(MOUSEEVENTF dwFlags, uint dx, uint dy, uint dwData, uint dwExtraInfo);
示例#20
0
 protected void MouseEvent(MOUSEEVENTF arg, uint dwData = 0)
 {
     inputs[0].U.mi.dwFlags   = arg;
     inputs[0].U.mi.mouseData = dwData;
     SendInput(1, inputs, INPUT.Size);
 }
示例#21
0
        /// <summary>
        /// Performs Mouse button up/down simulation.
        /// </summary>
        /// <param name="mouseEvent">The mouse opperation to simulate</param>
        /// <param name="xButton">When mouseEvent is either XDOWN or XUP, xButton refers to either XBUTTON1 or XBUTTON2</param>
        public static void SimulateMouseButton(MOUSEEVENTF mouseEvent, XButton xButton = XButton.None)
        {
            var input = new INPUT();
            input.Type = (uint)InputType.MOUSE;
            input.Data.Mouse = new MOUSEINPUT();
            input.Data.Mouse.dwFlags = mouseEvent;

            if (mouseEvent == MOUSEEVENTF.XDOWN || mouseEvent == MOUSEEVENTF.XUP)
            {
                switch (xButton)
                {
                    case XButton.XBUTTON1:
                        input.Data.Mouse.mouseData = (int)XButton.XBUTTON1;
                        break;
                    case XButton.XBUTTON2:
                        input.Data.Mouse.mouseData = (int)XButton.XBUTTON2;
                        break;
                    default:
                        input.Data.Mouse.mouseData = 0;
                        break;
                }
            }
            else
            {
                input.Data.Mouse.mouseData = 0;
            }

            input.Data.Mouse.dx = 0;
            input.Data.Mouse.dy = 0;
            input.Data.Mouse.time = 0;
            input.Data.Mouse.dwExtraInfo = IntPtr.Zero;

            INPUT[] inputList = new INPUT[1];
            inputList[0] = input;

            var numberOfSuccessfulSimulatedInputs = SendInput(1, inputList, Marshal.SizeOf(typeof(INPUT)));
            if (numberOfSuccessfulSimulatedInputs == 0) throw new Exception(string.Format("The mouse simulation for {0} was not successful.", mouseEvent.ToString()));
        }
示例#22
0
 public static extern void mouse_event(MOUSEEVENTF dwFlags, UInt32 dx, int UInt32, UInt32 dwData, UIntPtr dwExtraInfo);
 protected void MouseEvent(MOUSEEVENTF arg, uint dwData = 0)
 {
     mouse_event((uint)arg, (uint)_last.X, (uint)_last.Y, dwData, 0);
 }
 internal static extern void mouse_event(MOUSEEVENTF dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
示例#25
0
        private void MouseEvent(MOUSEEVENTF arg, uint dwData = 0)
        {
            var pos = GetCursorPosition();

            mouse_event((uint)arg, (uint)(pos.X + _offsetX), (uint)(pos.Y + _offsetY), dwData, 0);
        }
示例#26
0
        private static void Click(MOUSEEVENTF up, MOUSEEVENTF down)
        {
            INPUT mouseInput = new INPUT();
            mouseInput.type = INPUT_MOUSE;
            mouseInput.U.mi.dx = 0;
            mouseInput.U.mi.dy = 0;
            mouseInput.U.mi.mouseData = MouseEventDataXButtons.Nothing;

            mouseInput.U.mi.dwFlags = down;
            SendInput(1, new INPUT[] { mouseInput }, INPUT.Size);

            mouseInput.U.mi.dwFlags = up;
            SendInput(1, new INPUT[] { mouseInput }, INPUT.Size);
        }
示例#27
0
        private static INPUT getInput(int vKey, bool?down)
        {
            MOUSEDATA   data  = 0;
            MOUSEEVENTF flags = 0;

            switch ((VK)vKey)
            {
            case VK.LBUTTON:
                if (down == null)
                {
                    flags = MOUSEEVENTF.LEFTDOWN | MOUSEEVENTF.LEFTUP;
                    break;
                }
                flags = (bool)down ? MOUSEEVENTF.LEFTDOWN : MOUSEEVENTF.LEFTUP;
                break;

            case VK.RBUTTON:
                if (down == null)
                {
                    flags = MOUSEEVENTF.RIGHTDOWN | MOUSEEVENTF.RIGHTUP;
                    break;
                }
                flags = (bool)down ? MOUSEEVENTF.RIGHTDOWN : MOUSEEVENTF.RIGHTUP;
                break;

            case VK.MBUTTON:
                if (down == null)
                {
                    flags = MOUSEEVENTF.MIDDLEDOWN | MOUSEEVENTF.MIDDLEUP;
                    break;
                }
                flags = (bool)down ? MOUSEEVENTF.MIDDLEDOWN : MOUSEEVENTF.MIDDLEUP;
                break;

            case VK.XBUTTON1:
                data = MOUSEDATA.XBUTTON1;
                if (down == null)
                {
                    flags = MOUSEEVENTF.XDOWN | MOUSEEVENTF.XUP;
                    break;
                }
                flags = (bool)down ? MOUSEEVENTF.XDOWN : MOUSEEVENTF.XUP;
                break;

            case VK.XBUTTON2:
                data = MOUSEDATA.XBUTTON2;
                if (down == null)
                {
                    flags = MOUSEEVENTF.XDOWN | MOUSEEVENTF.XUP;
                    break;
                }
                flags = (bool)down ? MOUSEEVENTF.XDOWN : MOUSEEVENTF.XUP;
                break;
            }
            INPUT input = new INPUT
            {
                type = INPUTTYPE.INPUT_MOUSE,
                mkhi = new MouseKeybdHardwareInputUnion()
                {
                    mi = new MOUSEINPUT()
                    {
                        dx          = 0,
                        dy          = 0,
                        mouseData   = (int)data,
                        dwFlags     = (uint)flags,
                        time        = 0,
                        dwExtraInfo = IntPtr.Zero
                    }
                }
            };

            return(input);
        }
示例#28
0
 private static extern void MouseEvent(MOUSEEVENTF dwFlags, int dx, int dy, int dwData, UIntPtr dwExtraInfo);
示例#29
0
 public static extern void mouse_event(MOUSEEVENTF dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
示例#30
0
 private static extern void mouse_event(MOUSEEVENTF dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
示例#31
0
            public override void Update()
            {
                base.Update();

                if (_obj is StopComm)
                {
                    Server.State = new AuthenticatedState();
                }
                else if (_obj is KeyMsg)
                {
                    KeyMsg  kMsg   = (KeyMsg)_obj;
                    INPUT[] inputs = new INPUT[1];
                    inputs[0].type     = (uint)InputType.INPUT_KEYBOARD;
                    inputs[0].U.ki.wVk = kMsg.VirtualKey;
                    Console.WriteLine(kMsg.VirtualKey);
                    Console.WriteLine(kMsg.Pressed);
                    if (!kMsg.Pressed)
                    {
                        inputs[0].U.ki.dwFlags = KEYEVENTF.KEYUP;
                    }
                    else
                    {
                        inputs[0].U.ki.dwFlags = 0;
                    }
                    inputs[0].U.ki.time        = 0;
                    inputs[0].U.ki.dwExtraInfo = (UIntPtr)(UInt64)0;
                    WindowsAPI.SendInput(1, inputs, System.Runtime.InteropServices.Marshal.SizeOf(inputs[0]));
                }
                else if (_obj is MouseMsg)
                {
                    MouseMsg mMsg   = (MouseMsg)_obj;
                    INPUT[]  inputs = new INPUT[1];
                    inputs[0].type    = (uint)InputType.INPUT_MOUSE;
                    inputs[0].U.mi.dx = mMsg.Dx;
                    inputs[0].U.mi.dy = mMsg.Dy;
                    MOUSEEVENTF dwFlags = 0;
                    if ((mMsg.Flags & (int)MouseEventFlags.LeftButtonDown) != 0)
                    {
                        dwFlags |= MOUSEEVENTF.LEFTDOWN;
                    }
                    if ((mMsg.Flags & (int)MouseEventFlags.LeftButtonUp) != 0)
                    {
                        dwFlags |= MOUSEEVENTF.LEFTUP;
                    }
                    if ((mMsg.Flags & (int)MouseEventFlags.RightButtonDown) != 0)
                    {
                        dwFlags |= MOUSEEVENTF.RIGHTDOWN;
                    }
                    if ((mMsg.Flags & (int)MouseEventFlags.RightButtonUp) != 0)
                    {
                        dwFlags |= MOUSEEVENTF.RIGHTUP;
                    }
                    if ((mMsg.Flags & (int)MouseEventFlags.MiddleButtonDown) != 0)
                    {
                        dwFlags |= MOUSEEVENTF.MIDDLEDOWN;
                    }
                    if ((mMsg.Flags & (int)MouseEventFlags.MiddleButtonUp) != 0)
                    {
                        dwFlags |= MOUSEEVENTF.MIDDLEUP;
                    }
                    if ((mMsg.Flags & (int)MouseEventFlags.Wheel) != 0)
                    {
                        dwFlags |= MOUSEEVENTF.WHEEL;
                    }
                    if ((mMsg.Flags & (int)MouseEventFlags.HWheel) != 0)
                    {
                        dwFlags |= MOUSEEVENTF.HWHEEL;
                    }
                    if ((mMsg.Flags & (int)MouseEventFlags.MouseMoved) != 0)
                    {
                        dwFlags |= MOUSEEVENTF.MOVE;
                    }
                    inputs[0].U.mi.dwFlags     = dwFlags;
                    inputs[0].U.mi.mouseData   = mMsg.MouseData;
                    inputs[0].U.mi.time        = 0;
                    inputs[0].U.mi.dwExtraInfo = (UIntPtr)(UInt64)0;
                    WindowsAPI.SendInput(1, inputs, System.Runtime.InteropServices.Marshal.SizeOf(inputs[0]));
                }
            }