On my Windows 11 system, this piece of code does not work correctly. The code is not able to detect every click and display the corresponding message in the console. In this case, the mouse.UP event works correctly, but it does not suit me at all. Try checking it for yourself and maybe you will notice the problem too.
def main():
mouse.on_button(lambda: print("Mouse down"), buttons=mouse.LEFT, types=mouse.DOWN)
try:
while True:
time.sleep(0.01)
except KeyboardInterrupt:
pass
finally:
mouse.unhook_all()
if __name__ == "__main__":
main()