【问题标题】:Win32 pen simulation not working with InjectTouchInput()Win32 笔模拟不适用于 InjectTouchInput()
【发布时间】:2018-08-07 13:13:19
【问题描述】:

我在 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();

任何有关我如何使其工作或进一步调试的信息将不胜感激。

【问题讨论】:

  • documentation 声明:“模拟触摸输入。” 可能根本不支持模拟其他指针设备输入。请注意,POINTER_TOUCH_INFO 结构也与其他 API 调用一起使用(例如 GetPointerFrameTouchInfo),因此不要期望在您的用例中提供完整的功能集。当然,您的结构定义也可能是错误的。您也应该显示该代码。
  • 谢谢,它来自一个名为 TCD.System.TouchInjection 的 Nuget 包,所有结构都已预设。 GetPointerFrameTouchInfo 有一个对应的GetPointerFramePenInfo,你可能是对的,虽然这个函数只是不支持笔和压力。
  • 尝试编写一个 C++ 应用程序来消除 .NET 框架、P/Invoke 声明和结构定义作为可能的错误来源。

标签: c# c++ winapi pen


【解决方案1】:

有一个新的InjectSyntheticPointerInput API 与InjectTouchInput 非常相似,它支持笔和触摸。对 C# 或 .NET 无能为力,但我想它可以以同样的方式公开。唯一的问题是它仅受 Windows 10 1809 及更高版本支持,因此您至少需要该版本的 Windows SDK(仅支持 Visual Studio 2017,不支持 2015,仅供参考)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-20
    • 2014-12-02
    • 1970-01-01
    • 1970-01-01
    • 2017-08-17
    相关资源
    最近更新 更多