add mouse cursor to screenshot
This commit is contained in:
@@ -2,6 +2,7 @@ from enum import Enum
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from fabric import Connection
|
||||
import re
|
||||
|
||||
from .xdotool import XDoToolController
|
||||
from .python import PythonController
|
||||
@@ -13,6 +14,10 @@ class MouseClick(Enum):
|
||||
WHEEL_DOWN = 5
|
||||
|
||||
class AbstractMouseController(ABC):
|
||||
@abstractmethod
|
||||
def get_mouse(self):
|
||||
raise NotImplementedError
|
||||
|
||||
@abstractmethod
|
||||
def mouse_move(self, x: int, y: int):
|
||||
raise NotImplementedError
|
||||
@@ -66,6 +71,10 @@ class XDoToolMouseController(AbstractMouseController, XDoToolController):
|
||||
def __init__(self, ssh_connection: Connection):
|
||||
super().__init__(ssh_connection=ssh_connection)
|
||||
|
||||
@abstractmethod
|
||||
def get_mouse(self):
|
||||
raise NotImplementedError
|
||||
|
||||
def mouse_move(self, x: int, y: int):
|
||||
self._execute_xdotool_command(f"mousemove {x} {y}")
|
||||
|
||||
@@ -105,7 +114,13 @@ class XDoToolMouseController(AbstractMouseController, XDoToolController):
|
||||
class PythonMouseController(AbstractMouseController, PythonController):
|
||||
def __init__(self, http_server: str):
|
||||
super().__init__(http_server=http_server)
|
||||
self.command = "python -c \"import mouse; {command}\""
|
||||
self.command = "py -c \"import mouse; {command}\""
|
||||
|
||||
def get_mouse(self):
|
||||
response = self._execute_python_command(self.command.format(command=f"print(mouse.get_position())"))
|
||||
numbers = re.findall(r'-?\d+', response["output"])
|
||||
x, y = map(int, numbers)
|
||||
return x, y
|
||||
|
||||
def mouse_move(self, x: int, y: int):
|
||||
self._execute_python_command(self.command.format(command=f"mouse.move({x}, {y})"))
|
||||
|
||||
Reference in New Issue
Block a user