【问题标题】:Is there a way to simulate touch events in Windows 8有没有办法在 Windows 8 中模拟触摸事件
【发布时间】:2011-11-22 09:10:05
【问题描述】:

有没有办法在 Windows 8 中模拟触摸事件(最好是在 Windows 7 中)。
我知道有一个名为 Multi touch vista 的项目,但我觉得它有点矫枉过正,而且我从来没有让它在多个屏幕上正常工作。
我想做的很简单,我想启动一个应用程序,它可以向 Windows 发送触摸事件,而不需要多个鼠标或类似的东西。
可以完成还是我需要(MMV)驱动程序才能做到这一点?

谢谢
/吉米

【问题讨论】:

    标签: c# windows-7 touch windows-8


    【解决方案1】:

    进一步指向 InjectTouchInput 的 C++ 示例代码的解决方案,该代码打包在 Windows 8 的 User32.dll 中,C# 解决方案可以在这里找到:

    InjectTouchInput Windows 8 C# not working (returns false)

    【讨论】:

      【解决方案2】:

      我在寻找类似的东西,发现这篇文章 Simulating Touch Input in Windows Developer preview using Touch Injection APIsample code (C++) 可能会回答你的问题。但是,这似乎只适用于 Windows 8(而不是 Windows 7)。

      它模拟点击、按住、拖动、捏/平移、旋转和横向滑动。

      这里是触摸(Tap)代码:

      POINTER_TOUCH_INFO contact;
      InitializeTouchInjection(1, TOUCH_FEEDBACK_DEFAULT); // Here number of contact point is declared as 1.
      memset(&contact, 0, sizeof(POINTER_TOUCH_INFO)); 
      
      contact.pointerInfo.pointerType = PT_TOUCH;
      contact.pointerInfo.pointerId = 0;          //contact 0
      contact.pointerInfo.ptPixelLocation.y = 200; // Y co-ordinate of touch on screen
      contact.pointerInfo.ptPixelLocation.x = 300; // X co-ordinate of touch on screen
      
      contact.touchFlags = TOUCH_FLAG_NONE;
      contact.touchMask = TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
      contact.orientation = 90; // Orientation of 90 means touching perpendicular to screen.
      contact.pressure = 32000; 
      
      // defining contact area (I have taken area of 4 x 4 pixel)
      contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
      contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
      contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x  - 2;
      contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x  + 2;
      
      
      contact.pointerInfo.pointerFlags = POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
      InjectTouchInput(1, &contact); // Injecting the touch down on screen
      
      contact.pointerInfo.pointerFlags = POINTER_FLAG_UP;
      InjectTouchInput(1, &contact); // Injecting the touch Up from screen
      

      另一篇文章:Getting Started with Windows Touch Gestures

      【讨论】:

      • 在 Windows 7 上 - AttributeError:未找到函数“InitializeTouchInjection”。也许这个函数调用在win7上不存在?
      【解决方案3】:

      创建虚拟 Hid 驱动程序似乎是唯一的方法。

      【讨论】:

        【解决方案4】:

        我自己还没有机会尝试,但根据this article 的说法,Windows 8 Dev Preview 中包含的模拟器允许使用鼠标模拟多点触控缩放和旋转手势。

        您可以在此 BUILD 会议会话的大约 35:40 看到此演示:Tools for building Metro style apps

        【讨论】:

        • 我不想使用模拟器我想直接发送触摸事件给操作系统。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-03-05
        • 2012-04-09
        相关资源
        最近更新 更多