0

(For background, see Composing a WM_TOUCH message for SendMessage(), Kinect as a multi-touch device which asks basically the same question as mine but whose accepted answer doesn't actually answer the question. The tricky bit isn't filling in TOUCHINPUT structures but making a valid touch input handle.)

I would like to simulate the presence of a multi-touch input device in a nasty hackish way, which in outline goes like this:

while (true) {
  choose locations etc. for simulated touches;
  PostMessage(GetForegroundWindow(), WM_TOUCH, nTouches, ...);
}

The tricky bit is what goes in that space labelled "...". The MSDN documentation, which is unsurprisingly written from the point of view of a consumer of WM_TOUCH messages, says that the lParam for the WM_TOUCH message is

a touch input handle that can be used in a call to GetTouchInputInfo to retrieve detailed information about the touch points associated with this message.

I can easily enough make, e.g., an array of TOUCHINPUT structures, which is what GetTouchInputInfo gives you. But that seems to be an entirely different thing from a "touch input handle". (E.g., a touch input handle needs to be the right sort of thing to pass to CloseTouchInputHandle, which allegedly PostMessage or SendMessage will do.)

Is it possible (officially or unofficially!) for user code to generate a valid touch input handle that it can pass to PostMessage? If so, how?

Community
  • 1
  • 1
Gareth McCaughan
  • 19,888
  • 1
  • 41
  • 62
  • Saying "no way" is hard to do. Hmm, no, no way. You'd need the equivalent of SendInput(), it doesn't exist for touch. – Hans Passant Feb 27 '13 at 18:18
  • That was my guess too! I was just hoping that there might be some evil undocumented hacky way to do it. (E.g., maybe a touch input handle is really, under the hood, just a pointer to a bunch of TOUCHINPUT structures -- though that would require some highly improbable magic since pointers can't meaningfully be passed between processes.) Does your "no way" mean "no legal way" or "definitely no way, including nasty hacks"? – Gareth McCaughan Feb 28 '13 at 09:27

1 Answers1

0

Windows 8 has a TouchInjection API for faking touches in the Desktop Environment.

http://social.technet.microsoft.com/wiki/contents/articles/6460.simulating-touch-input-in-windows-8-using-touch-injection-api.aspx

Hinchy
  • 143
  • 9