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.
20 21 22 23 24 |
# File 'lib/daytona/computer_use.rb', line 20 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.
12 13 14 |
# File 'lib/daytona/computer_use.rb', line 12 def sandbox_id @sandbox_id end |
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi (readonly)
Returns API client for sandbox operations.
15 16 17 |
# File 'lib/daytona/computer_use.rb', line 15 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.
75 76 77 78 79 80 |
# File 'lib/daytona/computer_use.rb', line 75 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.
95 96 97 98 99 100 |
# File 'lib/daytona/computer_use.rb', line 95 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.
50 51 52 53 54 55 |
# File 'lib/daytona/computer_use.rb', line 50 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.
34 35 36 37 38 |
# File 'lib/daytona/computer_use.rb', line 34 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.
117 118 119 120 121 122 123 |
# File 'lib/daytona/computer_use.rb', line 117 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 |