Windows.UI.Input.Preview.Injection Windows.UI.Input.Preview.Injection Windows.UI.Input.Preview.Injection Windows.UI.Input.Preview.Injection Windows.UI.Input.Preview.Injection Namespace

Provides support for programmatically generating and automating input from a variety of devices such as keyboard, mouse, touch, pen, and gamepad.


The APIs in this namespace require the inputInjectionBrokered restricted capability.


InjectedInputGamepadInfo InjectedInputGamepadInfo InjectedInputGamepadInfo InjectedInputGamepadInfo InjectedInputGamepadInfo

Represents programmatically generated gamepad input.

InjectedInputKeyboardInfo InjectedInputKeyboardInfo InjectedInputKeyboardInfo InjectedInputKeyboardInfo InjectedInputKeyboardInfo

Represents programmatically generated keyboard input.

InjectedInputMouseInfo InjectedInputMouseInfo InjectedInputMouseInfo InjectedInputMouseInfo InjectedInputMouseInfo

Represents programmatically generated mouse input.

InjectedInputPenInfo InjectedInputPenInfo InjectedInputPenInfo InjectedInputPenInfo InjectedInputPenInfo

Represents programmatically generated pen input.

InjectedInputTouchInfo InjectedInputTouchInfo InjectedInputTouchInfo InjectedInputTouchInfo InjectedInputTouchInfo

Represents programmatically generated touch input.

InputInjector InputInjector InputInjector InputInjector InputInjector

Represents the virtual input device for sending the input data.


InjectedInputPoint InjectedInputPoint InjectedInputPoint InjectedInputPoint InjectedInputPoint

Contains the screen coordinates of the pointer in device-independent pixel (DIP).

InjectedInputPointerInfo InjectedInputPointerInfo InjectedInputPointerInfo InjectedInputPointerInfo InjectedInputPointerInfo

Contains basic pointer information common to all pointer types.

InjectedInputRectangle InjectedInputRectangle InjectedInputRectangle InjectedInputRectangle InjectedInputRectangle

The offsets, from the injected pointer, for the bounding box that represents the touch contact area.


InjectedInputButtonChangeKind InjectedInputButtonChangeKind InjectedInputButtonChangeKind InjectedInputButtonChangeKind InjectedInputButtonChangeKind

Specifies the changes in state of a button associated with a pointer.

InjectedInputKeyOptions InjectedInputKeyOptions InjectedInputKeyOptions InjectedInputKeyOptions InjectedInputKeyOptions

Specifies the various options, or modifiers, used to simulate input from physical or virtual keyboards through InjectedInputKeyboardInfo.

InjectedInputMouseOptions InjectedInputMouseOptions InjectedInputMouseOptions InjectedInputMouseOptions InjectedInputMouseOptions

Specifies the various options, or modifiers, used to simulate mouse input through InjectedInputMouseInfo.

InjectedInputPenButtons InjectedInputPenButtons InjectedInputPenButtons InjectedInputPenButtons InjectedInputPenButtons

Specifies the pen options used to simulate pen input through InjectedInputPenInfo.

InjectedInputPenParameters InjectedInputPenParameters InjectedInputPenParameters InjectedInputPenParameters InjectedInputPenParameters

Specifies the pen states used to simulate pen input through InjectedInputPenInfo.

InjectedInputPointerOptions InjectedInputPointerOptions InjectedInputPointerOptions InjectedInputPointerOptions InjectedInputPointerOptions

Specifies the various options, or modifiers, used to simulate pointer input through InjectedInputMouseInfo, InjectedInputPenInfo, and InjectedInputTouchInfo.

InjectedInputShortcut InjectedInputShortcut InjectedInputShortcut InjectedInputShortcut InjectedInputShortcut

Specifies the system shortcuts for InjectShortcut.

InjectedInputTouchParameters InjectedInputTouchParameters InjectedInputTouchParameters InjectedInputTouchParameters InjectedInputTouchParameters

