简体   繁体   中英

Win32 pen simulation not working with InjectTouchInput()

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.

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM