From c94344c4d427eaa5704b93b1355c5dfff9a49458 Mon Sep 17 00:00:00 2001 From: anon <anon@anon.anon> Date: Sun, 10 Mar 2024 15:57:36 +0100 Subject: [PATCH] Added otest.py --- otest.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 otest.py diff --git a/otest.py b/otest.py new file mode 100755 index 0000000..bde90b8 --- /dev/null +++ b/otest.py @@ -0,0 +1,46 @@ +#!/bin/python3 + + +#from pynput import mouse +# +#class TrackpadTapDetector: +# def __init__(self): +# self.tap_positions = {'top_left': None, 'top_right': None, 'bottom_left': None, 'bottom_right': None} +# +# def on_click(self, x, y, button, pressed): +# if pressed: +# # Record the position of the tap +# self.tap_positions[button] = (x, y) +# else: +# # Check if it's a release and print information +# if self.tap_positions[button]: +# release_x, release_y = x, y +# tap_x, tap_y = self.tap_positions[button] +# print(f'Tap at ({tap_x}, {tap_y}) released at ({release_x}, {release_y}) with {button}') +# # Reset the tap position +# self.tap_positions[button] = None +# +## Create an instance of the TrackpadTapDetector +#tap_detector = TrackpadTapDetector() +# +## Create a mouse listener with the custom on_click method +#with mouse.Listener(on_click=tap_detector.on_click) as listener: +# print('Listening to trackpad tap events...') +# listener.join() + +from pynput import mouse + +def on_move(x, y): + print(f'Mouse moved to ({x}, {y})') + +def on_click(x, y, button, pressed): + action = 'pressed' if pressed else 'released' + print(f'Mouse {action} at ({x}, {y}) with {button}') + +def on_scroll(x, y, dx, dy): + print(f'Scrolled at ({x}, {y}) with delta ({dx}, {dy})') + +# Create a mouse listener +with mouse.Listener(on_move=on_move, on_click=on_click, on_scroll=on_scroll) as listener: + print('Listening to trackpad events...') + listener.join()