Ejemplo n.º 1
0
        public override void DoBeforeNextExecute()
        {
            // If a mouse command was given in the script, issue it all at once right here
            if ((int)deltaXOut != 0 || (int)deltaYOut != 0 || wheel != 0)
            {
                var input = new MouseKeyIO.INPUT[1];
                input[0].type = MouseKeyIO.INPUT_MOUSE;
                input[0].mi   = MouseInput((int)deltaXOut, (int)deltaYOut, (uint)wheel, 0, MouseKeyIO.MOUSEEVENTF_MOVE | MouseKeyIO.MOUSEEVENTF_WHEEL);

                MouseKeyIO.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));

                // Reset the mouse values
                if ((int)deltaXOut != 0)
                {
                    deltaXOut = deltaXOut - (int)deltaXOut;
                }
                if ((int)deltaYOut != 0)
                {
                    deltaYOut = deltaYOut - (int)deltaYOut;
                }

                wheel = 0;
            }

            currentMouseState = null;  // flush the mouse state

            setButtonPressedStrategy.Do();
        }
        public void KeyDown(int code)
        {
            if (!MyKeyDown[code])
            {
                //System.Console.Out.WriteLine("keydown");
                MyKeyDown[code] = true;
                int scancode = ScanCodeMap[code]; // convert the keycode for SendInput

                var input = new MouseKeyIO.INPUT[1];
                input[0].type = MouseKeyIO.INPUT_KEYBOARD;
                input[0].ki   = KeyInput((ushort)scancode, extendedKeyMap.Contains(code) ? MouseKeyIO.KEYEVENTF_EXTENDEDKEY : 0);

                MouseKeyIO.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));
            }
        }
Ejemplo n.º 3
0
        //--------------------------------------------------------------------------
        public void KeyDown(int code)
        {
            if (!MyKeyDown[code])
            {
                //System.Console.Out.WriteLine("keydown");
                MyKeyDown[code] = true;
                code            = ScanCodeMap[code]; // convert the keycode for SendInput

                MouseKeyIO.INPUT[] input = new MouseKeyIO.INPUT[1];
                input[0].type = MouseKeyIO.INPUT_KEYBOARD;
                input[0].ki   = KeyInput((ushort)code, 0);

                MouseKeyIO.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));
            }
        }
Ejemplo n.º 4
0
        //---------------------------------------------------------------------
        public override void DoBeforeNextExecute()
        {
            // If a mouse command was given in the script, issue it all at once right here
            if ((DeltaXOut != 0) || (DeltaYOut != 0))
            {
                var input = new MouseKeyIO.INPUT[1];
                input[0].type = MouseKeyIO.INPUT_MOUSE;
                input[0].mi   = MouseInput(DeltaXOut, DeltaYOut, 0, 0, MouseKeyIO.MOUSEEVENTF_MOVE);

                MouseKeyIO.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));

                // Reset the mouse values
                DeltaXOut = 0;
                DeltaYOut = 0;
            }

            CurrentMouseState = null;  // flush the mouse state

            setButtonPressedStrategy.Do();
        }
Ejemplo n.º 5
0
        //--------------------------------------------------------------------------
        public void KeyUp(int code)
        {
            if (MyKeyDown[code])
            {
                //System.Console.Out.WriteLine("keyup");
                MyKeyDown[code] = false;

                int scancode = ScanCodeMap[code]; // convert the keycode for SendInput

                var input = new MouseKeyIO.INPUT[1];
                input[0].type = MouseKeyIO.INPUT_KEYBOARD;
                if (ExtendedKeyMap[code])
                {
                    input[0].ki = KeyInput((ushort)scancode, MouseKeyIO.KEYEVENTF_EXTENDEDKEY | MouseKeyIO.KEYEVENTF_KEYUP);
                }
                else
                {
                    input[0].ki = KeyInput((ushort)scancode, MouseKeyIO.KEYEVENTF_KEYUP);
                }

                MouseKeyIO.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));
            }
        }
Ejemplo n.º 6
0
        public void SetButtonPressed(int index, bool pressed)
        {
            uint btn_flag = 0;

            if (index == 0)
            {
                if (pressed)
                {
                    if (!leftPressed)
                    {
                        btn_flag = MouseKeyIO.MOUSEEVENTF_LEFTDOWN;
                    }
                }
                else
                {
                    if (leftPressed)
                    {
                        btn_flag = MouseKeyIO.MOUSEEVENTF_LEFTUP;
                    }
                }
                leftPressed = pressed;
            }
            else if (index == 1)
            {
                if (pressed)
                {
                    if (!rightPressed)
                    {
                        btn_flag = MouseKeyIO.MOUSEEVENTF_RIGHTDOWN;
                    }
                }
                else
                {
                    if (rightPressed)
                    {
                        btn_flag = MouseKeyIO.MOUSEEVENTF_RIGHTUP;
                    }
                }
                rightPressed = pressed;
            }
            else
            {
                if (pressed)
                {
                    if (!middlePressed)
                    {
                        btn_flag = MouseKeyIO.MOUSEEVENTF_MIDDLEDOWN;
                    }
                }
                else
                {
                    if (middlePressed)
                    {
                        btn_flag = MouseKeyIO.MOUSEEVENTF_MIDDLEUP;
                    }
                }
                middlePressed = pressed;
            }

            if (btn_flag != 0)
            {
                var input = new MouseKeyIO.INPUT[1];
                input[0].type = MouseKeyIO.INPUT_MOUSE;
                input[0].mi   = MouseInput(0, 0, 0, 0, btn_flag);

                MouseKeyIO.SendInput(1, input, Marshal.SizeOf(input[0].GetType()));
            }
        }