如何在机器上禁用鼠标和键盘硬件,但可以使用programmeticaly [英] How do I disable mouse and keyboard hardware on machine but it can be used programmeticaly

查看:141
本文介绍了如何在机器上禁用鼠标和键盘硬件,但可以使用programmeticaly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想编写一段代码,在特定时间段内禁用鼠标和键盘。它应该禁止通过硬件使用鼠标或键盘。我们应该能够以编程方式使用鼠标和键盘。这是因为我们想要实现自动化,但要确保用户不要打扰自动化。



我尝试了什么:



我已经搜索了很多来禁用C#中的程序禁用硬件,但它并没有帮助我。

Hi,

I want to write a code which will disable Mouse and Keyboard for a particular period of time. It should disable use of mouse or keyboard through hardware. We should be able to use mouse and keyboard in programmatic way. This is because we want to do automation but make sure tat user do not disturb automation.

What I have tried:

I have searched a lot to disable programetically disable hardware in C# but it is not helping me out.

推荐答案

你可以为键盘和鼠标事件安装全局钩子。在事件处理程序中,您可以吃掉消息或让它们在特定情况下传递。



一些有用的链接:

使用C#处理全局鼠标和键盘挂钩 [ ^ ]

C&#35中的应用程序和全球鼠标和键盘挂钩.Net Libary; - 主页 [ ^ ](来自与上述CP相同的作者)文章)

低C#中的级别键盘钩子Stephen Toub [ ^ ]

C#中的低级鼠标钩子Stephen Toub [ ^ ]
You can install global hooks for keyboard and mouse events. In the event handlers you can "eat" messages or let them pass on specific circumstances.

Some useful links:
Processing Global Mouse and Keyboard Hooks in C#[^]
Application and Global Mouse and Keyboard Hooks .Net Libary in C# - Home[^] (from the same author as the above CP article)
Low-Level Keyboard Hook in C# | Stephen Toub[^]
Low-Level Mouse Hook in C# | Stephen Toub[^]


这篇关于如何在机器上禁用鼠标和键盘硬件,但可以使用programmeticaly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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