Sandbox

Methods

doubleClick()

doubleClick(): Promise<CommandResult>

Double left click on the current mouse position.

Returns

Promise<CommandResult>

getCursorPosition()

getCursorPosition(): Promise<object>

Get the current mouse position.

Returns

Promise<object>

An object with x and y coordinates.

NameType
xnumber
ynumber

getScreenSize()

getScreenSize(): Promise<object>

Get the current screen size.

Returns

Promise<object>

An object with width and height properties.

NameType
heightnumber
widthnumber

getVideoStreamUrl()

getVideoStreamUrl(): Promise<string>
Returns

Promise<string>

hotkey()

hotkey(...keys: string[]): Promise<CommandResult>

Press a hotkey.

Parameters
ParameterTypeDescription
...keysstring[]The keys to press (e.g. hotkey("ctrl", "c") will press Ctrl+C).
Returns

Promise<CommandResult>

leftClick()

leftClick(): Promise<CommandResult>

Left click on the current mouse position.

Returns

Promise<CommandResult>

middleClick()

middleClick(): Promise<CommandResult>

Middle click on the current mouse position.

Returns

Promise<CommandResult>

moveMouse()

moveMouse(x: number, y: number): Promise<CommandResult>

Move the mouse to the given coordinates.

Parameters
ParameterTypeDescription
xnumberThe x coordinate.
ynumberThe y coordinate.
Returns

Promise<CommandResult>

open()

open(fileOrUrl: string): Promise<CommandHandle>

Open a file or a URL in the default application. Note that you'll need to wait for the application to be opened.

Parameters
ParameterTypeDescription
fileOrUrlstringThe file or URL to open.
Returns

Promise<CommandHandle>

press()

press(key: string): Promise<CommandResult>

Press a key.

Parameters
ParameterTypeDescription
keystringThe key to press (e.g. "enter", "space", "backspace", etc.).
Returns

Promise<CommandResult>

rightClick()

rightClick(): Promise<CommandResult>

Right click on the current mouse position.

Returns

Promise<CommandResult>

runPyautoguiCode()

runPyautoguiCode(code: string, opts: object): Promise<CommandResult>

Run the given Python code that uses pyautogui.

Parameters
ParameterType
codestring
optsobject
opts.onStderr?(data: string) => void
opts.onStdout?(data: string) => void
Returns

Promise<CommandResult>

scroll()

scroll(amount: number): Promise<CommandResult>

Scroll the mouse wheel by the given amount.

Parameters
ParameterTypeDescription
amountnumberThe amount to scroll.
Returns

Promise<CommandResult>

takeScreenshot()

takeScreenshot()
takeScreenshot(): Promise<Uint8Array>

Take a screenshot and save it to the given name.

Returns

Promise<Uint8Array>

A Uint8Array bytes representation of the screenshot.

takeScreenshot(format)
takeScreenshot(format: "bytes"): Promise<Uint8Array>

Take a screenshot and save it to the given name.

Parameters
ParameterTypeDescription
format"bytes"The format of the screenshot.
Returns

Promise<Uint8Array>

A Uint8Array bytes representation of the screenshot.

takeScreenshot(format)
takeScreenshot(format: "blob"): Promise<Blob>

Take a screenshot and save it to the given name.

Parameters
ParameterType
format"blob"
Returns

Promise<Blob>

A Blob representation of the screenshot.

takeScreenshot(format)
takeScreenshot(format: "stream"): Promise<ReadableStream<Uint8Array>>

Take a screenshot and save it to the given name.

Parameters
ParameterType
format"stream"
Returns

Promise<ReadableStream<Uint8Array>>

A ReadableStream of bytes representation of the screenshot.

write()

write(text: string): Promise<CommandResult>

Write the given text at the current cursor position.

Parameters
ParameterTypeDescription
textstringThe text to write.
Returns

Promise<CommandResult>

create()

create(this, opts)
static create<S>(this: S, opts?: SandboxOpts): Promise<InstanceType<S>>

Create a new sandbox from the default desktop sandbox template.

Type Parameters
Type Parameter
S extends typeof Sandbox
Parameters
ParameterTypeDescription
thisS-
opts?SandboxOptsconnection options.
Returns

Promise<InstanceType<S>>

sandbox instance for the new sandbox.

Example
const sandbox = await Sandbox.create()
Constructs

Sandbox

create(this, template, opts)
static create<S>(
   this: S, 
   template: string, 
opts?: SandboxOpts): Promise<InstanceType<S>>

Create a new sandbox from the specified sandbox template.

Type Parameters
Type Parameter
S extends typeof Sandbox
Parameters
ParameterTypeDescription
thisS-
templatestringsandbox template name or ID.
opts?SandboxOptsconnection options.
Returns

Promise<InstanceType<S>>

sandbox instance for the new sandbox.

Example
const sandbox = await Sandbox.create('<template-name-or-id>')
Constructs

Sandbox

Interfaces

SandboxOpts

Properties

onVideoStreamStart()?

optional onVideoStreamStart: (url: string) => void;
Parameters
ParameterType
urlstring
Returns

void

videoStream?

optional videoStream: boolean;