Skip to main content
ComputerBox runs a full Linux desktop (XFCE) inside an isolated VM and gives you programmatic control over the screen, mouse, and keyboard. Use it when you need GUI automation — filling out forms, testing desktop apps, or driving tools that don’t have a CLI.
Need browser automation only? Use BrowserBox instead — it’s lighter and gives you direct Playwright/Puppeteer access without a full desktop.

What you’ll build

A script that:
  1. Launches a ComputerBox with a GUI desktop
  2. Takes a screenshot
  3. Uses the mouse and keyboard to interact with the desktop
  4. Automates a complete workflow: open a text editor, type content, and save

Prerequisites

Requires Python 3.10+.

Step 1: Launch and take a screenshot

Create a ComputerBox, wait for the desktop to be ready, and capture a screenshot.
screenshot.py
What’s happening:
  • ComputerBox boots a VM with the lscr.io/linuxserver/webtop:ubuntu-xfce image — a full Ubuntu desktop with XFCE
  • wait_until_ready() blocks until the desktop environment is loaded and responsive
  • screenshot() returns a base64-encoded PNG with the current screen contents

Step 2: Mouse interaction

Move the cursor, click, double-click, and drag.
mouse.py

Mouse methods reference

Step 3: Keyboard input

Type text and press key combinations.
keyboard.py

Key syntax reference (xdotool format)

The key() method uses xdotool key syntax:

Step 4: Automate a full workflow

Put it all together — open a text editor, type content, save the file, and verify with a screenshot.
workflow.py
You can also view the desktop live in your browser at http://localhost:3000 (or whatever port you set with gui_http_port). This is helpful for debugging automation scripts — watch what’s happening in real time while your code runs.

Constructor options

What’s next?

Automate a browser

Use BrowserBox for browser-only automation with Playwright or Puppeteer — lighter than a full desktop.

Handle errors and debug

Catch exceptions, handle timeouts, and debug failures in your automation scripts.

ComputerBox API reference

Full API docs for all mouse, keyboard, and display methods.

Connect to an LLM

Give an LLM the ability to control a desktop by wiring up ComputerBox to function calling.