Simulating Touch Input in Windows 8 Using Touch Injection API

Table of Contents

Introduction

Windows 8 comes with multiple input types. Windows 8 devices often have multi-touch screens that enable users to use multiple fingers simultaneously to produce different input interactions such as tapping, dragging, or pinching. The Windows
Runtime has a number of different mechanisms for handling touch input, enabling us to create an immersive experience that we can explore with confidence. This Article covers the basics of using touch input (simulating the touch input via VC++ code) in
Windows Developer Preview using C++ by Touch Injection API. For other (consumer preview and release preview) you may need to
enable UI access permission( check references for this).

Using this article will help all to create application that will help in simulating the Touch inputs like Tap, Drag, Rotate etc. , Consider an application that will convert users mouse event to touch event for those users who does not have Touch screen monitor.
Also this will be of great use for Automating any touch based application on windows 8.

Prerequisites

This Article assumes that Reader is updated with these basics requirements

Understandings of Microsoft Visual C++

Using the code on Windows developer preview

Using Visual studio 11 developer preview to compile the code

Reader has knowledge of Touch Injection API structure and flags. If not please refer
doc1,
doc2 or read the references

Touch Interactions

Touch Interactions are a high-level way of interpreting touch input data into a set of common motions such as tapping, dragging, and pinching. Lets Understand some of the common interactions used in Windows Developer Preview which are as follow:

Interaction

Input Type

Description

Tap

Single Input

One finger touches the screen and lifts up.

Hold

Single Input

One finger touches the screen and stays in place.

Drag

Single Input

One or more fingers touch the screen and move in the same direction.

Pinch/Pan

Multiple Input

Two or more fingers touch the screen and move closer together (Zoom -out) or farther apart (Zoom-in).

Rotate

Multiple Input

Two or more fingers touch the screen and move in a clockwise or counter-clockwise arc.

Cross-slide

Multiple Input

Two finger touches an object and drags it at a right angle to the panning direction.

For windows 8 developer preview this will work as it is but for other windows 8 versions you may need to change UI access permission. Lets see how to simulate these Touch interaction via VC++ code using Touch Injection API.

Simulating Tap

By Tap we mean that it has simply touched any portion of screen. In this use case actor takes two action

Touch down on screen co-ordinate input

Lifts Up Touch input

To get above done you need to following 5 steps.

1] Create a Win32 application using visual studio 2011 developer preview. ( with No CLR support and without ATL support)

Simulating Cross-Slide

By Cross-Slide we mean two contact points moves in any one direction with respect to screen, simulating a situation where use puts both his figure to touch any picture and drag it to any direction using both
of his fingure. In this use case actor has three action.

Injecting two Touch down contact point simultaneously on the screen.

Drag both points to any 1 direction.

Lifts up both the touch contact points.

To implement the above scenario repeat all the steps in shown in Pinch Simulation
, but change the step 3 to the code shown below