Class: Daytona::ComputerUse::Mouse
- Inherits:
-
Object
- Object
- Daytona::ComputerUse::Mouse
- Includes:
- Instrumentation
- Defined in:
- lib/daytona/computer_use.rb
Instance Attribute Summary collapse
-
#sandbox_id ⇒ String
readonly
The ID of the sandbox.
-
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi
readonly
API client for sandbox operations.
Instance Method Summary collapse
-
#click(x:, y:, button: 'left', double: false) ⇒ DaytonaToolboxApiClient::MouseClickResponse
Clicks the mouse at the specified coordinates.
-
#drag(start_x:, start_y:, end_x:, end_y:, button: 'left') ⇒ DaytonaToolboxApiClient::MouseDragResponse
Drags the mouse from start coordinates to end coordinates.
-
#initialize(sandbox_id:, toolbox_api:, otel_state: nil) ⇒ Mouse
constructor
A new instance of Mouse.
-
#move(x:, y:) ⇒ DaytonaToolboxApiClient::MouseMoveResponse
Moves the mouse cursor to the specified coordinates.
-
#position ⇒ DaytonaToolboxApiClient::MousePosition
Gets the current mouse cursor position.
-
#scroll(x:, y:, direction:, amount: 1) ⇒ Boolean
Scrolls the mouse wheel at the specified coordinates.
Methods included from Instrumentation
Constructor Details
#initialize(sandbox_id:, toolbox_api:, otel_state: nil) ⇒ Mouse
Returns a new instance of Mouse.
17 18 19 20 21 |
# File 'lib/daytona/computer_use.rb', line 17 def initialize(sandbox_id:, toolbox_api:, otel_state: nil) @sandbox_id = sandbox_id @toolbox_api = toolbox_api @otel_state = otel_state end |
Instance Attribute Details
#sandbox_id ⇒ String (readonly)
Returns The ID of the sandbox.
9 10 11 |
# File 'lib/daytona/computer_use.rb', line 9 def sandbox_id @sandbox_id end |
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi (readonly)
Returns API client for sandbox operations.
12 13 14 |
# File 'lib/daytona/computer_use.rb', line 12 def toolbox_api @toolbox_api end |
Instance Method Details
#click(x:, y:, button: 'left', double: false) ⇒ DaytonaToolboxApiClient::MouseClickResponse
Clicks the mouse at the specified coordinates.
72 73 74 75 76 77 |
# File 'lib/daytona/computer_use.rb', line 72 def click(x:, y:, button: 'left', double: false) request = DaytonaToolboxApiClient::MouseClickRequest.new(x:, y:, button:, double:) toolbox_api.click(request) rescue StandardError => e raise Sdk::Error, "Failed to click mouse: #{e.}" end |
#drag(start_x:, start_y:, end_x:, end_y:, button: 'left') ⇒ DaytonaToolboxApiClient::MouseDragResponse
Drags the mouse from start coordinates to end coordinates.
92 93 94 95 96 97 |
# File 'lib/daytona/computer_use.rb', line 92 def drag(start_x:, start_y:, end_x:, end_y:, button: 'left') request = DaytonaToolboxApiClient::MouseDragRequest.new(start_x:, start_y:, end_x:, end_y:, button:) toolbox_api.drag(request) rescue StandardError => e raise Sdk::Error, "Failed to drag mouse: #{e.}" end |
#move(x:, y:) ⇒ DaytonaToolboxApiClient::MouseMoveResponse
Moves the mouse cursor to the specified coordinates.
47 48 49 50 51 52 |
# File 'lib/daytona/computer_use.rb', line 47 def move(x:, y:) request = DaytonaToolboxApiClient::MouseMoveRequest.new(x:, y:) toolbox_api.move_mouse(request) rescue StandardError => e raise Sdk::Error, "Failed to move mouse: #{e.}" end |
#position ⇒ DaytonaToolboxApiClient::MousePosition
Gets the current mouse cursor position.
31 32 33 34 35 |
# File 'lib/daytona/computer_use.rb', line 31 def position toolbox_api.get_mouse_position rescue StandardError => e raise Sdk::Error, "Failed to get mouse position: #{e.}" end |
#scroll(x:, y:, direction:, amount: 1) ⇒ Boolean
Scrolls the mouse wheel at the specified coordinates.
114 115 116 117 118 119 120 |
# File 'lib/daytona/computer_use.rb', line 114 def scroll(x:, y:, direction:, amount: 1) request = DaytonaToolboxApiClient::MouseScrollRequest.new(x:, y:, direction:, amount:) toolbox_api.scroll(request) true rescue StandardError => e raise Sdk::Error, "Failed to scroll mouse: #{e.}" end |