0

Im searching other ways to block mouse and keyboard. Some suggest to use BlockInput(). Can this be done by python? I'm using windows XP

unice
  • 2,655
  • 5
  • 43
  • 78

2 Answers2

3

Such WinAPI functions can be called using ctypes module.

You need to know in which DLL the function is. In this case it's user32.dll (that info is listed on the msdn documentation page you linked).

Then you need to know its params. This one takes one BOOL argument so we can use Python's bool directly.

from ctypes import *

ok = windll.user32.BlockInput(True)

See the explanation of the return value in the docs. The output will be a Python int which is ok in this simple case but you should know that ctypes lets you specifiy the exact argument and return value types if needed.

I've just tried that on Windows 7 box and it works but only if the process is running with elevated privileges (otherwise it just returns 0). Since you're running XP, this might be irrelevant to you.

yak
  • 8,851
  • 2
  • 29
  • 23
0

If you want to achieve the same as in the accepted answer but without Admin rights/elevated priviledges, you can check my answer to a similar question here:

disable or lock mouse and keybord in python?

Robert
  • 1,357
  • 15
  • 26