如何检测攻(触摸输入)在全球范围,而不是鼠标点击? [英] How to detect tapping (touch input) globally instead of mouse clicking?

查看:1916
本文介绍了如何检测攻(触摸输入)在全球范围,而不是鼠标点击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打一个应用程序,展示自己,当用户触摸他的屏幕。它不应该为点击工作。我在Windows 7/8抬头为触摸hanlders。但是,我看到每个触摸窗口必须与RegisterTouchWindow注册

I want to make an app that shows itself when the user touches his screen. It shouldn't work for click. I looked up for the touch hanlders in Windows 7/8. But I saw that every touch window must be registered with RegisterTouchWindow

TL; DR

有没有办法让我的窗外触摸点位置(全球)?

Is there a way to get the touch points position outside my window (globally)?

推荐答案

RegisterTouchWindow没有必要为Win 8应用服务了。

RegisterTouchWindow is not necessary for Win 8 apps any more.

据我知,有几种方式来实现自己的目的,有一些限制。

As far as I known, there are several ways to achieve your purpose with some limitations.

  1. <一个href="http://www.$c$cproject.com/Articles/381673/Using-the-RawInput-API-to-Process-MultiTouch-Digit">This文章在这里既赢得7和工程; 8.但厂商ID和所述触摸屏的产品ID是必需的。有一种可能性,你的应用程序将无法正常使用一些触摸设备正常工作。

  1. This article here works on both Win 7 & 8. But the vendor ID and the product ID of the touchscreen is required. There is a possibility that your application won't work properly with some touch device.

使用<一个href="http://msdn.microsoft.com/library/windows/desktop/hh454911%28v=vs.85%29.aspx">RegisterPointerInputTarget在Win 8,从我的调试,Windows 8的触摸机制,有其独特的特点。之间的触摸向下和触摸起来,所有的触摸事件将被发送到其接收第一触摸事件,无论窗口被最小化,或覆盖在其后期另一个窗口或设置WS_EX_TRANSPARENT属性窗口。之间的一个pressing和释放触摸事件只能共享到另一个窗口,如果第一个被破坏。使用该API,所有的触摸事件将被发送到已注册的窗口。其他窗口不能接收触摸事件更多,直到<一href="http://msdn.microsoft.com/en-us/library/windows/desktop/hh454915%28v=vs.85%29.aspx">UnregisterPointerInputTarget通过使用<一种称为由注册窗口,或触摸输入被注入到系统中href="http://msdn.microsoft.com/en-us/library/windows/desktop/hh802881%28v=vs.85%29.aspx">InjectTouchInput. 输入您的注册输入目标注入将不会被窃听。请注意,用户界面​​的访问权限需要使用此API。样本可以在这里 被发现。

Use RegisterPointerInputTarget on Win 8. From my debugging, the windows 8 touch mechanism has its unique characteristics. Between a touch down and a touch up, all the touch events will be sent to the window which receives the first touch event, no matter the window is minimized or covered by another window or set WS_EX_TRANSPARENT attribute in its later period. The touch events between one pressing and releasing can only be shared to another window if the first one is destroyed. Using this API, all the touch events will be sent to the registered window. Other windows cannot receive touch events any more until UnregisterPointerInputTarget is called by the registered window, or the touch input is injected back into the system by using InjectTouchInput. "Input injected by the registered input target will not be intercepted." Please notice that UI Access privilege is required for using this API. A sample can be found in here.

的Windows挂钩。对于在Win 7/8桌面应用,触摸事件可以容易地通过使用调用SetWindowsHookEx钩住,提供WH_CALLWNDPROC或WH_GETMESSAGE。对于在Win 8应用程序的地铁,只有第一个指针的事件可以在窗口的消息循环进行检测。虽然指针的事件可以通过点击或自来水,<一个可以发生href="http://msdn.microsoft.com/library/windows/desktop/hh454892%28v=vs.85%29.aspx">GetPointerType可以告诉你,如果它是一个触摸指针或鼠标指针。样品用钩子可以在这里找到。

Windows hook. For desktop app on Win 7/8, touch events can be easily hooked by using SetWindowsHookEx with WH_CALLWNDPROC or WH_GETMESSAGE. For metro app on Win 8, only the first pointer event can be detected in the message loop of the window. Although a pointer event can be occurred by either a click or a tap, GetPointerType can tell you if its a touch pointer or a mouse pointer. Samples for using hooks can be found at here.

一个code段处理指针事件:

A code snippet for handling pointer events:

switch(Msg)  
{  
...  
case WM_POINTERENTER:  
case WM_NCPOINTERDOWN:  
case WM_NCPOINTERUP:  
case WM_NCPOINTERUPDATE:  
case WM_POINTERACTIVATE:  
case WM_POINTERCAPTURECHANGED:  
case WM_POINTERDOWN:  
case WM_POINTERLEAVE:  
case WM_POINTERUP:  
case WM_POINTERUPDATE:  
    {  
        UINT32 pointerId = GET_POINTERID_WPARAM(wParam);  
        POINTER_INPUT_TYPE pointerType;  

        if (GetPointerType(pointerId, &pointerType))  
        {
            if (pointerType == PT_TOUCH)   
            {  
                ...  
            }  
        }  
    }  
    break;  
...

这篇关于如何检测攻(触摸输入)在全球范围,而不是鼠标点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