如何消除 C# WPF 中鼠标移动的像素噪声
当我没有远程控制时,我遇到了鼠标停止的时刻,但现在我远程控制了光标。现在,我无法获得鼠标停止的时刻,因为它永远不会完全停止,它总是在移动一点点。我的想法是添加一些偏移像素。比如5px,即使鼠标移动了5px左右,也会说鼠标停止了。
这是捕获鼠标停止时刻的代码的一部分。它会触发一个计时器。我没有把计时器代码放在这里。
mouse = new MouseKeyboardActivityMonitor.MouseHookListener(new GlobalHooker());
mouse.MouseMove += (sd, args) =>
{
movingCount = 0;
mouseLeft = args.X; //set the window.left to mouseLeft before showing it
mouseTop = args.Y; //set the window.top to mouseTop before showing it
};
mouse.Enabled = true;
对于获得鼠标不停移动但移动 5 px 噪音的时刻,您有什么想法?
I was getting the moment when mouse stops while I was not controlling the remotely, but now I control the cursor remotely. Right now, I can not get the moment when mouse stops, because It never exactly stops, it is always moving a little bit. My idea is to add some offset pixels. For example 5 px, even the mouse moves around 5 px, It will say that mouse stopped.
This was the some part of the code to capture the moment mouse stops. It triggers a timer. I didn't put here the timer code.
mouse = new MouseKeyboardActivityMonitor.MouseHookListener(new GlobalHooker());
mouse.MouseMove += (sd, args) =>
{
movingCount = 0;
mouseLeft = args.X; //set the window.left to mouseLeft before showing it
mouseTop = args.Y; //set the window.top to mouseTop before showing it
};
mouse.Enabled = true;
What are your ideas about getting the moment when mouse doesn't stop but moving around 5 px noise?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据评论中的要求,这里有一个示例:
您可以使用系统参数MinimumVerticalDragDistance和MinimumHorizontalDragDistance。
请参阅此处: http://msdn.microsoft.com/ en-us/library/system.windows.systemparameters.minimumverticaldragdistance.aspx
它们最初用作 DragDrop 操作中的阈值,以检测拖动是否成功是否真正开始,或者如果用户仅单击并将鼠标指针移动很小的距离。
使用方法如下:
HTH
As requested in the comments here's an example:
You can use the System Parameters MinimumVerticalDragDistance and MinimumHorizontalDragDistance.
See here: http://msdn.microsoft.com/en-us/library/system.windows.systemparameters.minimumverticaldragdistance.aspx
They are originally used as a threshold in DragDrop Operations to detect if the drag is really beginning or if the user was only clicking and moving the mouse pointer a very small distance.
Here's how it could be used:
HTH