""" bEnable:
True: Disable mouse & keyboard
False: Enable mouse & keyboard
"""
import pyHook
def uDisable(event): return False
def uEnable(event): return True
hm = pyHook.HookManager()
if bEnable == True:
hm.MouseAll = hm.KeyAll = uDisable
else:
hm.MouseAll = hm.KeyAll = uEnable
hm.HookMouse()
hm.HookKeyboard()
这里用Python的 pyHook 模块,写了个类似AutoIt中的BlockInput函数。
pyHook是个扩展模块,需要另外下载的,具体用法可以参考 pyHook 模块中的 example.py 。