示例#1
0
        private void EmulateMouseButton(MouseButton buttonNumber, bool isUpCommand)
        {
            Logger.Info("Mouse Button " + buttonNumber + " " + (isUpCommand ? "up" : "down"));
            switch (buttonNumber)
            {
            case MouseButton.Left:
                if (isUpCommand)
                {
                    sim.Mouse.LeftButtonUp();
                }
                else
                {
                    sim.Mouse.LeftButtonDown();
                }
                break;

            case MouseButton.Right:
                if (isUpCommand)
                {
                    sim.Mouse.RightButtonUp();
                }
                else
                {
                    sim.Mouse.RightButtonDown();
                }
                break;

            case MouseButton.Middle:
                //if (isUpCommand)
                //	sim.Mouse.MButtonUp();
                //else
                //	sim.Mouse.LeftButtonDown()
                break;

            case MouseButton.Back:
                if (isUpCommand)
                {
                    sim.Mouse.XButtonUp(0);
                }
                else
                {
                    sim.Mouse.XButtonDown(0);
                }
                break;

            case MouseButton.Forward:
                if (isUpCommand)
                {
                    sim.Mouse.XButtonUp(1);
                }
                else
                {
                    sim.Mouse.XButtonDown(1);
                }
                break;
            }
        }
示例#2
0
        //~InputEmulator()
        //{
        //	if (isDisposed)
        //		return;
        //	Dispose(false);
        //}

        //public void Dispose()
        //{
        //	if (isDisposed)
        //		return;
        //	Dispose(true);
        //	GC.SuppressFinalize(this);
        //}

        //protected void Dispose(bool disposing)
        //{
        //	isDisposed = true;
        //}

        public void EmulateInput(SharedMemoryStream sm)
        {
            DesktopManager.AssociateCurrentThreadWithDefaultDesktop();
            InputType type = (InputType)sm.ReadByte();

            switch (type)
            {
            case InputType.KeyDown:
            case InputType.KeyUp:
            {
                int          keyCode   = sm.ReadInt32();
                ModifierKeys modifiers = (ModifierKeys)sm.ReadUInt32();
                bool         isUp      = type == InputType.KeyUp;
                EmulateKeyboard(keyCode, modifiers, isUp);
            }
            break;

            case InputType.MouseMove:
            {
                float X = sm.ReadFloat();
                float Y = sm.ReadFloat();
                EmulateMouseMove(X, Y);
            }
            break;

            case InputType.MouseButtonDown:
            case InputType.MouseButtonUp:
            {
                MouseButton button = (MouseButton)sm.ReadByte();
                bool        isUp   = type == InputType.MouseButtonUp;
                EmulateMouseButton(button, isUp);
            }
            break;

            case InputType.MouseWheel:
            {
                short deltaX = sm.ReadInt16();
                short deltaY = sm.ReadInt16();
                if (deltaX != 0)
                {
                    EmulateMouseWheelX(deltaX);
                }
                if (deltaY != 0)
                {
                    EmulateMouseWheelY(deltaY);
                }
            }
            break;

            default:
                break;
            }
        }