diff --git a/.gitignore b/.gitignore index 542868c..dce9365 100644 --- a/.gitignore +++ b/.gitignore @@ -16,7 +16,6 @@ messages/ logs/ traces/ version -bin/ ########################## # Byte-compiled / optimized / DLL files diff --git a/kotonebot-resource/MANIFEST.in b/kotonebot-resource/MANIFEST.in index c1188e8..e8da5e6 100644 --- a/kotonebot-resource/MANIFEST.in +++ b/kotonebot-resource/MANIFEST.in @@ -1,3 +1,4 @@ graft fonts graft models graft ui +graft bin \ No newline at end of file diff --git a/kotonebot-resource/bin/AutoHotkey.exe b/kotonebot-resource/bin/AutoHotkey.exe new file mode 100644 index 0000000..34bbf09 Binary files /dev/null and b/kotonebot-resource/bin/AutoHotkey.exe differ diff --git a/kotonebot-resource/pyproject.toml b/kotonebot-resource/pyproject.toml index b97ee1d..e115d09 100644 --- a/kotonebot-resource/pyproject.toml +++ b/kotonebot-resource/pyproject.toml @@ -8,7 +8,7 @@ description = "This package contains the resources for ksaa." readme = "README.md" requires-python = ">=3.10" dependencies = [] -version = "0.1.0" +version = "0.2.0" [tool.setuptools] include-package-data = true @@ -19,3 +19,4 @@ kaa = "." "kaa.res.models" = "models" "kaa.res.fonts" = "fonts" "kaa.res.ui" = "ui" +"kaa.res.bin" = "bin" diff --git a/kotonebot/client/implements/windows.py b/kotonebot/client/implements/windows.py index 89d9ac4..60b7269 100644 --- a/kotonebot/client/implements/windows.py +++ b/kotonebot/client/implements/windows.py @@ -1,5 +1,6 @@ from ctypes import windll from typing import Literal +from importlib import resources from functools import cached_property import cv2 @@ -15,7 +16,8 @@ from ..protocol import Commandable, Touchable, Screenshotable class WindowsImpl(Touchable, Screenshotable): def __init__(self, device: Device): 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.emergency = False diff --git a/kotonebot/tasks/start_game.py b/kotonebot/tasks/start_game.py index 765a786..c9c74ab 100644 --- a/kotonebot/tasks/start_game.py +++ b/kotonebot/tasks/start_game.py @@ -94,8 +94,10 @@ def windows_launch(): 结束状态:游戏窗口出现 """ 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...') os.startfile('dmmgameplayer://play/GCL/gakumas/cl/win') # 等待游戏窗口出现 diff --git a/pyproject.toml b/pyproject.toml index 8e5764b..547446a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ dependencies = [ # Configuration "pydantic==2.10.4", # Resource - "ksaa-res==0.1.0", + "ksaa-res==0.2.0", # Other "typing-extensions==4.12.2", "python-dotenv==1.0.1",