问题
(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?
回答1:
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
来源:https://stackoverflow.com/questions/15117490/creating-a-wm-touch-message-for-postmessage-in-c-sharp-net