-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathtyper.py
43 lines (33 loc) · 1.08 KB
/
typer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from abc import ABC, abstractmethod
from typing import Optional
class Typer(ABC):
@staticmethod
def best_option(name: Optional[str] = None) -> "Typer":
from .noop import NoopTyper
from .wtype import WTypeTyper
from .xdotool import XDoToolTyper
available_typers = [XDoToolTyper, WTypeTyper, NoopTyper]
if name is not None:
return next(typer for typer in available_typers if typer.name() == name)()
else:
return next(typer for typer in available_typers if typer.supported())()
@staticmethod
@abstractmethod
def supported() -> bool:
pass
@staticmethod
@abstractmethod
def name() -> str:
pass
@abstractmethod
def get_active_window(self) -> str:
pass
@abstractmethod
def type_characters(self, characters: str, active_window: str) -> None:
pass
@abstractmethod
def insert_from_clipboard(self, active_window: str) -> None:
pass
@abstractmethod
def type_numerical(self, characters: str, active_window: str) -> None:
pass