Categories

Tuesday, December 17, 2024
#919814419350 therichposts@gmail.com
Python

How to use mouse button 4-5 (gamer) with python?

how to use mouse button 4-5 (gamer) with python?

Hello friends, welcome back to my blog. Today this blog post I will tell you, How to use mouse button 4-5 (gamer) with python?

Guy’s if you are new in Python then please check below link for more Python tutorials:

  1. Python Tutorials

Guy’s here is the working code snippet and please use it carefully:

1. Guys very first we need to import library pynput inside our python project.

2. Guys here is the code for button press:

import time
from pynput.mouse import Button, Controller

#press boton
mouse=Controller()
mouse.click(Button.x1)
time.sleep(1)
mouse.click(Button.x2)
time.sleep(1)

3. Guys here is the code for button listening:

import time
from pynput import mouse

def on_click(x, y, button, pressed):
    if pressed == True and str(button)=="Button.x1":
        print("pressed x1")
    return

listener = mouse.Listener(
    on_click=on_click)
listener.start()

while True:
    time.sleep(0.2)

This is it guy’s. Guy’s if you have any kind of query then please comment below. Guy’s I will come with more demos soon.

I will appreciate that if you will tell your views for this post. Nothing matters if your views will be good or bad because with your views, I will make my next posts more good and helpful.

Jassa

Thanks

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.