Mouse clicks/events
I coded an autoclicker with python that works great on Xorg but on Wayland doesn't. Autocliker detects when its pressed side button on mouse and then start working.
What I need to do for this to work on Wayland:
#!/usr/bin/env python3
import time
import threading
from pynput.mouse import Button, Controller, Listener
delay = 0.04
button_left = Button.left
start_button_left = Button.button9
button_right = Button.right
start_button_right = Button.button8
class ClickMouse(threading.Thread):
def __init__(self, delay, button):
super(ClickMouse, self).__init__()
self.delay = delay
self.button = button
self.running = False
self.program_running = True
def start_clicking(self):
self.running = True
def stop_clicking(self):
self.running = False
def exit(self):
self.stop_clicking()
self.program_running = False
def run(self):
while self.program_running:
while self.running:
mouse.click(self.button)
time.sleep(self.delay)
time.sleep(0.1)
mouse = Controller()
left_thread = ClickMouse(delay, button_left)
left_thread.start()
right_thread = ClickMouse(delay, button_right)
right_thread.start()
def on_click(x, y, button, pressed):
print(x, y, button, pressed)
if button == start_button_left:
if pressed:
left_thread.start_clicking()
else:
left_thread.stop_clicking()
if button == start_button_right:
if pressed:
right_thread.start_clicking()
else:
right_thread.stop_clicking()
with Listener(on_click=on_click) as listener:
listener.join()
Edited by LinuxHeki