diff --git a/README.md b/README.md index 9d7a608..f370eb3 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,28 @@ Segatools 读卡器前端 # 装 ``` +git clone https://github.com/MaigoLabs/AimeWeb +cd AimeWeb python3 -m venv venv venv/bin/pip install -r requirements.txt ``` +# 配 + +编辑 `src/main.py` 文件 + +```py +AIME_PATH = "aime.txt" # segatools aimePath +KEY = 0x0D # segatools card scan key +PORT = 8249 # HTTP Port +``` + # 跑 ``` venv/bin/python3 src/main.py ``` +# 用 + +浏览器打开 `http://{LAN ip}:8249` diff --git a/src/main.py b/src/main.py index 99a0ab5..01c8869 100644 --- a/src/main.py +++ b/src/main.py @@ -10,6 +10,12 @@ from starlette.responses import HTMLResponse from vk import press_key, release_key + +AIME_PATH = "aime.txt" # segatools aimePath +KEY = 0x0D # segatools card scan key +PORT = 8249 # HTTP Port + + app = FastAPI() # CORS @@ -22,7 +28,7 @@ app.add_middleware( ) # Configuration -PATH = Path('aime.txt') +PATH = Path(AIME_PATH) AUDIO_EFFECT = Path(__file__).parent / 'audio/mixkit-gaming-lock-2848.wav' HTML = Path(__file__).parent.parent / "web/dist/index.html" @@ -58,9 +64,9 @@ def scan(uid: str): winsound.PlaySound(str(AUDIO_EFFECT), winsound.SND_FILENAME) # Simulate key press - press_key() + press_key(KEY) time.sleep(5) - release_key() + release_key(KEY) return {"uid": uid} diff --git a/src/vk.py b/src/vk.py index 47bd965..9e6eb4a 100644 --- a/src/vk.py +++ b/src/vk.py @@ -1,14 +1,11 @@ import ctypes -# Virtual-Key codes -VK = 0x0D - -def press_key(vk_code=VK): +def press_key(vk_code): scan_code = ctypes.windll.user32.MapVirtualKeyA(vk_code, 0) ctypes.windll.user32.keybd_event(vk_code, scan_code, 0, 0) -def release_key(vk_code=VK): +def release_key(vk_code): scan_code = ctypes.windll.user32.MapVirtualKeyA(vk_code, 0) ctypes.windll.user32.keybd_event(vk_code, scan_code, 0x0002, 0)