One-click calibration & label/gap measurement for TSPL label printers on Windows.
Works with Xprinter, TSC, Gprinter and other TSPL-compatible thermal label printers over USB or Serial (COM) — no extra drivers, no libusb.
Label printers often lose track of where one label ends and the next begins — you get labels printed across the gap, skipped labels, or a blinking error light. The fix is a gap calibration, but many cheap printers ship with clunky (or no) tools to do it, and the Windows print spooler makes reading data back from the printer painful.
GapDetect does it in one click and also reads back the label length and gap size the printer has detected, in millimeters.
- One-click calibration — sends the TSPL
GAPDETECTcommand so the printer learns your label/gap layout. - Read current settings — fetches
ALLCONFIGfrom the printer and shows label length and gap size in mm. - Direct USB (RAW) access — talks to the printer through Windows' built-in USB Printer Class driver, completely bypassing the print spooler. Your existing printer queue stays untouched.
- Serial (COM) support for printers connected over RS-232 / virtual COM ports.
- DPI aware — 203 / 300 / 600 DPI for correct dot → mm conversion.
- Remembers your last printer, DPI and language.
- Light / dark mode follows your Windows theme.
- Clean, distraction-free English UI with modern frameless design.
Grab the latest GapDetect.exe from the Releases page — no installation needed, just run it.
Windows SmartScreen may warn about an unknown publisher because the executable isn't code-signed. Click More info → Run anyway, or build it yourself from source (below).
- Plug in your printer and load labels.
- Open GapDetect and select your printer from the list (it connects automatically).
- Choose your printer's DPI (most budget label printers are 203 DPI).
- Click Calibrate — the printer feeds a few labels to detect the gap.
- Click Get Info to read back the detected label length and gap.
Requirements: Windows, Python 3.8+
git clone https://github.com/StaticBeaver/GapDetect.git
cd GapDetect
pip install -r requirements.txt
python main.pypip install pyinstaller
pyinstaller GapDetect.specThe executable will be created in dist/GapDetect.exe.
usbprint_raw.py is a small, dependency-free module you can reuse in your own projects. It shows how to:
- enumerate
GUID_DEVINTERFACE_USBPRINTdevices withsetupapi.dll, - open them with
CreateFileand do asynchronous (OVERLAPPED)ReadFile/WriteFileviactypes, - avoid deadlocks on unresponsive printers with timeouts and
CancelIoEx.
from usbprint_raw import list_usbprint_devices_with_names, RawUsbPrinter
path, name = list_usbprint_devices_with_names()[0]
with RawUsbPrinter(path) as printer:
printer.write(b"ALLCONFIG\r\n")
data, err = printer.read(1024, timeout=2.5)
print(name, data.decode(errors="ignore"))No PyUSB, no libusb, no Zadig driver swapping — it uses the driver Windows already installed for your printer.
Any printer that speaks TSPL / TSPL2 should work. Tested with Xprinter label printers. If you've tried it with another model, please open an issue or PR to add it to this list!
Bug reports, printer compatibility reports and pull requests are welcome. Please open an issue first for larger changes.
MIT © 2026 StaticBeaver
