MCPcopy Create free account
hub / github.com/e2b-dev/desktop / main

Function main

packages/python-sdk/example.py:13–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11
12
13async def main():
14 print("Starting desktop sandbox...")
15
16 print("--> Sandbox creation time", end="")
17 start_time = time.time()
18 desktop = Sandbox.create()
19 end_time = time.time()
20 print(f": {end_time - start_time:.3f}s")
21
22 print("Desktop Sandbox started, ID:", desktop.sandbox_id)
23 screen_size = desktop.get_screen_size()
24 print("Screen size:", screen_size)
25
26 desktop.stream.start(require_auth=True)
27
28 auth_key = desktop.stream.get_auth_key()
29 print("Stream URL:", desktop.stream.get_url(auth_key=auth_key))
30
31 await asyncio.sleep(5)
32
33 print("Moving mouse to 'Applications' and clicking...")
34 desktop.move_mouse(100, 100)
35 desktop.left_click()
36 cursor_position = desktop.get_cursor_position()
37 print("Cursor position:", cursor_position)
38
39 await asyncio.sleep(1)
40
41 screenshot = desktop.screenshot("bytes")
42 with open("1.png", "wb") as f:
43 f.write(screenshot)
44
45 for i in range(20):
46 x = math.floor(random.random() * 1024)
47 y = math.floor(random.random() * 768)
48 desktop.move_mouse(x, y)
49 await asyncio.sleep(2)
50 desktop.right_click()
51 print("right clicked", i)
52
53 desktop.stream.stop()
54 desktop.kill()
55
56
57if __name__ == "__main__":

Callers 1

example.pyFile · 0.70

Calls 12

get_screen_sizeMethod · 0.80
get_auth_keyMethod · 0.80
get_urlMethod · 0.80
move_mouseMethod · 0.80
left_clickMethod · 0.80
get_cursor_positionMethod · 0.80
right_clickMethod · 0.80
createMethod · 0.45
startMethod · 0.45
screenshotMethod · 0.45
writeMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected