[英]In windows using python how do I check if the middle mouse button is held down?
I know how to check if the left mouse button and if the right mouse button are 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}')
But what is the code for checking if the middle mouse button is held down?但是检查鼠标中键是否被按下的代码是什么? I'd like to do it with the ctypes function:
windll.user32.GetKeyState()
我想用 ctypes function 来做:
windll.user32.GetKeyState()
I've googled it and I can't find anything.我已经用谷歌搜索了,但找不到任何东西。
middle_click = windll.user32.GetKeyState(0x04)
You can check the reference here.您可以在此处查看参考资料。 https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.