Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use side mouse buttons with Pynput?

I am using the Python module Pynput to make a macro that will press one of my side buttons. Does anyone know what the side buttons are called in Pynput? For example:

from pynput.mouse import Button, Controller

mouse = Controller()

mouse.press(Button.SIDEBUTTON)
mouse.release(Button.SIDEBUTTON)

What would go in the SIDEBUTTON part?

like image 867
Kamepoh2 Avatar asked Sep 16 '25 16:09

Kamepoh2


1 Answers

So this question is a bit old and i had the same problem. I figured out how these buttons are called:

its Button.x1 and Button.x2 for Mouse4 and Mouse5.

Hope I could help you. The script I used to find it is right here:

from pynput.mouse import Listener
def on_click(x, y, button, pressed):
    if pressed:
       print(button)
   
# Collect events until released
with Listener(on_click=on_click) as listener:
    listener.join()
like image 120
Laurenz Z Avatar answered Sep 19 '25 06:09

Laurenz Z