[英]Disable Keyboard/Mouse in c#
I need to disable keyboard/mouse or both for specific time period at system level in my application. 我需要在我的应用程序中在系统级别的特定时间段内禁用键盘/鼠标或两者。
I have following to do that 我有以下这样做
public partial class NativeMethods
{
/// Return Type: BOOL->int
///fBlockIt: BOOL->int
[System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint = "BlockInput")]
[return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
public static extern bool BlockInput([System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fBlockIt);
}
By this code the task is complete but when user click on CTRL+ALT+DELETE keyboard and mouse are working again. 通过此代码,任务完成,但当用户单击CTRL + ALT + DELETE键盘和鼠标再次工作。 Can any body tell me how to stop this?
任何人都可以告诉我如何阻止这种情况吗?
Windows level shortcuts and macros ( CTRL + ALT + DEL , WINDOWS + L , ALT + TAB , CTRL + SHIFT + ESC ) are messages that are not processed by your application, they're processed by windows runtime. Windows级别的快捷方式和宏( CTRL + ALT + DEL , WINDOWS + L , ALT + TAB , CTRL + SHIFT + ESC )是您的应用程序未处理的消息,它们由Windows运行时处理。 You can check this by creating a simple form and overriding the
WndProc
method and checking those messages. 您可以通过创建一个简单的表单并覆盖
WndProc
方法并检查这些消息来检查这一点。
Anyway here are some tutorials on how to hook the keyboard: 无论如何这里有一些关于如何挂钩键盘的教程:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.