Specifies the touch states used to simulate touch input through InjectedInputTouchInfo.

InjectedInputVisualizationMode InjectedInputVisualizationMode InjectedInputVisualizationMode InjectedInputVisualizationMode InjectedInputVisualizationMode

Specifies the type of visual feedback displayed for the injected input type.


Here's an example of a touch input injection function.

First, we call TryCreate to instantiate the InputInjector object.

Then, we call InitializeTouchInjection with an InjectedInputVisualizationMode of Default.

After calculating the point of injection, we call InjectedInputTouchInfo to initialize the list of touch points to inject (for this example, we create one touch point corresponding to the mouse input pointer).

Finally, we call InjectTouchInput twice, the first for a pointer down and the second for a pointer up.

/// <summary>
/// Inject touch input on injection target corresponding 
/// to mouse click on input target.
/// </summary>
/// <param name="pointerPoint">The mouse click pointer.</param>
private void InjectTouchForMouse(PointerPoint pointerPoint)
    // Create the touch injection object.
    _inputInjector = InputInjector.TryCreate();

    if (_inputInjector != null)

        // Create a unique pointer ID for the injected touch pointer.
        // Multiple input pointers would require more robust handling.
        uint pointerId = pointerPoint.PointerId + 1;

        // Get the bounding rectangle of the app window.
        Rect appBounds =

        // Get the top left screen coordinates of the app window rect.
        Point appBoundsTopLeft = new Point(appBounds.Left, appBounds.Top);

        // Get a reference to the input injection area.
        GeneralTransform injectArea =

        // Get the top left screen coordinates of the input injection area.
        Point injectAreaTopLeft = injectArea.TransformPoint(new Point(0, 0));

        // Get the screen coordinates (relative to the input area) 
        // of the input pointer.
        int pointerPointX = (int)pointerPoint.Position.X;
        int pointerPointY = (int)pointerPoint.Position.Y;

        // Create the point for input injection and calculate its screen location.
        Point injectionPoint =
            new Point(
                appBoundsTopLeft.X + injectAreaTopLeft.X + pointerPointX,
                appBoundsTopLeft.Y + injectAreaTopLeft.Y + pointerPointY);

        // Create a touch data point for pointer down.
        // Each element in the touch data list represents a single touch contact. 
        // For this example, we're mirroring a single mouse pointer.
        List<InjectedInputTouchInfo> touchData =
            new List<InjectedInputTouchInfo>
                new InjectedInputTouchInfo
                    Contact = new InjectedInputRectangle
                        Left = 30, Top = 30, Bottom = 30, Right = 30
                    PointerInfo = new InjectedInputPointerInfo
                        PointerId = pointerId,
                        PointerOptions =
                        InjectedInputPointerOptions.PointerDown |
                        InjectedInputPointerOptions.InContact |
                        TimeOffsetInMilliseconds = 0,
                        PixelLocation = new InjectedInputPoint
                            PositionX = (int)injectionPoint.X ,
                            PositionY = (int)injectionPoint.Y
                Pressure = 1.0,
                TouchParameters =
                    InjectedInputTouchParameters.Pressure |

        // Inject the touch input. 

        // Create a touch data point for pointer up.
        touchData = new List<InjectedInputTouchInfo>
            new InjectedInputTouchInfo
                PointerInfo = new InjectedInputPointerInfo
                    PointerId = pointerId,
                    PointerOptions = InjectedInputPointerOptions.PointerUp

        // Inject the touch input. 


Using input injection requires the following be added to the Package.appxmanifest:

  • To <Package>
    • xmlns:rescap=""
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

See Also

  • # Conceptual [Gaze interactions and eye tracking in UWP apps]( ### Samples - [Simulate user input through input injection]( - [Input injection sample (mouse to touch)]( - [Touch injection sample]( - [Input: XAML user input events sample](