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

Time:02-16

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.

CodePudding user response:

middle_click = windll.user32.GetKeyState(0x04)

You can check the reference here. https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes

  • Related