在 windows 中使用 python 如何检查鼠标中键是否被按住?

In windows using python how do I check if the middle mouse button is held down?

我知道如何检查鼠标左键和鼠标右键是否被按住:

from ctypes import windll

left_click = windll.user32.GetKeyState(0x01)
right_click = windll.user32.GetKeyState(0x02)

print(f'left_click: {left_click}')
print(f'right_click: {right_click}')

但是检查鼠标中键是否被按下的代码是什么? 我想用 ctypes 函数来做:windll.user32.GetKeyState()

我用谷歌搜索了它,但找不到任何东西。

middle_click = windll.user32.GetKeyState(0x04)

您可以在此处查看参考资料。 https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes