简体   繁体   中英

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()

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM