Bloqueo de mouse y teclado [英] Bloqueo de mouse y teclado

查看:91
本文介绍了Bloqueo de mouse y teclado的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Buendía,necesito bloquear el mouse y teclado del PC cuando ejecute una funcion en C#。 alguien me puede ayudar con esto?



翻译:您好,我需要在C#中执行函数时阻止PC的鼠标和键盘。有人可以帮我这个吗?



我尝试过:



intente con el Blockinput(); pero somo se bloquean los dispositivos con la aplicacion



翻译:尝试使用Blockinput();但是(somo)设备被应用程序阻止

Buen día, necesito bloquear el mouse y teclado del PC cuando ejecute una funcion en C#. alguien me puede ayudar con esto ?

Translation: Hello, I need to block the mouse and keyboard of the PC while executing a function in C#. Can someone help me with this?

What I have tried:

intente con el Blockinput(); pero somo se bloquean los dispositivos con la aplicacion

Translation: Try with the Blockinput (); but (somo) the devices are blocked by the application

推荐答案

阻止光标的一般方法是将其设置为等待



A general way of blocking the cursor is to set it to wait

Cursor = Cursors.WaitCursor;





我' d倾向于同意人们评论,你永远不会得到称赞人们的键盘,毕竟,他们可能想要alt-tab来改变焦点。防止这种情况将被定性为病毒!



但是假设您只是在自己的应用程序中,它与您正在使用的应用程序类型相关(?)



基本上你可以通过收听按键事件来实现你的目标





I'd tend to agree with the people commenting, that you'll NEVER get compliments for taking peoples keyboard, after all, they may be wanting to alt-tab to change focus for instance. Preventing this would be characterized as a virus!

But suppose you only mean in your own application, it becomes relevant what type of application you are using(?)

Essentially you can achieve what you will by listening in on key-down event

private void MyKeyDownEventHandler(object sender, KeyEventArgs e)
{
        e.SuppressKeyPress = true;
}



然后只需在键盘工作时删除事件监听器。


Then simply remove your event listener when you want the keyboard to work.


这篇关于Bloqueo de mouse y teclado的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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