vboxweb

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package vboxweb performs absolute mouse clicks against a running VM by talking SOAP to the VirtualBox web service (vboxwebsrv). This replaces the upstream project's Python (vboxapi) helper, keeping the server a single Go binary with no external runtime.

VBoxManage has no CLI command for mouse events, so the Main API is the only way to drive the guest pointer. Reaching it from Go without cgo/XPCOM means using the web service. The service is started automatically on demand the first time a mouse click is needed (see ensureStarted); no manual setup is required in the default configuration.

Configuration via environment:

VBOXWEB_ENDPOINT    service URL (default http://127.0.0.1:18083/)
VBOXWEB_USER        logon username (default empty -> anonymous/null auth)
VBOXWEB_PASSWORD    logon password (default empty)
VBOXWEB_AUTOSTART   "false" to disable auto-starting vboxwebsrv
VBOXWEB_BIN         path to the vboxwebsrv binary (else derived/PATH)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client talks to a vboxwebsrv SOAP endpoint and can start the service on demand.

func NewFromEnv

func NewFromEnv(timeout time.Duration, vboxManagePath string) *Client

NewFromEnv builds a Client from the VBOXWEB_* environment variables. vboxManagePath is used to locate vboxwebsrv (installed alongside it) and to set the web service to anonymous auth on first auto-start.

func (*Client) Click

func (c *Client) Click(ctx context.Context, vm string, x, y int, button string, double bool) error

Click moves the absolute pointer to (x, y) and presses/releases button. When double is true it issues a second press/release. The VM must have USB tablet mouse mode enabled (vm_create does this) for absolute positioning to work.

If the web service is unreachable and autostart is enabled, Click starts vboxwebsrv on demand and retries once.

func (*Client) Drag

func (c *Client) Drag(ctx context.Context, vm string, x1, y1, x2, y2 int, button string) error

Drag presses button at (x1, y1), moves to (x2, y2) in steps while held, then releases. Intermediate moves make the drag register with the guest.

func (*Client) Move

func (c *Client) Move(ctx context.Context, vm string, x, y int) error

Move positions the absolute pointer at (x, y) without pressing any button.

func (*Client) Scroll

func (c *Client) Scroll(ctx context.Context, vm string, x, y, dz, dw int) error

Scroll positions the pointer at (x, y) and turns the wheel: dz is the vertical wheel delta (positive = up, negative = down), dw the horizontal delta.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL