动态改变鼠标速度
伙计们,我有一个 C# Winforms 应用程序,表单内有一个面板。我想做的是,每当鼠标指针进入这个面板时,我想将鼠标的移动速度减慢50%。一旦指针移出该面板,我希望鼠标速度恢复正常的 100% 速度。我怎样才能在 C# 中完成这个任务?
Guys, I have a C# Winforms application with a panel inside the form. What I want to do is, whenever the mouse pointer enters this panel, I want to slow the movement speed of the mouse by 50%. Once the pointer moves outside this panel, I want to speed of the mouse to resume normal 100% speed. How can I accomplish this in C#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这篇文章可能会有所帮助
以下是文章中的代码:
This article might help
Here's the code from the article:
由于不太清楚如何使用答案中的代码,我找到了更简洁的解决方案来更改鼠标速度。将此代码添加到要更改速度的类中:
然后使用所需的鼠标速度调用 SystemParametersInfo:
不要忘记添加
using System.Runtime.InteropServices;
致谢。As it was not very clear how to use code from the answers, I found more concise solution for changing Mouse speed. Add this code to class where you want to change the speed:
And then call SystemParametersInfo with required Mouse speed:
Not forget to add
using System.Runtime.InteropServices;
Credits.