---
title: Commands
description: Computer commands and interface methods
---

This page describes the set of supported **commands** you can use to control a Cua Computer directly via the Python SDK.

These commands map to the same actions available in the [Computer Server API Commands Reference](../libraries/computer-server/Commands), and provide low-level, async access to system operations from your agent or automation code.

## Shell Actions

Execute shell commands and get detailed results:

<Tabs items={['Python', 'TypeScript']}>
  <Tab value="Python">

    ```python
    # Run shell command
    result = await computer.interface.run_command(cmd) # result.stdout, result.stderr, result.returncode
    ```

  </Tab>
  <Tab value="TypeScript">

    ```typescript
    // Run shell command
    const result = await computer.interface.runCommand(cmd); // result.stdout, result.stderr, result.returncode
    ```

  </Tab>
</Tabs>

## Window Management

Control application launching and windows:

<Tabs items={['Python', 'TypeScript']}>
  <Tab value="Python">

    ```python
    # Launch applications
    await computer.interface.launch("xfce4-terminal")
    await computer.interface.launch("libreoffice --writer")
    await computer.interface.open("https://www.google.com")

    # Window management
    windows = await computer.interface.get_application_windows("xfce4-terminal")
    window_id = windows[0]
    await computer.interface.activate_window(window_id)

    window_id = await computer.interface.get_current_window_id()  # get the current active window id
    await computer.interface.window_size(window_id)
    await computer.interface.get_window_title(window_id)
    await computer.interface.get_window_position(window_id)
    await computer.interface.set_window_size(window_id, 1200, 800)
    await computer.interface.set_window_position(window_id, 100, 100)
    await computer.interface.maximize_window(window_id)
    await computer.interface.minimize_window(window_id)
    await computer.interface.close_window(window_id)
    ```

  </Tab>
  <Tab value="TypeScript">

    ```typescript
    // Launch applications
    await computer.interface.launch("xfce4-terminal");
    await computer.interface.launch("libreoffice --writer");
    await computer.interface.open("https://www.google.com");

    // Window management
    const windows = await computer.interface.getApplicationWindows("xfce4-terminal");
    let windowId = windows[0];
    await computer.interface.activateWindow(windowId);

    windowId = await computer.interface.getCurrentWindowId(); // current active window id
    await computer.interface.getWindowSize(windowId);
    await computer.interface.getWindowName(windowId);
    await computer.interface.getWindowPosition(windowId);
    await computer.interface.setWindowSize(windowId, 1200, 800);
    await computer.interface.setWindowPosition(windowId, 100, 100);
    await computer.interface.maximizeWindow(windowId);
    await computer.interface.minimizeWindow(windowId);
    await computer.interface.closeWindow(windowId);
    ```

  </Tab>
</Tabs>

## Mouse Actions

Precise mouse control and interaction:

<Tabs items={['Python', 'TypeScript']}>
  <Tab value="Python">

    ```python
    # Basic clicks
    await computer.interface.left_click(x, y)       # Left click at coordinates
    await computer.interface.right_click(x, y)      # Right click at coordinates
    await computer.interface.double_click(x, y)     # Double click at coordinates

    # Cursor movement and dragging
    await computer.interface.move_cursor(x, y)      # Move cursor to coordinates
    await computer.interface.drag_to(x, y, duration)  # Drag to coordinates
    await computer.interface.get_cursor_position()  # Get current cursor position

    # Advanced mouse control
    await computer.interface.mouse_down(x, y, button="left")  # Press and hold a mouse button
    await computer.interface.mouse_up(x, y, button="left")    # Release a mouse button
    ```

  </Tab>
  <Tab value="TypeScript">

    ```typescript
    // Basic clicks
    await computer.interface.leftClick(x, y);       // Left click at coordinates
    await computer.interface.rightClick(x, y);      // Right click at coordinates
    await computer.interface.doubleClick(x, y);     // Double click at coordinates

    // Cursor movement and dragging
    await computer.interface.moveCursor(x, y);      // Move cursor to coordinates
    await computer.interface.dragTo(x, y, duration);  // Drag to coordinates
    await computer.interface.getCursorPosition();  // Get current cursor position

    // Advanced mouse control
    await computer.interface.mouseDown(x, y, "left");  // Press and hold a mouse button
    await computer.interface.mouseUp(x, y, "left");    // Release a mouse button
    ```

  </Tab>
</Tabs>

## Keyboard Actions

Text input and key combinations:

<Tabs items={['Python', 'TypeScript']}>
  <Tab value="Python">

    ```python
    # Text input
    await computer.interface.type_text("Hello")     # Type text
    await computer.interface.press_key("enter")     # Press a single key

    # Key combinations and advanced control
    await computer.interface.hotkey("command", "c") # Press key combination
    await computer.interface.key_down("command")    # Press and hold a key
    await computer.interface.key_up("command")      # Release a key
    ```

  </Tab>
  <Tab value="TypeScript">

    ```typescript
    // Text input
    await computer.interface.typeText("Hello");     // Type text
    await computer.interface.pressKey("enter");     // Press a single key

    // Key combinations and advanced control
    await computer.interface.hotkey("command", "c"); // Press key combination
    await computer.interface.keyDown("command");    // Press and hold a key
    await computer.interface.keyUp("command");      // Release a key
    ```

  </Tab>
</Tabs>

## Scrolling Actions

Mouse wheel and scrolling control:

