A .NET Standard Port of Windows.UI.Input.Preview.Injection
You can use it for software testing or writing tools for cheating in games.
We provide wrapped undocumented APIs in the Nukepayload2.Diagnostics.Preview
namespace.
VB
SendTouch(123, 456, 789)
C#
SendTouch(123, 456, 789);
VB
Dim injection = InputInjector.TryCreate
If injection Is Nothing Then MsgBox("Your system is too old to use touch injection.", vbExclamation, "Not supported")
injection.InitializeTouchInjection(InjectedInputVisualizationMode.Default)
Const PosX = 123
Const PosY = 456
Const DurationMilliseconds = 789
With injection
Dim touch As New InjectedInputTouchInfo With {
.PointerInfo = New InjectedInputPointerInfo With {
.PointerId = CUInt(pointerId),
.PixelLocation = New InjectedInputPoint With {
.PositionX = PosX, ' Y co-ordinate of touch on screen
.PositionY = PosY ' X co-ordinate of touch on screen
},
.PointerType = PointerInputType.Touch ' Must be set to PointerInputType.Touch. It's different from UWP.
},
.TouchParameters =
InjectedInputTouchParameters.Contact Or
InjectedInputTouchParameters.Orientation Or
InjectedInputTouchParameters.Pressure, ' TouchMask
.Orientation = 90,
.Pressure = 1024
}
' defining contact area (I have taken area of 30 x 30 pixel)
Dim pxLoc As InjectedInputPoint = touch.PointerInfo.PixelLocation
touch.Contact = New InjectedInputRectangle With {
.Top = pxLoc.PositionY - 15,
.Bottom = pxLoc.PositionY + 15,
.Left = pxLoc.PositionX - 15,
.Right = pxLoc.PositionX + 15
}
' TouchDown
touch.PointerInfo.PointerOptions =
InjectedInputPointerOptions.PointerDown Or
InjectedInputPointerOptions.InRange Or
InjectedInputPointerOptions.InContact
.InjectTouchInput(touch) ' Injecting the touch Down from screen
' Hold
touch.PointerInfo.PointerOptions =
InjectedInputPointerOptions.Update Or
InjectedInputPointerOptions.InRange Or
InjectedInputPointerOptions.InContact
Dim timer As New Stopwatch
timer.Start()
Do While timer.ElapsedMilliseconds < DurationMilliseconds
.InjectTouchInput(touch)
Loop
timer.Stop()
' TouchUp
touch.PointerInfo.PointerOptions = InjectedInputPointerOptions.PointerUp
.InjectTouchInput(touch) ' Injecting the touch Up from screen
End With
InjectTouchInput
and [user32] InitializeTouchInjection
)RemoveInjectionDevice
is undocumented)XboxgipSynthetic.dll
is undocumented)SyntheticController_RemoveController
is undocumented)InjectPointerInput
and [user32] InitializePointerDeviceInjection
are undocumented)RemoveInjectionDevice
is undocumented)InjectMouseInput
is undocumented)InjectKeyboardInput
is undocumented)InjectKeyboardInput
is undocumented)