简体   繁体   English

用户全局单击/释放鼠标按钮时的事件

[英]Event for when user clicks/releases mouse button globally

Hey guys i was wondering if there was a way to detect if the user has clicked the mouse down and also if they have released it? 大家好,我想知道是否有一种方法可以检测用户是否单击了鼠标,以及是否释放了鼠标? Currently I am trying to use: 目前,我正在尝试使用:

   private void Form1_MouseDown(object sender, MouseEventArgs e)
    {
        start_x = e.X;
        start_y = e.Y;

        MessageBox.Show(start_x.ToString() + " : " + start_y.ToString());

    }

But that only works when clicking inside the form. 但这仅在单击表单内部时有效。 Any help would be appreciated. 任何帮助,将不胜感激。

Try using this library . 尝试使用此

It allows you to easily register global keyboard & mouse hooks and handle them like any other .NET mouse / keyboard event. 它使您可以轻松注册全局键盘和鼠标挂钩,并像处理其他任何.NET鼠标/键盘事件一样处理它们。

Also CodeProject has a ton of reading material on this 另外CodeProject对此也有大量 阅读 材料

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM