C#BlockInput,鼠标和键盘 [英] C# BlockInput, mouse and keyboard

查看:306
本文介绍了C#BlockInput,鼠标和键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我在学校项目中工作,我需要禁用我的鼠标和键盘,我读过很多博客但是我找到了相同的解决方案,问题是它不起作用



Hi everyone!!

I am working for in a school project and I need to put in disable my mouse and keyboard, I read a lot of blogs but I found the same solution, the problem is that it doesn''t work

//declare this
using System.Runtime.InteropServices;

[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern void BlockInput([In, MarshalAs(UnmanagedType.Bool)]bool fBlockIt);


private void button1_Click(object sender, EventArgs e)
{
    BlockInput(true);

}





我有一台Windows 7笔记本电脑,一台微软视觉工作室2008



谢谢!!!



I have a windows 7 laptop, a Microsoft visual studio 2008

Thanks!!!

推荐答案

试试这个有答案如何在C#中阻止键盘和鼠标输入? [ ^ ]



我推荐这篇文章 - 用C#处理全局鼠标和键盘挂钩 [ ^ ]
Try this which has answer How can I block keyboard and mouse input in C#?[^]

I recommend this article for you - Processing Global Mouse and Keyboard Hooks in C#[^]


[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);







这可以用于赢32但不工作赢得64 ....任何人都可以帮助同样赢得64位...



提前感谢




this can work for win 32 but not working win 64 .... can any one help to to do the same for win 64 bit...

thanks in advance


这篇关于C#BlockInput,鼠标和键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