有没有一种方法在Windows 8中模拟触摸事件?

12
有没有一种方法可以在Windows 8(最好是在Windows 7中)模拟触摸事件。
我知道有一个名为Multi touch vista的项目,但我觉得它有些过度,并且我从未能够正确地在多个屏幕上使用它。
我想做的很简单,我想启动一个应用程序,可以向Windows发送触摸事件,不需要多个鼠标或任何类似的东西。
是否可以实现,还是我需要(MMV)驱动程序来完成这个?

谢谢
/Jimmy

4个回答

5
我正在寻找类似的东西,发现了这篇文章“使用Touch Injection API在Windows Developer预览版中模拟触摸输入”示例代码(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

另一篇文章:Windows触摸手势入门


在Windows 7上 - AttributeError: 找不到函数'InitializeTouchInjection'。 也许这个函数调用在win7上不存在? - Berry Tsakala

4

1
我不想使用模拟器,我想直接向操作系统发送触摸事件。 - Jimmy Engtröm

4

0

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接