Files
lc-mcp/backends/__init__.py
T

35 lines
896 B
Python

# -*- coding: utf-8 -*-
"""输入后端接口。每种后端实现同一套动作:click/move/keypress/type_text。"""
from abc import ABC, abstractmethod
class InputBackend(ABC):
@abstractmethod
def click(self, x, y, button='left', clicks=1):
...
@abstractmethod
def move(self, x, y):
...
@abstractmethod
def keypress(self, key):
...
@abstractmethod
def type_text(self, text):
...
def backend_factory(name, **kwargs):
if name == 'mock':
from .mock import MockBackend
return MockBackend(**kwargs)
if name == 'sendinput':
from .sendinput_win import SendInputBackend
return SendInputBackend(**kwargs)
if name == 'interception':
from .interception_win import InterceptionBackend
return InterceptionBackend(**kwargs)
raise ValueError('unknown backend: %s' % name)