我在Windows 10桌面上使用win32 touchinjection。
我已经尝试了两天来进行笔模拟。
下面的代码适用于PointerInputType.Touch,但我需要压力和方向,这似乎不起作用。
GetLastError()返回87表示错误的参数,但我已经尝试了我能想到的每一对参数。
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();
我将非常感谢有关如何使其工作或进一步调试的任何信息。
答案 0 :(得分:1)
有一个新的InjectSyntheticPointerInput
API与InjectTouchInput
非常相似,它支持笔和触摸。无法使用C#或.NET,但我想可以用相同的方式公开它。唯一的问题是Windows 10 1809及更高版本仅支持该版本,因此您至少需要该版本的Windows SDK(仅支持Visual Studio 2017,不支持2015,FYI)。