问题
Is there any way to capture touch input on the screen (outside application frame) in windows device?
I'm working on a WPF application and can retrieve the touch input if it only occurs within the application frame. Also, is there a way to register the touch input even when the application is minimized?
回答1:
There's no built-in method of the WPF framework that lets you listen for input outside of the application. If you want to do that, you'll have to get into p/invoke territory.
Specifically you'll need to create a hook. You'll want to look at the SetWindowsHookEx method and either the WH_MOUSE or WH_MOUSE_LL hooks.
Since you're dealing with touch inputs, this answer might have some useful information for you:
The
lParam
argument of yourhookProc
callback is a pointer to an MSLLHOOKSTRUCT. It contains a very poorly documenteddwExtraInfo
variable, which tells you whether it was generated from a touch.If all of the bits in
0xFF515700
are set indwExtraInfo
, then the callback was invoked in response to a touch.
来源:https://stackoverflow.com/questions/62180923/capture-touch-input-on-the-screen-in-windows-device