有没有办法模拟Windows 8中的触摸事件?
问题描述:
有没有一种方法来模拟Windows 8(最好是在Windows 7中)的触摸事件。
我知道有一个名为Multi touch vista的项目,但我觉得它有点矫枉过正,我从来没有在多个屏幕上正常工作。
我想要做的事很简单,我想开始一个应用程序,可以发送触摸事件到Windows,不需要多个鼠标或任何类似的东西。
它可以做到或者我需要一个(MMV)驱动程序来做到这一点?有没有办法模拟Windows 8中的触摸事件?
感谢
/吉米
答
我正在寻找类似的东西,发现这篇文章Simulating Touch Input in Windows Developer preview using Touch Injection API和sample 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
答
我还没有机会尝试它自己,但根据this article,包含在Windows 8开发预览模拟器允许使用模拟多点触摸缩放和旋转手势一个鼠标。
你可以看到这个这个BUILD大会会议的大约35:40的演示:Tools for building Metro style apps
答
创建虚拟HID驱动器似乎是唯一的出路。
答
继它指向哪个来包装在的User32.dll中为InjectTouchInput C++的示例代码的溶液Windows 8中,C#的解决方案可以在这里找到:
我不想用我想送触摸事件模拟器直接到操作系统。 –