Skip to main content

Sandbox

create

Create a new sandbox. By default, the sandbox is created from the default desktop sandbox template. Arguments:
  • template: Sandbox template name or ID
  • resolution: Startup the desktop with custom screen resolution. Defaults to (1024, 768)
  • dpi: Startup the desktop with custom DPI. Defaults to 96
  • display: Startup the desktop with custom display. Defaults to “:0”
  • timeout: Timeout for the sandbox in seconds, default to 300 seconds. The maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
  • metadata: Custom metadata for the sandbox
  • envs: Custom environment variables for the sandbox
  • secure: Envd is secured with access token and cannot be used without it
  • allow_internet_access: Allow sandbox to access the internet, defaults to True.
Returns: A Sandbox instance for the new sandbox Use this method instead of using the constructor to create a new sandbox.

beta_create

[BETA] This feature is in beta and may change in the future. Create a new sandbox. By default, the sandbox is created from the default desktop sandbox template. Arguments:
  • template: Sandbox template name or ID
  • resolution: Startup the desktop with custom screen resolution. Defaults to (1024, 768)
  • dpi: Startup the desktop with custom DPI. Defaults to 96
  • display: Startup the desktop with custom display. Defaults to “:0”
  • timeout: Timeout for the sandbox in seconds, default to 300 seconds. The maximum time a sandbox can be kept alive is 24 hours (86_400 seconds) for Pro users and 1 hour (3_600 seconds) for Hobby users.
  • auto_pause: Automatically pause the sandbox after the timeout expires. Defaults to False.
  • metadata: Custom metadata for the sandbox
  • envs: Custom environment variables for the sandbox
  • secure: Envd is secured with access token and cannot be used without it
  • allow_internet_access: Allow sandbox to access the internet, defaults to True.
Returns: A Sandbox instance for the new sandbox Use this method instead of using the constructor to create a new sandbox.

screenshot

Take a screenshot and return it as a stream of bytes.

screenshot

Take a screenshot and return it as a bytearray.

screenshot

Take a screenshot and return it in the specified format. Arguments:
  • format: The format of the screenshot. Can be ‘bytes’, ‘blob’, or ‘stream’.
Returns: The screenshot in the specified format.

left_click

Left click on the mouse position.

double_click

Double left click on the mouse position.

middle_click

Middle click on the mouse position.

scroll

Scroll the mouse wheel by the given amount. Arguments:
  • direction: The direction to scroll. Can be “up” or “down”.
  • amount: The amount to scroll.

move_mouse

Move the mouse to the given coordinates. Arguments:
  • x: The x coordinate.
  • y: The y coordinate.

mouse_press

Press the mouse button.

mouse_release

Release the mouse button.

get_cursor_position

Get the current cursor position. Raises:
  • RuntimeError: If the cursor position cannot be determined
Returns: A tuple with the x and y coordinates

get_screen_size

Get the current screen size. Raises:
  • RuntimeError: If the screen size cannot be determined
Returns: A tuple with the width and height

write

Write the given text at the current cursor position. Arguments:
  • text: The text to write.
  • chunk_size: The size of each chunk of text to write.
  • delay_in_ms: The delay between each chunk of text.

press

Press a key. Arguments:
  • key: The key to press (e.g. “enter”, “space”, “backspace”, etc.).

drag

Drag the mouse from the given position to the given position. Arguments:
  • from: The starting position.
  • to: The ending position.

wait

Wait for the given amount of time. Arguments:
  • ms: The amount of time to wait in milliseconds.

open

Open a file or a URL in the default application. Arguments:
  • file_or_url: The file or URL to open.

get_current_window_id

Get the current window ID.

get_application_windows

Get the window IDs of all windows for the given application.

get_window_title

Get the title of the window with the given ID.

launch

Launch an application.