Capture touch input on the screen in windows device

≯℡__Kan透↙ 提交于 2021-02-05 11:14:09

问题


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 your hookProc callback is a pointer to an MSLLHOOKSTRUCT. It contains a very poorly documented dwExtraInfo variable, which tells you whether it was generated from a touch.

If all of the bits in 0xFF515700 are set in dwExtraInfo, then the callback was invoked in response to a touch.



来源:https://stackoverflow.com/questions/62180923/capture-touch-input-on-the-screen-in-windows-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!