2011-09-21 67 views
11

有沒有一種方法來模擬Windows 8(最好是在Windows 7中)的觸摸事件。
我知道有一個名爲Multi touch vista的項目,但我覺得它有點矯枉過正,我從來沒有在多個屏幕上正常工作。
我想要做的事很簡單,我想開始一個應用程序,可以發送觸摸事件到Windows,不需要多個鼠標或任何類似的東西。
它可以做到或者我需要一個(MMV)驅動程序來做到這一點?有沒有辦法模擬Windows 8中的觸摸事件?

感謝
/吉米

回答

5

我正在尋找類似的東西,發現這篇文章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

4

我還沒有機會嘗試它自己,但根據this article,包含在Windows 8開發預覽模擬器允許使用模擬多點觸摸縮放和旋轉手勢一個鼠標。

你可以看到這個這個BUILD大會會議的大約35:40的演示:Tools for building Metro style apps

+1

我不想用我想送觸摸事件模擬器直接到操作系統。 –

0

創建虛擬HID驅動器似乎是唯一的出路。

相關問題