Disable mouse promotion

不想你离开。 提交于 2019-12-01 07:41:11

问题


Is there any way to disable mouse promotion from code, that is preventing windows to interpret touch events as mouse events?

I capture touch events in my WPF application, and I don't want these interactions to effect mouse pointer visibility and position.

There is a TouchFrameEventArgs.SuspendMousePromotionUntilTouchUp Method that seems to be doing exactly that. Unfortunately it's available only for Silverlight and Windows Phone.

In addition there are some system settings you can use to disable double click and right click promotion, but nothing to disable mouse promotion as a whole.

A Windows 8 specific solution or a low level solution would also help.


回答1:


public static class PreventTouchToMousePromotion
{

    public static void Register(FrameworkElement root)
    {
        root.PreviewMouseDown += Evaluate;
        root.PreviewMouseMove += Evaluate;
        root.PreviewMouseUp += Evaluate;
    }

    private static void Evaluate(object sender, MouseEventArgs e)
    {
        if (e.StylusDevice != null)
        {
            e.Handled = true;
        }
    }
}

Excample Usage:

public MainWindow()
    {
        InitializeComponent();
        PreventTouchToMousePromotion.Register(this);
    }

or take a look at this post

http://social.msdn.microsoft.com/Forums/vstudio/en-US/9b05e550-19c0-46a2-b19c-40f40c8bf0ec/prevent-a-wpf-application-to-interpret-touch-events-as-mouse-events?forum=wpf#9965f159-04a4-41ed-b199-30394991f120




回答2:


There doesn't seem to be any such option (at least up to Windows 8.1 and .NET 4.5).

The only way to disable mouse promotion is to disable finger input completely, either from within the system control panel (open control panel, open "Pen and Touch", select "Touch" tab, disbale "Use your finger as an input device") or via Registry (HKLM\Software\Microsoft\Wisp\Touch, TouchGate = 0 =disable touch)

Then you can still process touch input using one of the following (nasty) alternatives:

  • Write your own WinUSB driver for your touch device
  • Get raw touch input data using the RawInput API
  • Find a 3rd party USB driver for your device (e.g. UPDD TouchBase)

Finally, you can inject the collected touch data into your application using custom routed events or using touch injection.

In any case you will, of course, loose touch support for any other application on your system, so this solution will in general not be too helpfull to you.



来源:https://stackoverflow.com/questions/18234024/disable-mouse-promotion

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