Cross-platform Python client for KMBox Net devices
Project description
kmbox-universal
Cross-platform Python client for KMBox Net devices.
This package merges the useful parts of the public KMBox ecosystem:
- the official
kvmaibox/kmboxnetprotocol and command set - the Java ergonomics from
OceanTw/KMNet.java - the higher-level helpers from
uve192/KMBox.NET
It adds:
- pure Python UDP transport
- optional encrypted packet sending for
enc_*operations - monitor mode with keyboard/mouse state tracking
- mask/unmask helpers
- LCD, debug, VID/PID, reboot, and trace commands
- text typing helpers
- "absolute-ish" cursor movement by homing to a screen corner first
Install
pip install kmbox-universal
Public API
Main exports:
KMBoxClientHidKeyMouseButtonKeyboardModifierAbsoluteMouseConfigKMBoxErrorKMBoxTimeoutErrorKMBoxProtocolError
Quick Start
from kmbox_universal import KMBoxClient, HidKey, MouseButton
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.key_press(HidKey.C, 60)
client.move(100, 0)
client.click(MouseButton.LEFT)
client.close()
Interactive Test CLI
After install:
kmbox-interactive --host 192.168.2.188 --port 6314 --uuid 39EBDC32
Or from source:
PYTHONPATH=src python -m kmbox_universal.interactive --host 192.168.2.188 --port 6314 --uuid 39EBDC32
The CLI supports common manual test commands:
press c 60combo LEFT_CTRL,C 60type hellomove 100 0move_auto 300 100 200click left 50click_at 10 10 left 50monitor_start 5002statemask left onunmask_alllcd_color 0xF800
Use help inside the CLI to see the full command list.
Constructor
KMBoxClient(
host: str,
port: int,
uuid: str,
*,
timeout: float = 2.0,
auto_connect: bool = True,
absolute_mouse: AbsoluteMouseConfig | None = None,
)
Parameters:
host: KMBox device IPport: KMBox UDP portuuid: 8 hex characters, for example39EBDC32timeout: socket timeout in secondsauto_connect: automatically sends the initial connect commandabsolute_mouse: settings used bymove_to()/click_at()mode:corner_randomortop_left_onlyscreen_width/screen_height: used when homing from non-top-left corners
API Coverage
Connection
connect()close()
Mouse
move(dx, dy)enc_move(dx, dy)move_auto(dx, dy, duration_ms)enc_move_auto(dx, dy, duration_ms)move_bezier(dx, dy, duration_ms, x1, y1, x2, y2)enc_move_bezier(dx, dy, duration_ms, x1, y1, x2, y2)button(button, is_down)enc_button(button, is_down)left(is_down)right(is_down)middle(is_down)side1(is_down)side2(is_down)enc_left(is_down)enc_right(is_down)enc_middle(is_down)enc_side1(is_down)enc_side2(is_down)click(button=MouseButton.LEFT, duration_ms=50)wheel(amount)enc_wheel(amount)mouse_all(buttons, dx, dy, wheel)home_top_left()move_to(x, y, duration_ms=None)click_at(x, y, button=MouseButton.LEFT, duration_ms=50)
Keyboard
key_down(key)enc_key_down(key)key_up(key)enc_key_up(key)key_press(key, duration_ms=50, encrypted=False)combo(keys, duration_ms=50, encrypted=False)type_text(text, delay_ms=80)
Monitor
monitor_start(port=5002, timeout=0.003)monitor_stop()isdown_left()isdown_right()isdown_middle()isdown_side1()isdown_side2()isdown_keyboard(key)client.monitor
client.monitor is a MonitorListener instance after monitor_start(). It can be used for lower-level state reads and callbacks.
Mask / Unmask
mask_left(enabled)mask_right(enabled)mask_middle(enabled)mask_side1(enabled)mask_side2(enabled)mask_x(enabled)mask_y(enabled)mask_wheel(enabled)mask_keyboard(key)unmask_keyboard(key)unmask_all()
Device / Network
set_config(ip, port)set_vid_pid(vid, pid)reboot()debug(port, enabled)trace_enable(enabled)
LCD
lcd_color(rgb565)lcd_picture_bottom(image_data)lcd_picture(image_data)
Image buffer requirements:
lcd_picture_bottom: exactly128 * 80 * 2byteslcd_picture: exactly128 * 160 * 2bytes- format: raw RGB565
Common Examples
Press a Key
from kmbox_universal import KMBoxClient, HidKey
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.key_press(HidKey.F1, 80)
client.close()
Combo
from kmbox_universal import KMBoxClient, HidKey
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.combo([HidKey.LEFT_CTRL, HidKey.C], duration_ms=60)
client.close()
Type Text
from kmbox_universal import KMBoxClient
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.type_text("Hello 123", delay_ms=70)
client.close()
Relative Mouse Move
from kmbox_universal import KMBoxClient
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.move(200, 0)
client.wheel(10)
client.close()
Interpolated Mouse Move
from kmbox_universal import KMBoxClient
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.move_auto(300, 120, 250)
client.close()
Bezier Mouse Move
from kmbox_universal import KMBoxClient
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.move_bezier(300, 100, 220, 80, 0, 220, 100)
client.close()
Encrypted Packets
from kmbox_universal import KMBoxClient, HidKey
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.enc_move(50, 0)
client.enc_left(True)
client.enc_left(False)
client.key_press(HidKey.C, 50, encrypted=True)
client.close()
Monitor Mode
from kmbox_universal import KMBoxClient, HidKey
import time
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.monitor_start(5002)
for _ in range(50):
if client.isdown_left():
print("left mouse is down")
if client.isdown_keyboard(HidKey.A):
print("A is down")
time.sleep(0.05)
client.monitor_stop()
client.close()
Mask / Unmask
from kmbox_universal import KMBoxClient, HidKey
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.mask_left(True)
client.mask_x(True)
client.mask_keyboard(HidKey.A)
# do work...
client.unmask_all()
client.close()
Absolute Click Helper
KMBox Net exposes relative mouse movement, not true absolute cursor positioning. This package provides a pragmatic helper:
client.click_at(10, 10)
By default it first homes to one of the four screen corners at random, then moves from that corner to the requested target.
If you want the old fixed behavior, use AbsoluteMouseConfig(mode="top_left_only").
Example:
from kmbox_universal import AbsoluteMouseConfig, KMBoxClient
client = KMBoxClient(
"192.168.2.188",
6314,
"39EBDC32",
absolute_mouse=AbsoluteMouseConfig(
mode="corner_random",
screen_width=2560,
screen_height=1440,
),
)
client.click_at(10, 10)
client.close()
This works best when:
- the target machine uses one monitor
- the resolution stays fixed
- pointer acceleration is disabled
LCD
from kmbox_universal import KMBoxClient
client = KMBoxClient("192.168.2.188", 6314, "39EBDC32")
client.lcd_color(0xF800) # red
client.close()
Notes
- The package speaks UDP directly to the device.
uuidmust be 8 hex characters.enc_*support is implemented from the public protocol behavior.move_to()/click_at()are practical helpers, not true hardware absolute positioning.- Side buttons are supported at the protocol level, but physical behavior depends on device firmware.
Errors
Main exceptions:
KMBoxError: base errorKMBoxTimeoutError: device did not reply before timeoutKMBoxProtocolError: response header did not match the request
References
These repositories were used as public references while building this package:
- https://github.com/kvmaibox/kmboxnet
- https://github.com/OceanTw/KMNet.java
- https://github.com/uve192/KMBox.NET
Publish
Build:
python -m build
Test:
pytest
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 kmbox_universal-0.1.1.tar.gz.
File metadata
- Download URL: kmbox_universal-0.1.1.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cccf21d467ca24b7696cad92ec046254f776ba6075430aacf102fd17db2ba830
|
|
| MD5 |
0b649802526b13f5cf668771fb2d0991
|
|
| BLAKE2b-256 |
0442ad4648a7b6349824a01c110989a13be754e6df2b81e9115aa2d776e0815e
|
File details
Details for the file kmbox_universal-0.1.1-py3-none-any.whl.
File metadata
- Download URL: kmbox_universal-0.1.1-py3-none-any.whl
- Upload date:
- Size: 16.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae347a3506a544bbbe6ea7a428a7477a2c38c66716679f9c09c1d940e03fddb5
|
|
| MD5 |
171e407bc02ec6503fe97d2f7484f821
|
|
| BLAKE2b-256 |
5f44232f02b827ed5b8cafec0dbe4d597cdbbe01d24713534286c6b7806b8139
|