Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
added correct example
Dillon DuPont22fb3208558a
diff --git a/examples/computer_examples.py b/examples/computer_examples.pyindex e3266049b2..34dd8c5bbd 100644--- a/examples/computer_examples.py+++ b/examples/computer_examples.py@@ -42,17 +42,28 @@ async def main():ephemeral=False,)+ # computer = Computer(+ # os_type="linux",+ # api_key=os.getenv("CUA_API_KEY"),+ # name=os.getenv("VM_NAME"),+ # provider_type=VMProviderType.CLOUD,+ # )+try:# Run the computer with default parametersawait computer.run()- await computer.interface.hotkey("command", "space")+ screenshot = await computer.interface.screenshot()+ with open(Path("~/cua/examples/screenshot.png").expanduser(), "wb") as f:+ f.write(screenshot)++ # await computer.interface.hotkey("command", "space")# res = await computer.interface.run_command("touch ./Downloads/empty_file")# print(f"Run command result: {res}")- accessibility_tree = await computer.interface.get_accessibility_tree()- print(f"Accessibility tree: {accessibility_tree}")+ # accessibility_tree = await computer.interface.get_accessibility_tree()+ # print(f"Accessibility tree: {accessibility_tree}")# Screen Actions Examples# print("\n=== Screen Actions ===")@@ -60,36 +71,36 @@ async def main():# with open("screenshot_direct.png", "wb") as f:# f.write(screenshot)- screen_size = await computer.interface.get_screen_size()- print(f"Screen size: {screen_size}")+ # screen_size = await computer.interface.get_screen_size()+ # print(f"Screen size: {screen_size}")# Demonstrate coordinate conversion- center_x, center_y = 733, 736- print(f"Center in screen coordinates: ({center_x}, {center_y})")+ # center_x, center_y = 733, 736+ # print(f"Center in screen coordinates: ({center_x}, {center_y})")- screenshot_center = await computer.to_screenshot_coordinates(center_x, center_y)- print(f"Center in screenshot coordinates: {screenshot_center}")+ # screenshot_center = await computer.to_screenshot_coordinates(center_x, center_y)+ # print(f"Center in screenshot coordinates: {screenshot_center}")- screen_center = await computer.to_screen_coordinates(*screenshot_center)- print(f"Back to screen coordinates: {screen_center}")+ # screen_center = await computer.to_screen_coordinates(*screenshot_center)+ # print(f"Back to screen coordinates: {screen_center}")# Mouse Actions Examples- print("\n=== Mouse Actions ===")- await computer.interface.move_cursor(100, 100)- await computer.interface.left_click()- await computer.interface.right_click(300, 300)- await computer.interface.double_click(400, 400)-- # Keyboard Actions Examples- print("\n=== Keyboard Actions ===")- await computer.interface.type_text("Hello, World!")- await computer.interface.press_key("enter")-- # Clipboard Actions Examples- print("\n=== Clipboard Actions ===")- await computer.interface.set_clipboard("Test clipboard")- content = await computer.interface.copy_to_clipboard()- print(f"Clipboard content: {content}")+ # print("\n=== Mouse Actions ===")+ # await computer.interface.move_cursor(100, 100)+ # await computer.interface.left_click()+ # await computer.interface.right_click(300, 300)+ # await computer.interface.double_click(400, 400)++ # # Keyboard Actions Examples+ # print("\n=== Keyboard Actions ===")+ # await computer.interface.type_text("Hello, World!")+ # await computer.interface.press_key("enter")++ # # Clipboard Actions Examples+ # print("\n=== Clipboard Actions ===")+ # await computer.interface.set_clipboard("Test clipboard")+ # content = await computer.interface.copy_to_clipboard()+ # print(f"Clipboard content: {content}")finally:# Important to clean up resources