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
|
script-name: main.py
|
||||||
mode: app
|
mode: app
|
||||||
enable-plugins: pyside6
|
enable-plugins: pyside6
|
||||||
nofollow-import-to: pyscreeze
|
|
||||||
onefile-tempdir-spec: "{TEMP}/AUTO_MAA"
|
onefile-tempdir-spec: "{TEMP}/AUTO_MAA"
|
||||||
windows-console-mode: attach
|
windows-console-mode: attach
|
||||||
windows-icon-from-ico: resources/icons/AUTO_MAA.ico
|
windows-icon-from-ico: resources/icons/AUTO_MAA.ico
|
||||||
|
|||||||
@@ -576,7 +576,7 @@ class MaaPlanConfig(LQConfig):
|
|||||||
|
|
||||||
class AppConfig(GlobalConfig):
|
class AppConfig(GlobalConfig):
|
||||||
|
|
||||||
VERSION = "4.3.10.2"
|
VERSION = "4.3.10.3"
|
||||||
|
|
||||||
gameid_refreshed = Signal()
|
gameid_refreshed = Signal()
|
||||||
PASSWORD_refreshed = Signal()
|
PASSWORD_refreshed = Signal()
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ from loguru import logger
|
|||||||
from PySide6.QtCore import QObject, QTimer
|
from PySide6.QtCore import QObject, QTimer
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import pyautogui
|
import keyboard
|
||||||
|
|
||||||
from .config import Config
|
from .config import Config
|
||||||
from .task_manager import TaskManager
|
from .task_manager import TaskManager
|
||||||
@@ -41,8 +41,6 @@ class _MainTimer(QObject):
|
|||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self.if_FailSafeException = False
|
|
||||||
|
|
||||||
self.Timer = QTimer()
|
self.Timer = QTimer()
|
||||||
self.Timer.timeout.connect(self.timed_start)
|
self.Timer.timeout.connect(self.timed_start)
|
||||||
self.Timer.timeout.connect(self.set_silence)
|
self.Timer.timeout.connect(self.set_silence)
|
||||||
@@ -113,16 +111,14 @@ class _MainTimer(QObject):
|
|||||||
for emulator_path in Config.silence_list
|
for emulator_path in Config.silence_list
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
pyautogui.hotkey(
|
keyboard.press_and_release(
|
||||||
*[
|
"+".join(
|
||||||
_.strip().lower()
|
_.strip().lower()
|
||||||
for _ in Config.get(Config.function_BossKey).split("+")
|
for _ in Config.get(Config.function_BossKey).split("+")
|
||||||
]
|
)
|
||||||
)
|
)
|
||||||
except pyautogui.FailSafeException as e:
|
except Exception as e:
|
||||||
if not self.if_FailSafeException:
|
logger.error(f"模拟按键时出错:{e}")
|
||||||
logger.warning(f"FailSafeException: {e}")
|
|
||||||
self.if_FailSafeException = True
|
|
||||||
|
|
||||||
def check_power(self):
|
def check_power(self):
|
||||||
|
|
||||||
|
|||||||
@@ -982,6 +982,7 @@ class MaaManager(QObject):
|
|||||||
connect_result = subprocess.run(
|
connect_result = subprocess.run(
|
||||||
[self.ADB_path, "connect", ADB_address],
|
[self.ADB_path, "connect", ADB_address],
|
||||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||||
|
stdin=subprocess.DEVNULL,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
@@ -993,6 +994,7 @@ class MaaManager(QObject):
|
|||||||
devices_result = subprocess.run(
|
devices_result = subprocess.run(
|
||||||
[self.ADB_path, "devices"],
|
[self.ADB_path, "devices"],
|
||||||
creationflags=subprocess.CREATE_NO_WINDOW,
|
creationflags=subprocess.CREATE_NO_WINDOW,
|
||||||
|
stdin=subprocess.DEVNULL,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
text=True,
|
text=True,
|
||||||
encoding="utf-8",
|
encoding="utf-8",
|
||||||
|
|||||||
@@ -72,12 +72,11 @@ if __name__ == "__main__":
|
|||||||
os.system(
|
os.system(
|
||||||
"powershell -Command python -m nuitka --standalone --onefile --mingw64"
|
"powershell -Command python -m nuitka --standalone --onefile --mingw64"
|
||||||
" --enable-plugins=pyside6 --windows-console-mode=attach"
|
" --enable-plugins=pyside6 --windows-console-mode=attach"
|
||||||
" --nofollow-import-to=pyscreeze"
|
|
||||||
" --onefile-tempdir-spec='{TEMP}\\AUTO_MAA'"
|
" --onefile-tempdir-spec='{TEMP}\\AUTO_MAA'"
|
||||||
" --windows-icon-from-ico=resources\\icons\\AUTO_MAA.ico"
|
" --windows-icon-from-ico=resources\\icons\\AUTO_MAA.ico"
|
||||||
" --company-name='AUTO_MAA Team' --product-name=AUTO_MAA"
|
" --company-name='AUTO_MAA Team' --product-name=AUTO_MAA"
|
||||||
f" --file-version={version["main_version"]}"
|
f" --file-version={version['main_version']}"
|
||||||
f" --product-version={version["main_version"]}"
|
f" --product-version={version['main_version']}"
|
||||||
" --file-description='AUTO_MAA Component'"
|
" --file-description='AUTO_MAA Component'"
|
||||||
" --copyright='Copyright © 2024-2025 DLmaster361'"
|
" --copyright='Copyright © 2024-2025 DLmaster361'"
|
||||||
" --assume-yes-for-downloads --output-filename=AUTO_MAA"
|
" --assume-yes-for-downloads --output-filename=AUTO_MAA"
|
||||||
|
|||||||
4
main.py
4
main.py
@@ -28,6 +28,8 @@ v4.3
|
|||||||
# 屏蔽广告
|
# 屏蔽广告
|
||||||
import builtins
|
import builtins
|
||||||
|
|
||||||
|
original_print = builtins.print
|
||||||
|
|
||||||
|
|
||||||
def no_print(*args, **kwargs):
|
def no_print(*args, **kwargs):
|
||||||
if (
|
if (
|
||||||
@@ -36,7 +38,7 @@ def no_print(*args, **kwargs):
|
|||||||
and "QFluentWidgets Pro is now released." in args[0]
|
and "QFluentWidgets Pro is now released." in args[0]
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
return __builtins__.print(*args, **kwargs)
|
return original_print(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
builtins.print = no_print
|
builtins.print = no_print
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ PySide6
|
|||||||
PySide6-Fluent-Widgets[full]
|
PySide6-Fluent-Widgets[full]
|
||||||
psutil
|
psutil
|
||||||
pywin32
|
pywin32
|
||||||
pyautogui
|
keyboard
|
||||||
pycryptodome
|
pycryptodome
|
||||||
requests
|
requests
|
||||||
markdown
|
markdown
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
{
|
{
|
||||||
"main_version": "4.3.10.2",
|
"main_version": "4.3.10.3",
|
||||||
"version_info": {
|
"version_info": {
|
||||||
|
"4.3.10.3": {
|
||||||
|
"程序优化": [
|
||||||
|
"使用 keyboard 模块替代 pyautogui 模块"
|
||||||
|
]
|
||||||
|
},
|
||||||
"4.3.10.2": {
|
"4.3.10.2": {
|
||||||
"新增功能": [
|
"新增功能": [
|
||||||
"公招喜报模板优化",
|
"公招喜报模板优化",
|
||||||
|
|||||||
Reference in New Issue
Block a user