refactor: 使用 keyboard 模块替代 pyautogui 模块
This commit is contained in:
1
.github/workflows/build-app.yml
vendored
1
.github/workflows/build-app.yml
vendored
@@ -81,7 +81,6 @@ jobs:
|
||||
script-name: main.py
|
||||
mode: app
|
||||
enable-plugins: pyside6
|
||||
nofollow-import-to: pyscreeze
|
||||
onefile-tempdir-spec: "{TEMP}/AUTO_MAA"
|
||||
windows-console-mode: attach
|
||||
windows-icon-from-ico: resources/icons/AUTO_MAA.ico
|
||||
|
||||
@@ -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):
|
||||
|
||||
|
||||
@@ -982,6 +982,7 @@ class MaaManager(QObject):
|
||||
connect_result = subprocess.run(
|
||||
[self.ADB_path, "connect", ADB_address],
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
stdin=subprocess.DEVNULL,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
@@ -993,6 +994,7 @@ class MaaManager(QObject):
|
||||
devices_result = subprocess.run(
|
||||
[self.ADB_path, "devices"],
|
||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||
stdin=subprocess.DEVNULL,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
|
||||
@@ -72,12 +72,11 @@ if __name__ == "__main__":
|
||||
os.system(
|
||||
"powershell -Command python -m nuitka --standalone --onefile --mingw64"
|
||||
" --enable-plugins=pyside6 --windows-console-mode=attach"
|
||||
" --nofollow-import-to=pyscreeze"
|
||||
" --onefile-tempdir-spec='{TEMP}\\AUTO_MAA'"
|
||||
" --windows-icon-from-ico=resources\\icons\\AUTO_MAA.ico"
|
||||
" --company-name='AUTO_MAA Team' --product-name=AUTO_MAA"
|
||||
f" --file-version={version["main_version"]}"
|
||||
f" --product-version={version["main_version"]}"
|
||||
f" --file-version={version['main_version']}"
|
||||
f" --product-version={version['main_version']}"
|
||||
" --file-description='AUTO_MAA Component'"
|
||||
" --copyright='Copyright © 2024-2025 DLmaster361'"
|
||||
" --assume-yes-for-downloads --output-filename=AUTO_MAA"
|
||||
|
||||
4
main.py
4
main.py
@@ -28,6 +28,8 @@ v4.3
|
||||
# 屏蔽广告
|
||||
import builtins
|
||||
|
||||
original_print = builtins.print
|
||||
|
||||
|
||||
def no_print(*args, **kwargs):
|
||||
if (
|
||||
@@ -36,7 +38,7 @@ def no_print(*args, **kwargs):
|
||||
and "QFluentWidgets Pro is now released." in args[0]
|
||||
):
|
||||
return
|
||||
return __builtins__.print(*args, **kwargs)
|
||||
return original_print(*args, **kwargs)
|
||||
|
||||
|
||||
builtins.print = no_print
|
||||
|
||||
@@ -4,7 +4,7 @@ PySide6
|
||||
PySide6-Fluent-Widgets[full]
|
||||
psutil
|
||||
pywin32
|
||||
pyautogui
|
||||
keyboard
|
||||
pycryptodome
|
||||
requests
|
||||
markdown
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
{
|
||||
"main_version": "4.3.10.2",
|
||||
"main_version": "4.3.10.3",
|
||||
"version_info": {
|
||||
"4.3.10.3": {
|
||||
"程序优化": [
|
||||
"使用 keyboard 模块替代 pyautogui 模块"
|
||||
]
|
||||
},
|
||||
"4.3.10.2": {
|
||||
"新增功能": [
|
||||
"公招喜报模板优化",
|
||||
|
||||
Reference in New Issue
Block a user