InputInjector InputInjector InputInjector InputInjector Class

Definition

Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Prerelease APIs are identified by a Prerelease label.

[Contains prerelease APIs.]
Represents the virtual input device for sending the input data.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : sealed class InputInjector : IInputInjectorpublic sealed class InputInjector : IInputInjectorPublic NotInheritable Class InputInjector Implements IInputInjector// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

Remarks

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

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

Methods

InitializeGamepadInjection() InitializeGamepadInjection() InitializeGamepadInjection() InitializeGamepadInjection()

Prerelease. Initializes a virtual gamepad device that can synthesize input events and provide corresponding input data to your app.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void InitializeGamepadInjection()public void InitializeGamepadInjection()Public Function InitializeGamepadInjection() As void// You can use this method in JavaScript.
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.16257.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Remarks

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

  • To <Package>

    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"

    • IgnorableNamespaces="rescap"

  • To <Capabilities>

    • <rescap:Capability Name="inputInjectionBrokered" />

Calling this method is analogous to connecting a physical gamepad, which also triggers a GamepadAdded event.

A physical gamepad is assigned a persistent unique ID (see NonRoamableId) that does not change when the device is connected and disconnected. Similarly, a virtual gamepad created with InitializeGamepadInjection is also assigned a unique ID that persists across calls to UninitializeGamepadInjection and InitializeGamepadInjection for the same InputInjector instance.

InitializePenInjection(InjectedInputVisualizationMode) InitializePenInjection(InjectedInputVisualizationMode) InitializePenInjection(InjectedInputVisualizationMode) InitializePenInjection(InjectedInputVisualizationMode)

Initializes a virtual pen device that can synthesize input events and provide corresponding input data to your app.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void InitializePenInjection(InjectedInputVisualizationMode visualMode)public void InitializePenInjection(InjectedInputVisualizationMode visualMode)Public Function InitializePenInjection(visualMode As InjectedInputVisualizationMode) As void// You can use this method in JavaScript.
Parameters

Remarks

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

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

InitializeTouchInjection(InjectedInputVisualizationMode) InitializeTouchInjection(InjectedInputVisualizationMode) InitializeTouchInjection(InjectedInputVisualizationMode) InitializeTouchInjection(InjectedInputVisualizationMode)

Initializes a virtual touch device that can synthesize input events and provide corresponding input data to your app.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void InitializeTouchInjection(InjectedInputVisualizationMode visualMode)public void InitializeTouchInjection(InjectedInputVisualizationMode visualMode)Public Function InitializeTouchInjection(visualMode As InjectedInputVisualizationMode) As void// You can use this method in JavaScript.
Parameters

Remarks

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

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

InjectGamepadInput(InjectedInputGamepadInfo) InjectGamepadInput(InjectedInputGamepadInfo) InjectGamepadInput(InjectedInputGamepadInfo) InjectGamepadInput(InjectedInputGamepadInfo)

Prerelease. Sends programmatically generated gamepad input to the system.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void InjectGamepadInput(InjectedInputGamepadInfo input)public void InjectGamepadInput(InjectedInputGamepadInfo input)Public Function InjectGamepadInput(input As InjectedInputGamepadInfo) As void// You can use this method in JavaScript.
Parameters
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.16257.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Remarks

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

  • To <Package>

    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"

    • IgnorableNamespaces="rescap"

  • To <Capabilities>

    • <rescap:Capability Name="inputInjectionBrokered" />

InjectKeyboardInput(IIterable) InjectKeyboardInput(IIterable) InjectKeyboardInput(IIterable) InjectKeyboardInput(IIterable)

Sends programmatically generated keyboard input to the system.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void InjectKeyboardInput(IIterable<InjectedInputKeyboardInfo> input)public void InjectKeyboardInput(IEnumerable<InjectedInputKeyboardInfo> input)Public Function InjectKeyboardInput(input As IEnumerable<InjectedInputKeyboardInfo>) As void// You can use this method in JavaScript.
Parameters
input
IIterable<InjectedInputKeyboardInfo> IEnumerable<InjectedInputKeyboardInfo> IEnumerable<InjectedInputKeyboardInfo> IEnumerable<InjectedInputKeyboardInfo>

The keyboard input specified by InjectedInputKeyboardInfo.

Remarks

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

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

InjectMouseInput(IIterable) InjectMouseInput(IIterable) InjectMouseInput(IIterable) InjectMouseInput(IIterable)

Sends programmatically generated mouse input to the system.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void InjectMouseInput(IIterable<InjectedInputMouseInfo> input)public void InjectMouseInput(IEnumerable<InjectedInputMouseInfo> input)Public Function InjectMouseInput(input As IEnumerable<InjectedInputMouseInfo>) As void// You can use this method in JavaScript.
Parameters
input
IIterable<InjectedInputMouseInfo> IEnumerable<InjectedInputMouseInfo> IEnumerable<InjectedInputMouseInfo> IEnumerable<InjectedInputMouseInfo>

The mouse input specified by InjectedInputMouseInfo.

Remarks

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

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

