如何从windows中抑制全局鼠标单击事件?

我正在开发一个基于Windows的应用程序,我希望每当我的应用程序启动时它应该禁用我的应用程序窗口窗体之外的鼠标单击事件。

任何人都可以告诉我,我怎么能实现这一目标?

提前致谢。

编辑:
在表单中捕获鼠标单击事件并禁止单击操作很容易,因为我们只使用它:

protected override void WndProc(ref Message m) { if (m.Msg == (int)MouseMessages.WM_LBUTTONDOWN || m.Msg == (int)MouseMessages.WM_LBUTTONUP) MessageBox.Show("Click event caught!"); //return; --for suppress the click event action. else base.WndProc(ref m); } 

但如何在我的应用程序表单之外捕获鼠标单击事件?

这样就可以完成。 它使用win API函数BlockInput 。

注意:CTRL + ALT + DELETE再次启用输入。 但其他鼠标和键盘输入被阻止。

 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Runtime.InteropServices; namespace WindowsFormsApplication1 { public partial class Form1 : Form { [return: MarshalAs(UnmanagedType.Bool)] [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)] public static extern void BlockInput([In, MarshalAs(UnmanagedType.Bool)]bool fBlockIt); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.Show(); //Blocks the input BlockInput(true); System.Threading.Thread.Sleep(5000); //Unblocks the input BlockInput(false); } } }