Python's method of locking keystrokes based on the Windows platform

  • 2020-04-02 14:38:28
  • OfStack

This article illustrates an example of how python locks keystrokes based on the Windows platform. Share with you for your reference. Specific analysis is as follows:

There is no BlockInput in pywin32. VC++, found this method can be.

This code can block mouse and keyboard input under the Windows platform, as shown below:


# coding: UTF-8
import time
from ctypes import *
user32 = windll.LoadLibrary('user32.dll')
user32.BlockInput(True);
time.sleep(10);
user32.BlockInput(False);

I hope this article has helped you with your Python programming.


Related articles: