Python wrapper for LunaHook — attach to Windows VN/game processes and stream hooked text
Project description
lunahook-py
Python wrapper for LunaHook — attach to running Windows VN/game processes, inject text hooks, and stream extracted text into your own tools. Zero runtime dependencies.
What is this?
LunaHook is the text hooking engine behind LunaTranslator, a successor to the previously popular Textractor. It supports a much wider range of games than the older Textractor, with monthly updates for new titles.
lunahook-py wraps LunaHook's DLLs in a clean Python API so you can plug text hooking into your own projects — translation pipelines, subtitle overlays, logging tools, whatever you're building.
The LunaHook binaries are bundled with the package. You don't need a separate LunaTranslator installation.
Requirements
- Python 3.10+
- Windows 10/11 (x64)
- Visual C++ Redistributable (already installed on most machines)
- Admin privileges (required for DLL injection)
Installation
pip install lunahook-py
Quick Start
from lunahook_py import LunaHook
lh = LunaHook()
lh.attach(12345) # your game's PID
for pid, hook, text in lh.listen():
print(text)
Usage
Filtering by hook
When you attach to a game, LunaHook will discover multiple text threads — story text, UI strings, system calls, noise. Each one has a hook code like ENHQX-24@10DD90:game.exe. Once you know which hook carries the story text, filter to it:
for pid, hook, text in lh.listen(pid=12345, hook="ENHQX-24@10DD90:game.exe"): #Both parameters are optional
print(text)
To discover which hooks are available, listen without a filter first and watch what comes through.
Listening to everything
# No filters — see all output from all attached processes
for pid, hook, text in lh.listen():
print(f"[{pid}] {hook}: {text}")
Attaching multiple games
lh.attach(111)
lh.attach(222) # spins up a second LunaHost instance if architectures differ
for pid, hook, text in lh.listen(): #Here you could use the pid parameter for filtering too
print(f"[{pid}] {text}")
Detaching
lh.detach(12345)
API
LunaHook()
Creates a new LunaHook instance and initializes the host DLL.
.attach(pid: int)
Attaches to a running process. Automatically detects x86/x64 architecture and injects the appropriate hook DLL. If the process is already hooked (e.g. from a previous session), injection is skipped.
.detach(pid: int)
Detaches from a process.
.listen(pid: int = 0, hook: str = None)
Blocking generator that yields (pid, hook, text) tuples as text arrives.
| Parameter | Description |
|---|---|
pid |
Filter to a specific process. 0 means all attached processes. |
hook |
Filter to a specific hook code string. None means all hooks. |
Notes
Admin privileges — DLL injection requires elevated permissions. Run your script as administrator, or you'll get silent injection failures.
x86 games — 32-bit games are fully supported. lunahook-py detects the target architecture automatically and uses the right injector.
Hook discovery — LunaHook auto-discovers text threads when you attach. Give it a second after attaching and advance some text in the game before listening — this lets the hooks fire and populate the output stream.
Compared to textractor-py — lunahook-py uses the same listen() interface as textractor-py, so they're largely drop-in compatible from the caller's perspective. LunaHook supports more games and gets more frequent updates; Textractor is simpler but increasingly unmaintained.
License
GPLv3.0 — matching LunaHook's upstream license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lunahook_py-0.1.0.tar.gz.
File metadata
- Download URL: lunahook_py-0.1.0.tar.gz
- Upload date:
- Size: 2.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b72a1fbc31eba011d47cfc5185e674bfd9ac7424d838b408444a1df394af82e
|
|
| MD5 |
4c6ad35de1263fa8d4ae0b2a3d318aec
|
|
| BLAKE2b-256 |
331cbf8df5c171f59432f59217f619a2024f65c252ee937bb8ab24d720716f73
|
File details
Details for the file lunahook_py-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lunahook_py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 2.3 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddb9c3c81b7473154fd71ae695a4986459a23c7cf99672529dffe5e1524d6471
|
|
| MD5 |
c479e01bec649706a91fc8837b40c3b7
|
|
| BLAKE2b-256 |
784772362c8c35d63dac081840a4df597e59ce93d6871f8e49f4028bbfc04ba1
|