0

Im using win32 touchinjection on windows 10 desktop.

I have been trying for two days to get pen simulation.

The code below works with PointerInputType.Touch but i need pressure and orientation, which don't seem to work.

GetLastError() returns 87 which means bad parameter but i have tried every pair of parameters i can think of.

       InitializeTouchInjection();

        pointer = new PointerTouchInfo();

        pointer.PointerInfo.PointerId = 1;
        pointer.PointerInfo.pointerType = PointerInputType.PEN;            

        pointer.TouchMasks = TouchMask.PRESSURE | TouchMask.ORIENTATION;
    //  pointer.TouchMasks =  TouchMask.CONTACTAREA | TouchMask.ORIENTATION | TouchMask.PRESSURE;
        pointer.Pressure = 1024;
        pointer.Orientation = 90;

   //   pointer.PointerInfo.PtHimetricLocation.X = 50;
   //   pointer.PointerInfo.PtHimetricLocation.Y = 200;
        pointer.PointerInfo.PtPixelLocation.X = 50;
        pointer.PointerInfo.PtPixelLocation.Y = 200;          

        pointer.PointerInfo.PointerFlags = PointerFlags.INCONTACT |PointerFlags.INRANGE| PointerFlags.DOWN;

        var a1=InjectTouchInput(1, new[] { pointer });
        var b1 = GetLastError();
        int errCode = Marshal.GetLastWin32Error();

Any information on how i could get this working or debug this further would be greatly appreciated.

jacobian
  • 141
  • 9
  • 1
    The [documentation](https://msdn.microsoft.com/en-us/library/windows/desktop/hh802881.aspx) states: *"Simulates touch input."* Maybe simulation of other pointing device input is simply not supported. Note, that the `POINTER_TOUCH_INFO` structure is used with other API calls as well (e.g. [GetPointerFrameTouchInfo](https://msdn.microsoft.com/en-us/library/windows/desktop/hh454883.aspx)), so don't expect the full set of features to be available in your use case. Of course, your structure definitions could be wrong, too. You should show that code as well. – IInspectable Feb 27 '18 at 20:13
  • Thanks, its from a Nuget package called TCD.System.TouchInjection with all the structure preset up. GetPointerFrameTouchInfo has a corresponding GetPointerFramePenInfo, you may be right though that the function just does not support pen and pressure. – jacobian Feb 27 '18 at 21:25
  • Try writing a C++ application to eliminate the .NET framework, P/Invoke declarations, and structure definitions as possible sources of errors. – IInspectable Feb 27 '18 at 21:31

1 Answers1

1

There's a new InjectSyntheticPointerInput API very similar to InjectTouchInput which supports pen as well as touch. Can't help with C# or .NET but I imagine it can be exposed the same way. Only problem is it's only supported by Windows 10 1809 and above, so you'll need at least that version of the Windows SDK (which only supports Visual Studio 2017, not 2015, FYI).

DuBistKomisch
  • 956
  • 10
  • 9