Why win32api can not scan keys after filedialog was used in Python 3? Why win32api can not scan keys after filedialog was used in Python 3? tkinter tkinter

Why win32api can not scan keys after filedialog was used in Python 3?


The results of GetKeyState depends on the current message queue,

it reports the state of the keyboard based on the messages you have retrieved from your input queue.

(From The old new thing)

If the current message queue has been changed, The key message will be sent to the new queue, and the message in the old one is Invalid.(unless you back to the old queue).

GetAsyncKeyState return the status reflect the interrupt-level state associated with the hardware.And you also need to ignore the least significant bit:

base_x = win32api.GetKeyState(key)&0x8000