问题描述
有没有办法在 Windows 8 中模拟触摸事件(最好是在 Windows 7 中).
我知道有一个名为 Multi touch vista 的项目,但我觉得它有点矫枉过正,而且我从来没有让它在多个屏幕上正常工作.
我想做的很简单,我想启动一个应用程序,它可以向 Windows 发送触摸事件,而不需要多个鼠标或类似的东西.
可以完成还是我需要(MMV)驱动程序才能做到这一点?
Is there a way to simulate touch events in Windows 8 (and preferably in windows 7).
I know there is a project called Multi touch vista but I feel its a bit overkill and I never got it working correctly with multiple screens.
What I want to do is very simple, I want to start an app that can send touch events to Windows no need for multiple mice or any thing like that.
Can it be done or do I need a (MMV) driver to do that?
谢谢
/吉米
推荐答案
我正在寻找类似的东西,发现这篇文章 使用触控注入 API 在 Windows 开发者预览版中模拟触控输入示例代码 (C++) 可能会回答您的问题.但是,这似乎只适用于 Windows 8(而不是 Windows 7).
I was looking for something similar and found this article Simulating Touch Input in Windows Developer preview using Touch Injection API and sample code (C++) may answer your question. However, this seems to work only on Windows 8 (not Windows 7).
它模拟点击、按住、拖动、捏/平移、旋转和横向滑动.
It simulates Tap, Hold, Drag, Pinch/Pan, Rotate and Cross-Slide.
这是触摸(Tap)代码:
Here is the touch (Tap) code:
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 8 中模拟触摸事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!