Capture touch input on the screen in windows device(在 Windows 设备的屏幕上捕获触摸输入)
问题描述
有没有办法在 windows 设备的屏幕上(应用程序框架外)捕获触摸输入?
Is there any way to capture touch input on the screen (outside application frame) in windows device?
我正在开发 WPF 应用程序,如果触摸输入仅出现在应用程序框架内,我可以检索它.另外,有没有办法在应用最小化的情况下注册触摸输入?
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?
推荐答案
WPF 框架没有内置方法可以让您在应用程序之外侦听输入.如果你想这样做,你必须进入 p/invoke 领域.
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.
具体来说,您需要创建一个 hook一个>.您需要查看 SetWindowsHookEx 方法和 WH_MOUSE 或 WH_MOUSE_LL 钩子.
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:
hookProc 回调的 lParam 参数是一个指向 MSLLHOOKSTRUCT.它包含一个 very 记录不佳的 dwExtraInfo 变量,它告诉您它是否是通过触摸生成的.
The
lParamargument of yourhookProccallback is a pointer to anMSLLHOOKSTRUCT. It contains a very poorly documenteddwExtraInfovariable, which tells you whether it was generated from a touch.
如果 0xFF515700 中的所有位都在 dwExtraInfo 中设置,则调用回调以响应触摸.
If all of the bits in 0xFF515700 are set in dwExtraInfo, then the callback was invoked in response to a touch.
这篇关于在 Windows 设备的屏幕上捕获触摸输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Windows 设备的屏幕上捕获触摸输入
基础教程推荐
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- WPF 模态进度窗口 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
