Te recomendamos que pruebes esta solución en un entorno controlado antes de pasarlo a producción, saludos.
Ejemplo 1: código python para liberar con un clic del mouse
from pynput.mouse import Button, Controller
mouse = Controller()
# Read pointer position
print('The current pointer position is 0'.format(
mouse.position))
# Set pointer position
mouse.position = (10, 20)
print('Now we have moved it to 0'.format(
mouse.position))
# Move pointer relative to current position
mouse.move(5, -5)
# Press and release
mouse.press(Button.left)
mouse.release(Button.left)
# Double click; this is different from pressing and releasing
# twice on Mac OSX
mouse.click(Button.left, 2)
# Scroll two steps down
mouse.scroll(0, 2)
Ejemplo 2: pynput detecta el clic del mouse
from pynput.mouse import Listener
def on_move(x, y):
print('Pointer moved to 0'.format(
(x, y)))
def on_click(x, y, button, pressed):
print('0 at 1'.format(
'Pressed' if pressed else 'Released',
(x, y)))
if not pressed:
# Stop listener
return False
def on_scroll(x, y, dx, dy):
print('Scrolled 0'.format(
(x, y)))
# Collect events until released
with Listener(
on_move=on_move,
on_click=on_click,
on_scroll=on_scroll) as listener:
listener.join()
Si te sientes incitado, tienes la habilidad dejar una reseña acerca de qué te ha parecido este escrito.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)