Relative Content

Tag Archive for pythonpython-3.xctypes

Inconsistent result of ctypes – GetAsyncKeyState function

import ctypes def mouse_released() -> bool: mouse_state = ctypes.windll.user32.GetAsyncKeyState(0x01) if mouse_state: while ctypes.windll.user32.GetAsyncKeyState(0x01): continue # is pressing else: print(‘released’) return mouse_state != 0 # released return False while True: mouse_released() This program tells if the left mouse button was released. Problem: in general it works correctly. But sometimes at the very beginning it prints “released”, […]