refactor(task): 将 AutoHotKey.exe 移动到 ksaa-res 包内

This commit is contained in:
XcantloadX 2025-03-21 18:42:45 +08:00
parent a86004b899
commit 1c063f3ee6
7 changed files with 10 additions and 5 deletions

1
.gitignore vendored
View File

@ -16,7 +16,6 @@ messages/
logs/ logs/
traces/ traces/
version version
bin/
########################## ##########################
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files

View File

@ -1,3 +1,4 @@
graft fonts graft fonts
graft models graft models
graft ui graft ui
graft bin

Binary file not shown.

View File

@ -8,7 +8,7 @@ description = "This package contains the resources for ksaa."
readme = "README.md" readme = "README.md"
requires-python = ">=3.10" requires-python = ">=3.10"
dependencies = [] dependencies = []
version = "0.1.0" version = "0.2.0"
[tool.setuptools] [tool.setuptools]
include-package-data = true include-package-data = true
@ -19,3 +19,4 @@ kaa = "."
"kaa.res.models" = "models" "kaa.res.models" = "models"
"kaa.res.fonts" = "fonts" "kaa.res.fonts" = "fonts"
"kaa.res.ui" = "ui" "kaa.res.ui" = "ui"
"kaa.res.bin" = "bin"

View File

@ -1,5 +1,6 @@
from ctypes import windll from ctypes import windll
from typing import Literal from typing import Literal
from importlib import resources
from functools import cached_property from functools import cached_property
import cv2 import cv2
@ -15,7 +16,8 @@ from ..protocol import Commandable, Touchable, Screenshotable
class WindowsImpl(Touchable, Screenshotable): class WindowsImpl(Touchable, Screenshotable):
def __init__(self, device: Device): def __init__(self, device: Device):
self.__hwnd: int | None = None self.__hwnd: int | None = None
self.ahk = AHK(executable_path='bin/AutoHotKey.exe') # TODO: 硬编码路径
self.ahk = AHK(executable_path=str(resources.files('kaa.res.bin') / 'AutoHotkey.exe'))
self.device = device self.device = device
self.emergency = False self.emergency = False

View File

@ -94,8 +94,10 @@ def windows_launch():
结束状态游戏窗口出现 结束状态游戏窗口出现
""" """
from ahk import AHK from ahk import AHK
from importlib import resources
ahk = AHK(executable_path='bin/AutoHotkey.exe') ahk_path = str(resources.files('kaa.res.bin') / 'AutoHotkey.exe')
ahk = AHK(executable_path=ahk_path)
logger.info('Starting game...') logger.info('Starting game...')
os.startfile('dmmgameplayer://play/GCL/gakumas/cl/win') os.startfile('dmmgameplayer://play/GCL/gakumas/cl/win')
# 等待游戏窗口出现 # 等待游戏窗口出现

View File

@ -29,7 +29,7 @@ dependencies = [
# Configuration # Configuration
"pydantic==2.10.4", "pydantic==2.10.4",
# Resource # Resource
"ksaa-res==0.1.0", "ksaa-res==0.2.0",
# Other # Other
"typing-extensions==4.12.2", "typing-extensions==4.12.2",
"python-dotenv==1.0.1", "python-dotenv==1.0.1",