InjectPenInput(InjectedInputPenInfo) InjectPenInput(InjectedInputPenInfo) InjectPenInput(InjectedInputPenInfo) InjectPenInput(InjectedInputPenInfo)

Sends programmatically generated pen input to the system.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void InjectPenInput(InjectedInputPenInfo input)public void InjectPenInput(InjectedInputPenInfo input)Public Function InjectPenInput(input As InjectedInputPenInfo) As void// You can use this method in JavaScript.
Parameters

Remarks

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

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

InjectShortcut(InjectedInputShortcut) InjectShortcut(InjectedInputShortcut) InjectShortcut(InjectedInputShortcut) InjectShortcut(InjectedInputShortcut)

Sends programmatically generated system shortcuts to the system.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void InjectShortcut(InjectedInputShortcut shortcut)public void InjectShortcut(InjectedInputShortcut shortcut)Public Function InjectShortcut(shortcut As InjectedInputShortcut) As void// You can use this method in JavaScript.
Parameters

Remarks

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

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

InjectTouchInput(IIterable) InjectTouchInput(IIterable) InjectTouchInput(IIterable) InjectTouchInput(IIterable)

Sends programmatically generated touch input to the system.

public : void InjectTouchInput(IIterable<InjectedInputTouchInfo> input)public void InjectTouchInput(IEnumerable<InjectedInputTouchInfo> input)Public Function InjectTouchInput(input As IEnumerable<InjectedInputTouchInfo>) As void// You can use this method in JavaScript.
Parameters
input
IIterable<InjectedInputTouchInfo> IEnumerable<InjectedInputTouchInfo> IEnumerable<InjectedInputTouchInfo> IEnumerable<InjectedInputTouchInfo>

The touch input specified by InjectedInputTouchInfo.

Remarks

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

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

TryCreate() TryCreate() TryCreate() TryCreate()

Attempts to create a new instance of the InputInjector class.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : static InputInjector TryCreate()public static InputInjector TryCreate()Public Static Function TryCreate() As InputInjector// You can use this method in JavaScript.
Returns

If successful, returns a new instance of the InputInjector class. Otherwise, returns null.

Remarks

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

  • To <Package>

    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"

    • IgnorableNamespaces="rescap"

  • To <Capabilities>

    • <rescap:Capability Name="inputInjectionBrokered" />

TryCreateForAppBroadcastOnly() TryCreateForAppBroadcastOnly() TryCreateForAppBroadcastOnly() TryCreateForAppBroadcastOnly()

Prerelease. Attempts to create a new instance of the InputInjector class.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : static InputInjector TryCreateForAppBroadcastOnly()public static InputInjector TryCreateForAppBroadcastOnly()Public Static Function TryCreateForAppBroadcastOnly() As InputInjector// You can use this method in JavaScript.
Returns

If successful, returns a new instance of the InputInjector class. Otherwise, returns null.

Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.16257.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Remarks

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

  • To <Package>

    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"

    • IgnorableNamespaces="rescap"

  • To <Capabilities>

    • <rescap:Capability Name="inputInjectionBrokered" />

This method differs from TryCreate in that input injection is restricted to the process that is actively being captured for broadcast using an App​Broadcast​Services object. Injected input is silently dropped when there is no such active process.

UninitializeGamepadInjection() UninitializeGamepadInjection() UninitializeGamepadInjection() UninitializeGamepadInjection()

Prerelease. Shuts down the virtual gamepad device created with InitializeGamepadInjection.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void UninitializeGamepadInjection()public void UninitializeGamepadInjection()Public Function UninitializeGamepadInjection() As void// You can use this method in JavaScript.
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.16257.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Remarks

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

  • To <Package>

    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"

    • IgnorableNamespaces="rescap"

  • To <Capabilities>

    • <rescap:Capability Name="inputInjectionBrokered" />

Calling this method is analogous to disconnecting a physical gamepad, which also triggers a GamepadRemoved event.

A physical gamepad is assigned a persistent unique ID (see NonRoamableId) that does not change when the device is connected and disconnected. Similarly, a virtual gamepad created with InitializeGamepadInjection is also assigned a unique ID that persists across calls to UninitializeGamepadInjection and InitializeGamepadInjection for the same InputInjector instance.

UninitializePenInjection() UninitializePenInjection() UninitializePenInjection() UninitializePenInjection()

Shuts down the virtual pen device created with InitializePenInjection.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void UninitializePenInjection()public void UninitializePenInjection()Public Function UninitializePenInjection() As void// You can use this method in JavaScript.

Remarks

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

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />

UninitializeTouchInjection() UninitializeTouchInjection() UninitializeTouchInjection() UninitializeTouchInjection()

Shuts down the virtual touch device created with InitializeTouchInjection.

Note

The APIs in this namespace require the inputInjectionBrokered restricted capability.

public : void UninitializeTouchInjection()public void UninitializeTouchInjection()Public Function UninitializeTouchInjection() As void// You can use this method in JavaScript.

Remarks

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

  • To <Package>
    • xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
    • IgnorableNamespaces="rescap"
  • To <Capabilities>
    • <rescap:Capability Name="inputInjectionBrokered" />