add more actions

This commit is contained in:
Jing Hua
2023-10-25 18:26:13 +08:00
parent a7144824d2
commit d01a3b44f6
3 changed files with 56 additions and 10 deletions

View File

@@ -1,6 +1,17 @@
from enum import Enum
import subprocess
from fabric import Connection
class MouseClick(Enum):
LEFT = 1
MIDDLE = 2
RIGHT = 3
WHEEL_UP = 4
WHEEL_DOWN = 5
class EmulatorSimulator:
def __init__(self, vm_name: str, username: str, password: str, host:str, snapshot_name: str = "snapshot"):
self.vm_name = vm_name
@@ -34,16 +45,22 @@ class EmulatorSimulator:
def save_state(self) -> None:
self._execute_command(["VBoxManage", "snapshot", self.vm_name, "take", self.snapshot_name])
def send_click(self, click: int) -> None:
self._execute_xdotool_command(f"click {click}")
def click(self, click: MouseClick) -> None:
self._execute_xdotool_command(f"click {click.value}")
def send_key(self) -> None:
pass
def mousedown(self, click: MouseClick) -> None:
self._execute_xdotool_command(f"mousedown {click}")
def mouseup(self, click: MouseClick) -> None:
self._execute_xdotool_command(f"mouseup {click}")
def mouse_move(self, x: int, y: int) -> None:
self._execute_xdotool_command(f"mousemove {x} {y}")
def keyboard_type(self, text: str) -> None:
def key(self, key: str) -> None:
self._execute_xdotool_command(f"key {key}")
def type(self, text: str) -> None:
self._execute_xdotool_command(f"type {text}")
def get_screenshot(self) -> str: