()
| 11 | |
| 12 | |
| 13 | async 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 | |
| 57 | if __name__ == "__main__": |
no test coverage detected