Skip to content

Tego Bot API Documentation v0.1.1


Tego Bot



High-performance desktop automation library for Node.js. Powered by Rust for extreme speed and memory safety.


  • ๐Ÿš€ Extreme performance โ€“ Rust core optimized for maximum speed & efficiency
  • ๐Ÿ”’ Memory safe โ€“ Rust's type system guarantees memory safety
  • ๐ŸŽฏ API compatible โ€“ Similar API design to robotjs for easy migration
  • ๐ŸŒ Cross-platform โ€“ Supports Windows, macOS, and Linux
  • ๐Ÿ“ฆ Zero dependencies โ€“ No additional Node.js dependencies required
  • ๐Ÿงช Well tested โ€“ Comprehensive test coverage

๐Ÿš€ Quick Start โ€‹

You can add Tego Bot to your project via the @tego/botjs package:

bash
pnpm add @tego/botjs

# Or: npm/yarn/bun add @tego/botjs

Minimal Example โ€‹

ts
import { moveMouse, mouseClick, keyTap, typeString, captureScreen } from '@tego/botjs';

// Move mouse and click
moveMouse(100, 200);
mouseClick('left');

// Type text
typeString('Hello from Tego Bot!');
keyTap('enter');

// Capture screen
const screenshot = await captureScreen();
// screenshot.image contains PNG buffer

๐Ÿ“– API Documentation โ€‹

Mouse Operations โ€‹

ts
import { moveMouse, moveMouseSmooth, mouseClick, getMousePos, dragMouse, scrollMouse } from '@tego/botjs';

// Move mouse to coordinates
moveMouse(100, 200);

// Smooth movement
moveMouseSmooth(300, 400);
moveMouseSmooth(500, 600, 5.0); // with custom speed

// Click
mouseClick('left');           // Left click
mouseClick('right', true);    // Right double click
mouseClick('middle');         // Middle click

// Get mouse position
const pos = getMousePos();
console.log(`Mouse at: ${pos.x}, ${pos.y}`);

// Drag
dragMouse(500, 600);

// Scroll
scrollMouse(0, 3);  // Scroll down
scrollMouse(2, 0);  // Scroll right

Keyboard Operations โ€‹

ts
import { keyTap, keyToggle, typeString, typeStringDelayed, unicodeTap } from '@tego/botjs';

// Tap a key
keyTap('a');
keyTap('enter');
keyTap('c', ['control']);        // Ctrl+C
keyTap('v', ['control', 'shift']); // Ctrl+Shift+V

// Toggle key
keyToggle('a', 'down');  // Press 'a'
keyToggle('a', 'up');    // Release 'a'

// Type text
typeString('Hello, World!');

// Type with delay (characters per minute)
typeStringDelayed('Hello', 300); // 300 CPM

// Tap Unicode character
unicodeTap(0x1F600); // ๐Ÿ˜€

Screen Operations โ€‹

ts
import { captureScreen, captureScreenRegion, getScreenSize, getPixelColor, screen } from '@tego/botjs';
import fs from 'fs';

// Capture entire screen
const screenshot = await captureScreen();
fs.writeFileSync('screenshot.png', screenshot.image);

// Capture region
const region = await captureScreenRegion(100, 100, 800, 600);
fs.writeFileSync('region.png', region.image);

// Get screen size
const size = getScreenSize();
console.log(`Screen: ${size.width}x${size.height}`);

// Get pixel color (returns hex string)
const color = await getPixelColor(100, 200);
console.log(`Color: ${color}`); // e.g., "#FF0000"

// Using screen object
const bitmap = await screen.capture(0, 0, 800, 600);
const pixelColor = bitmap.colorAt(100, 200);

Configuration โ€‹

ts
import { setMouseDelay, setKeyboardDelay, updateScreenMetrics } from '@tego/botjs';

// Set delays (in milliseconds)
setMouseDelay(50);
setKeyboardDelay(10);

// Update screen metrics (refresh monitor information)
updateScreenMetrics();

๐ŸŽฏ Supported Keys โ€‹

Modifier Keys โ€‹

  • control / ctrl โ€“ Control key
  • shift โ€“ Shift key
  • alt โ€“ Alt key
  • command / cmd / meta โ€“ Command/Meta key

Function Keys โ€‹

  • f1 โ€“ f12 โ€“ F1 to F12

Special Keys โ€‹

  • enter / return โ€“ Enter key
  • escape / esc โ€“ ESC key
  • backspace โ€“ Backspace key
  • tab โ€“ Tab key
  • space โ€“ Space key
  • delete / del โ€“ Delete key
  • up / down / left / right โ€“ Arrow keys
  • home / end โ€“ Home/End keys
  • pageup / page_down โ€“ Page Up/Down keys

Mouse Buttons โ€‹

  • left โ€“ Left button
  • right โ€“ Right button
  • middle โ€“ Middle button

๐Ÿ› ๏ธ Building โ€‹

To build the library from source:

bash
# Install dependencies
pnpm install

# Build Rust code and generate Node.js bindings
pnpm build

# Or build only Rust code
pnpm rs:build

๐Ÿ“‹ System Requirements โ€‹

macOS โ€‹

  • macOS 10.13+
  • Screen recording permission required (System Preferences > Security & Privacy > Screen Recording)

Windows โ€‹

  • Windows 10+
  • No additional configuration needed

Linux โ€‹

  • X11 or Wayland
  • May require system dependencies:
    bash
    # Ubuntu/Debian
    sudo apt-get install libxcb1-dev libxrandr-dev libdbus-1-dev
    
    # Fedora
    sudo dnf install libxcb-devel libXrandr-devel dbus-devel

๐Ÿงช Testing โ€‹

bash
# Run Rust tests
pnpm test

# Build and test Node.js bindings
pnpm build

๐Ÿ“Š Comparison with robotjs โ€‹

FeaturerobotjsTego Bot (@tego/botjs)
PerformanceMedium (C++ bindings)โšก Extremely high (Rust native)
MaintenanceโŒ No longer maintainedโœ… Actively maintained
Memory Safetyโš ๏ธ C++โœ… Rust
API Designโœ… Simpleโœ… Compatible
Cross-platformโœ…โœ…
Type Safetyโš ๏ธ Runtime checksโœ… Compile-time guarantees

๐Ÿ“„ License โ€‹

Licensed under the MIT License.


๐Ÿค Contributing โ€‹

Contributions are welcome! Please feel free to submit a Pull Request.


Released under the MIT License.