如何禁用连接有线鼠标和键盘的USB端口? [英] How do I disable usb port where wired mouse and keyboard attached?

查看:182
本文介绍了如何禁用连接有线鼠标和键盘的USB端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的一个项目编写程序,其中我想禁用有线鼠标和有线键盘来限制其输入事件(如鼠标移动,按键事件),而不是我将使用蓝牙鼠标和蓝牙键盘。所以帮我禁用那些。



谢谢



我的尝试:



I am writing program for one of my project in which i want to disable wired mouse and wired keyboard to restrict its input events(like mouse movements , keypress events) , instead of that i will use bluetooth mouse and bluetooth keyboard. so help me to disable those.

Thanks

What I have tried:

I used following code but it blocks all inputs, not only wired devices but also bluetooth HID devices. 

[DllImport("user32.dll")]
        private static extern bool BlockInput(bool block);

        public static void FreezeMouse()
        {
            BlockInput(true);
        }

        public static void ThawMouse()
        {
            BlockInput(false);
        }

推荐答案

嗨!

我想你可以看看这个链接:

硬件帮助程序库 [ ^ ]



它包含启用禁用设备的方法。
Hi !
I think you can give a look to this link :
Hardware Helper Library for C#[^]

It contains a way to enable disable your devices.


这篇关于如何禁用连接有线鼠标和键盘的USB端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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