Beispiel #1
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;
            }
        }