マウスとキーボードのpythonを無効にする権利を言及

請求

無効にキーボードとマウスを実現するのpythonを使用します

考え

情報へのアクセスを通じて、最良の方法は、dllファイルが書き込まれるのctypesを使用することです

from ctypes import *
improt time

print(winll.shell32.IsUserAnAdmin())  #判断是否有管理员权限


user32 = windll.LoadLibrary("C:\\Windows\\System32\\user32.dll")
user32.BlockInput(True)  #该功能需要管理员权限 True  禁用
time.sleep(5)
user32.BlockInput(Flase)  #该功能需要管理员权限 
time.sleep(5)         

右置きます

def requireAdministrator(f):
    def inner(*args, **kwargs):
        if windll.shell32.IsUserAnAdmin():
            f()
        else:
            # Re-run the program with admin rights
            windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 0)
            f()
    return inner

公式ドキュメント

おすすめ

転載: www.cnblogs.com/jokerBi/p/10945449.html