refactor: 使用 keyboard 模块替代 pyautogui 模块
This commit is contained in:
@@ -576,7 +576,7 @@ class MaaPlanConfig(LQConfig):
|
||||
|
||||
class AppConfig(GlobalConfig):
|
||||
|
||||
VERSION = "4.3.10.2"
|
||||
VERSION = "4.3.10.3"
|
||||
|
||||
gameid_refreshed = Signal()
|
||||
PASSWORD_refreshed = Signal()
|
||||
|
||||
@@ -29,7 +29,7 @@ from loguru import logger
|
||||
from PySide6.QtCore import QObject, QTimer
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
import pyautogui
|
||||
import keyboard
|
||||
|
||||
from .config import Config
|
||||
from .task_manager import TaskManager
|
||||
@@ -41,8 +41,6 @@ class _MainTimer(QObject):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
self.if_FailSafeException = False
|
||||
|
||||
self.Timer = QTimer()
|
||||
self.Timer.timeout.connect(self.timed_start)
|
||||
self.Timer.timeout.connect(self.set_silence)
|
||||
@@ -113,16 +111,14 @@ class _MainTimer(QObject):
|
||||
for emulator_path in Config.silence_list
|
||||
):
|
||||
try:
|
||||
pyautogui.hotkey(
|
||||
*[
|
||||
keyboard.press_and_release(
|
||||
"+".join(
|
||||
_.strip().lower()
|
||||
for _ in Config.get(Config.function_BossKey).split("+")
|
||||
]
|
||||
)
|
||||
)
|
||||
except pyautogui.FailSafeException as e:
|
||||
if not self.if_FailSafeException:
|
||||
logger.warning(f"FailSafeException: {e}")
|
||||
self.if_FailSafeException = True
|
||||
except Exception as e:
|
||||
logger.error(f"模拟按键时出错:{e}")
|
||||
|
||||
def check_power(self):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user