有没有办法在Windows8(最好是Windows7)中模拟触摸事件?
我知道有一个叫多点触控视景的项目,但我觉得它有点过头了,我从来没有让它在多个屏幕上正常工作。
我想做的很简单,我想启动一个应用程序,可以发送触摸事件到Windows,而不需要多个鼠标或任何类似的东西。
它可以做到吗?或者我需要一个(MMV)驱动程序来做到这一点吗?
谢谢
/Jimmy
发布于 2012-04-10 10:32:17
我正在寻找类似的东西,发现这篇文章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另一篇文章:Getting Started with Windows Touch Gestures
发布于 2011-09-22 06:50:41
我还没有机会亲自尝试,但据this article称,Windows8开发人员预览版附带的模拟器允许使用鼠标模拟多点触摸缩放和旋转手势。
您可以在大约35:40的构建会议上看到这一点的演示:Tools for building Metro style apps
发布于 2012-04-16 07:11:06
该解决方案指向InjectTouchInput的C++示例代码,该示例代码打包在Windows8的User32.dll中,C#解决方案可在此处找到:
https://stackoverflow.com/questions/7507568
复制相似问题