Control OBSBOT webcams (tested on Tiny 2 Lite) from AutoHotkey over OSC.
This repo provides an OBSBOTController class that talks directly to the camera via UDP/OSC using a custom build of OSC2AHK that supports sending more than two parameters.
The dll is compatible with other languages such as C++, C#, Python...
Usage example as "security camera":
- Start/stop PC recording
- Snap a photo to PC
- Wake / Sleep
- Reset gimbal
- Zoom (0–100)
- Field of View presets (e.g., 86° / 78° / 65°)
- Mirror toggle
- AI tracking controls (mode, lock)
- AI “composition” mode (Headroom / Standard / Motion)
- Direct gimbal control: speed, pan, pitch (uses multi-param OSC — requires the custom DLL)
- Windows (64-bit)
- AutoHotkey v1.1+ 64-bit
- Custom DLL:
OSC2AHKv1.2.dll(modifiedOSC2AHKthat adds a multi-param sender)- Functions used:
sendOscMessageInt— send one integer argumentsendOscMessageInts— send multiple integer arguments (non-standard; added by the custom build)
- Functions used:
Place
OSC2AHKv1.2.dllnext to your script or somewhere on your systemPATH.
- Clone or download this repository.
- Copy
OBSBOTController.ahkinto your project or include it. - Ensure
OSC2AHKv1.2.dllis available to the script (same folder is easiest). - Make sure your OBSBOT Tiny 2 Lite is on the same network, with OBSBOT control service running and OSC function enabled.
- Make sure that you know its IP and OSC/UDP port and that firewall is not blocking the connection.
#NoEnv
#SingleInstance, Force
; Include the class (adjust path if needed)
#Include %A_ScriptDir%\OBSBOTController.ahk
; Replace with your camera's IP and port
ip := "192.168.1.123"
port := 8999
cam := new OBSBOTController(ip, port)
; Wake the camera and center the shot a bit
cam.Wake()
cam.SetZoom(35)
cam.SetAIMode(1) ; 0 Headroom, 1 Standard, 2 Motion
cam.SetTrackingMode(1) ; see modes below
cam.SetAILock(1) ; lock target
; Move gimbal (speed, pan, pitch)
; Ranges: speed 0–90, pan -129–129, pitch -59–59
cam.SetGimbal(45, 0, -10)
; Start/stop PC recording
cam.StartRecording()
Sleep, 5000
cam.StopRecording()
; Take a snapshot to PC
cam.TakePhoto()
; Put camera to sleep
cam.Sleep()
ExitAppAll methods send OSC to the camera using the given ip and port.
cam := new OBSBOTController(ip, port)Loads OSC2AHKv1.2.dll and stores network info.
| Method | OSC Address | Value(s) | Notes |
|---|---|---|---|
StartRecording() |
/OBSBOT/WebCam/General/SetPCRecording |
1 |
Start PC recording |
StopRecording() |
/OBSBOT/WebCam/General/SetPCRecording |
0 |
Stop PC recording |
TakePhoto() |
/OBSBOT/WebCam/General/PCSnapshot |
1 |
Trigger PC snapshot |
Wake() |
/OBSBOT/WebCam/General/WakeSleep |
1 |
Wake device |
Sleep() |
/OBSBOT/WebCam/General/WakeSleep |
0 |
Sleep device |
ResetGimbal() |
/OBSBOT/WebCam/General/ResetGimbal |
0 |
Recenter / reset gimbal |
| Method | OSC Address | Value(s) | Notes |
|---|---|---|---|
SetZoom(v) |
/OBSBOT/WebCam/General/SetZoom |
0–100 (int) |
Zoom percentage |
SetFOV(v) |
/OBSBOT/WebCam/General/SetView |
0 / 1 / 2 |
0→86°, 1→78°, 2→65° |
SetMirror(v) |
/OBSBOT/WebCam/General/SetMirror |
0 / 1 |
0 not mirrored, 1 mirrored |
| Method | OSC Address | Value(s) | Notes |
|---|---|---|---|
SetTrackingMode(v) |
/OBSBOT/WebCam/Tiny/SetTrackingMode |
int | See “Tracking Modes” below |
SetAILock(v) |
/OBSBOT/WebCam/Tiny/ToggleAILock |
0 / 1 |
1 lock, 0 unlock |
SetAIMode(v) |
/OBSBOT/WebCam/Tiny/SetAiMode |
0 / 1 / 2 |
0 Headroom, 1 Standard, 2 Motion |
From the class comments:
0→ No Tracking1→ Normal Tracking- Additional modes observed in firmware/UI (naming varies by app version):
- Upper Body, Lower Body, Desk Mode, Whiteboard, Hand, Group, and possibly others.
Exact numeric mapping for all special modes can vary with firmware/app updates. Start with
0/1and then test additional integers to confirm behavior on your device/firmware. (The method accepts a single integer.)
; speed: 0–90, pan: -129–129, pitch: -59–59
cam.SetGimbal(speed, pan, pitch)| Method | OSC Address | Values (ints) | Notes |
|---|---|---|---|
SetGimbal(s,p,t) |
/OBSBOT/WebCam/General/SetGimMotorDegree |
speed, pan, pitch |
Uses sendOscMessageInts (custom DLL) |
- The class sends OSC packets over UDP to your camera (
ip,port). - Single-value commands use
sendOscMessageInt. - Multi-value commands (like
SetGimbal) usesendOscMessageInts, which is not in the stockOSC2AHK— it’s part of your customOSC2AHKv1.2.dlland enables passing more than two parameters.
- Firewall: Allow outbound UDP traffic for your script if prompted.
- IP/Port: Verify the camera’s IP and OSC/UDP port (same LAN as your PC).
- AHK Version: Use AHK 64-bit v1.1+. The syntax in this repo is v1, not v2.
- DLL loading: If the DLL fails to load, put
OSC2AHKv1.2.dllin the same folder as your script. - Value ranges: Stay within the specified ranges (e.g., gimbal angles, zoom 0–100).
- Firmware differences: Some AI/Tracking modes can shift IDs or names across updates — test on your device.
#NoEnv
#SingleInstance, Force
#Include %A_ScriptDir%\OBSBOTController.ahk
ip := "192.168.1.123"
port := 8999
cam := new OBSBOTController(ip, port)
; F1: Wake & center
F1::
cam.Wake()
cam.ResetGimbal()
return
; F2: Standard composition, normal tracking
F2::
cam.SetAIMode(1) ; Standard
cam.SetTrackingMode(1) ; Normal Tracking
return
; F3: Zoom in a bit
F3::
cam.SetZoom(60)
return
; F4: Snapshot
F4::cam.TakePhoto()
; F5: Sleep
F5::cam.Sleep().
├─ OBSBOTController.ahk ; The AHK class (this repo)
└─ OSC2AHKv1.2.dll ; Custom DLL enabling multi-param OSC (place alongside)
- Author: elModo7 / VictorDevLog
- Repo: https://github.com/elModo7/OBSBOT-Camera-Control-AHK
- Based on a custom build of
OSC2AHKthat addssendOscMessageInts. - OSC2AHK repo: Ludwig/OSC2AHK: OSC extension for Autohotkey
MIT License: https://mit-license.org/
- Keep addresses and value mappings in sync with OBSBOT app/firmware releases.
- If you add new methods, please document:
- OSC address
- Value type/range
- A short usage example
