Moonlink Developer Integration Guide

Overview

Moonlink exposes a named pipe at \\.\pipe\moonlink_input that accepts relative mouse deltas. Your application writes 4-byte packets to this pipe and Moonlink forwards them to the hardware device. The Windows cursor is never moved — there is no fighting, no hooks to worry about, and no SendInput required.

The pipe is available as soon as Moonlink is open. You do not need to press Capture first.


Protocol

Each packet is 4 bytes:

Byte
Content
Type

0–1

dx (horizontal delta)

int16, little-endian

2–3

dy (vertical delta)

int16, little-endian

Value range: -32768 to 32767 per axis.

Positive dx = move right. Positive dy = move down.


Python

Copy moonlink.py into your project. No dependencies beyond the standard library.

Raw pipe access (no library needed)

Mouse button handler

Moonlink forwards physical button state automatically — your code only sends movement deltas through the pipe. But your application needs to read button state to know when to activate (e.g., "aim while right-click is held").

Use win32api.GetAsyncKeyState for low-latency, non-blocking button polling. This works globally — no window focus required.

Usage — check any button:

Practical example — activate while holding a button

A common pattern: send AI movement only while a specific button is held.

Toggle mode

If you prefer a toggle (press once to activate, press again to deactivate):

All 5 buttons — reference table

Button
Virtual Key
Constant
Typical Use

Left

0x01

VK_LBUTTON

Shoot / interact

Right

0x02

VK_RBUTTON

Aim / scope

Middle

0x04

VK_MBUTTON

Secondary toggle

Back (Mouse4)

0x05

VK_XBUTTON1

Toggle on/off

Forward (Mouse5)

0x06

VK_XBUTTON2

Mode switch

Full example — circle movement


C / C++

Connecting to the pipe

Sending a delta

Mouse button handler

Full example


C#


Rust


Tips

  • Pipe is always open — you can connect as soon as Moonlink launches, before pressing Capture.

  • Unbuffered writes — use buffering=0 in Python or write-through in other languages for lowest latency.

  • Reconnection — if the pipe disconnects (Moonlink restarts), just reopen it. Moonlink recreates the pipe server automatically.

  • Movement only — the pipe handles movement. Buttons and scroll wheel are read from your physical mouse by Moonlink automatically.

  • No cursor movement — pipe data goes straight to the device. The Windows cursor stays where it is.

  • Legacy mode — if your software must use SendInput, uncheck "Pipe Mode" in Moonlink's Misc tab. This enables the older hook-based interception. Not recommended.

Last updated