Windows.UI.Input.Preview.Injection
Windows.UI.Input.Preview.Injection
Windows.UI.Input.Preview.Injection
Windows.UI.Input.Preview.Injection
Namespace
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.
[This namespace contains one or more prerelease APIs.]
Provides support for programmatically generating and automating input from a variety of devices such as keyboard, mouse, touch, pen, and gamepad.
Note
The APIs in this namespace require the inputInjectionBrokered restricted capability.
Classes
| InjectedInputGamepadInfo InjectedInputGamepadInfo InjectedInputGamepadInfo InjectedInputGamepadInfo |
[Contains prerelease APIs.] NoteThe APIs in this namespace require the inputInjectionBrokered restricted capability. |
| InjectedInputKeyboardInfo InjectedInputKeyboardInfo InjectedInputKeyboardInfo InjectedInputKeyboardInfo |
Represents programmatically generated keyboard input. NoteThe APIs in this namespace require the inputInjectionBrokered restricted capability. |
| InjectedInputMouseInfo InjectedInputMouseInfo InjectedInputMouseInfo InjectedInputMouseInfo |
Represents programmatically generated mouse input. NoteThe APIs in this namespace require the inputInjectionBrokered restricted capability. |
| InjectedInputPenInfo InjectedInputPenInfo InjectedInputPenInfo InjectedInputPenInfo |
Represents programmatically generated pen input. NoteThe APIs in this namespace require the inputInjectionBrokered restricted capability. |
| InjectedInputTouchInfo InjectedInputTouchInfo InjectedInputTouchInfo InjectedInputTouchInfo |
Represents programmatically generated touch input. NoteThe APIs in this namespace require the inputInjectionBrokered restricted capability. |
| InputInjector InputInjector InputInjector InputInjector |
[Contains prerelease APIs.] NoteThe APIs in this namespace require the inputInjectionBrokered restricted capability. |
Structs
| InjectedInputPoint InjectedInputPoint InjectedInputPoint InjectedInputPoint |
Contains the screen coordinates of the pointer in device-independent pixel (DIP). NoteThe APIs in this namespace require the inputInjectionBrokered restricted capability. |
| InjectedInputPointerInfo InjectedInputPointerInfo InjectedInputPointerInfo InjectedInputPointerInfo |
Contains basic pointer information common to all pointer types. NoteThe APIs in this namespace require the inputInjectionBrokered restricted capability. |
| InjectedInputRectangle InjectedInputRectangle InjectedInputRectangle InjectedInputRectangle |
The screen coordinates of the bounding box that represents the touch contact area. NoteThe APIs in this namespace require the inputInjectionBrokered restricted capability. |
Enums
Examples
Here, we show how to inject a single touch contact and corresponding pointer up input events.
private void InjectTouch_Button_Click(object sender, RoutedEventArgs e)
{
InputInjector inputInjector = InputInjector.TryCreate();
if (inputInjector != null)
{
try
{
inputInjector.InitializeTouchInjection(
InjectedInputVisualizationMode.Indirect);
// Each element in the list represents a single contact.
// Multiple elements represent multiple contacts.
inputInjector.InjectTouchInput(
new List<InjectedInputTouchInfo>
{
new InjectedInputTouchInfo
{
Contact = new InjectedInputRectangle {
Top = 50, Bottom = 50, Left = 40, Right = 40 },
PointerInfo = new InjectedInputPointerInfo
{
// PerformanceCount default is 0.
// This uses the current tick (or TimeOffsetInMS) in milliseconds.
// The first value passed in becomes a baseline or reference value
// and is treated as a zero time offset. Each subsequent value must
// be larger than the preceeding value. The difference is used
// to calculate timed events such as double click events.
//
// Alternatively, the caller can pass in the value of
// QueryPerformanceCounter into the PerformanceCount field.
PixelLocation = new InjectedInputPoint
{
PositionX = 40, PositionY = 50
},
// PointerID is assigned to a pointer during it’s lifetime in contact with
// a touch device.
// The scope of this ID is the InputInjector instance (between a
// call to Initialize and the corresponding call to Uninitialize).
PointerOptions = InjectedInputPointerOptions.InContact,
PointerId = 1
},
Pressure = 1.0,
TouchParameters =
InjectedInputTouchParameters.Pressure |
InjectedInputTouchParameters.Contact
}
});
// Copied from some test tool code...
System.Threading.Tasks.Task.Delay(100).Wait();
inputInjector.InjectTouchInput(
new List<InjectedInputTouchInfo> {
new InjectedInputTouchInfo {
Contact = new InjectedInputRectangle
{
Top = 50,
Bottom = 50,
Left = 40,
Right = 40
},
PointerInfo = new InjectedInputPointerInfo {
PixelLocation = new InjectedInputPoint {
PositionX = 40, PositionY = 50
},
PointerOptions = InjectedInputPointerOptions.PointerUp,
PointerId = 1,
},
Pressure = 0.0,
TouchParameters =
InjectedInputTouchParameters.Pressure |
InjectedInputTouchParameters.Contact
}
});
}
catch (ArgumentException args)
{
// Handle exception.
}
}
}
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" />
See Also
- Input & devices
- Interaction primer
- User interaction mode sample
- Focus visuals sample
- Input: Device capabilities sample
- Input: Ink sample
- Input: Manipulations and gestures (JavaScript) sample
- Input: Simplified ink sample
- Input: Windows 8 gestures sample
- Input: XAML user input events sample
- XAML scrolling, panning, and zooming sample
- DirectX touch input sample
- Input: Manipulations and gestures (C++) sample
- Input: Touch hit testing sample
- Input source identification sample
- Touch injection sample
- Win32 touch hit-testing sample