在 Python 中禁用或锁定鼠标和键盘? [英] disable or lock mouse and keyboard in Python?
本文介绍了在 Python 中禁用或锁定鼠标和键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法使用python禁用或锁定鼠标和键盘?我想冻结鼠标并禁用键盘.
Is there a way of disabling or locking mouse and keyboard using python? I want to freeze the mouse and disable the keyboard.
推荐答案
我还没有测试过(实际上我已经测试过鼠标部分,它的工作很烦人)但是使用 pyhook 会做你想做的:
I haven't tested (actually I've tested the mouse part, and it annoyingly works) but something like this using pyhook would do what you want:
import pythoncom, pyHook
def uMad(event):
return False
hm = pyHook.HookManager()
hm.MouseAll = uMad
hm.KeyAll = uMad
hm.HookMouse()
hm.HookKeyboard()
pythoncom.PumpMessages()
这篇关于在 Python 中禁用或锁定鼠标和键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文