<Tabs items={['Python', 'TypeScript']}>
  <Tab value="Python">

    ```python
    # Scrolling
    await computer.interface.scroll(x, y) # Scroll the mouse wheel
    await computer.interface.scroll_down(clicks) # Scroll down
    await computer.interface.scroll_up(clicks) # Scroll up
    ```

  </Tab>
  <Tab value="TypeScript">

    ```typescript
    // Scrolling
    await computer.interface.scroll(x, y); // Scroll the mouse wheel
    await computer.interface.scrollDown(clicks); // Scroll down
    await computer.interface.scrollUp(clicks); // Scroll up
    ```

  </Tab>
</Tabs>

## Screen Actions

Screen capture and display information:

<Tabs items={['Python', 'TypeScript']}>
  <Tab value="Python">

    ```python
    # Screen operations
    await computer.interface.screenshot() # Take a screenshot
    await computer.interface.get_screen_size() # Get screen dimensions
    ```

  </Tab>
  <Tab value="TypeScript">

    ```typescript
    // Screen operations
    await computer.interface.screenshot(); // Take a screenshot
    await computer.interface.getScreenSize(); // Get screen dimensions
    ```

  </Tab>
</Tabs>

## Desktop Actions

Control desktop environment features like wallpaper:

<Tabs items={['Python', 'TypeScript']}>
  <Tab value="Python">
    ```python 
    # Get current desktop environment (e.g., 'xfce4', 'gnome', 'kde', 'mac', 'windows')
    env = await computer.interface.get_desktop_environment()
    print(env) # "xfce4"

    # Set desktop wallpaper to an image file accessible on the sandbox
    await computer.interface.set_wallpaper("/home/cua/shared/wallpaper.png")
    ```

  </Tab>
  <Tab value="TypeScript">
    ```typescript 
    // Get current desktop environment
    const env = await computer.interface.getDesktopEnvironment();
    print(env) # "xfce4"

    // Set desktop wallpaper to an image file accessible on the sandbox
    await computer.interface.setWallpaper('/home/cua/shared/wallpaper.png');
    ```

  </Tab>
</Tabs>

## Clipboard Actions

System clipboard management:

<Tabs items={['Python', 'TypeScript']}>
  <Tab value="Python">

    ```python
    # Clipboard operations
    await computer.interface.set_clipboard(text) # Set clipboard content
    await computer.interface.copy_to_clipboard() # Get clipboard content
    ```

  </Tab>
  <Tab value="TypeScript">

    ```typescript
    // Clipboard operations
    await computer.interface.setClipboard(text); // Set clipboard content
    await computer.interface.copyToClipboard(); // Get clipboard content
    ```

  </Tab>
</Tabs>

## File System Operations

Direct file and directory manipulation:

<Tabs items={['Python', 'TypeScript']}>
  <Tab value="Python">

    ```python
    # File existence checks
    await computer.interface.file_exists(path)      # Check if file exists
    await computer.interface.directory_exists(path) # Check if directory exists

    # File content operations
    await computer.interface.read_text(path, encoding="utf-8")        # Read file content
    await computer.interface.write_text(path, content, encoding="utf-8") # Write file content
    await computer.interface.read_bytes(path)       # Read file content as bytes
    await computer.interface.write_bytes(path, content) # Write file content as bytes

    # File and directory management
    await computer.interface.delete_file(path)      # Delete file
    await computer.interface.create_dir(path)       # Create directory
    await computer.interface.delete_dir(path)       # Delete directory
    await computer.interface.list_dir(path)         # List directory contents
    ```

  </Tab>
  <Tab value="TypeScript">

    ```typescript
    // File existence checks
    await computer.interface.fileExists(path);      // Check if file exists
    await computer.interface.directoryExists(path); // Check if directory exists

    // File content operations
    await computer.interface.readText(path, "utf-8");        // Read file content
    await computer.interface.writeText(path, content, "utf-8"); // Write file content
    await computer.interface.readBytes(path);       // Read file content as bytes
    await computer.interface.writeBytes(path, content); // Write file content as bytes

    // File and directory management
    await computer.interface.deleteFile(path);      // Delete file
    await computer.interface.createDir(path);       // Create directory
    await computer.interface.deleteDir(path);       // Delete directory
    await computer.interface.listDir(path);         // List directory contents
    ```

  </Tab>
</Tabs>

## Accessibility

Access system accessibility information:

<Tabs items={['Python', 'TypeScript']}>
  <Tab value="Python">

    ```python
    # Get accessibility tree
    await computer.interface.get_accessibility_tree()
    ```

  </Tab>
  <Tab value="TypeScript">

    ```typescript
    // Get accessibility tree
    await computer.interface.getAccessibilityTree();
    ```

  </Tab>
</Tabs>

## Delay Configuration

Control timing between actions:

<Tabs items={['Python']}>
  <Tab value="Python">

    ```python
    # Set default delay between all actions (in seconds)
    computer.interface.delay = 0.5  # 500ms delay between actions

    # Or specify delay for individual actions
    await computer.interface.left_click(x, y, delay=1.0)     # 1 second delay after click
    await computer.interface.type_text("Hello", delay=0.2)   # 200ms delay after typing
    await computer.interface.press_key("enter", delay=0.5)   # 500ms delay after key press
    ```

  </Tab>
</Tabs>

## Python Virtual Environment Operations

Manage Python environments:

<Tabs items={['Python']}>
  <Tab value="Python">

    ```python
    # Virtual environment management
    await computer.venv_install("demo_venv", ["requests", "macos-pyxa"]) # Install packages in a virtual environment
    await computer.venv_cmd("demo_venv", "python -c 'import requests; print(requests.get(`https://httpbin.org/ip`).json())'') # Run a shell command in a virtual environment
    await computer.venv_exec("demo_venv", python_function_or_code, *args, **kwargs) # Run a Python function in a virtual environment and return the result / raise an exception
    ```

  </Tab>
</Tabs>
