Class: Daytona::ComputerUse::Mouse
- Inherits:
-
Object
- Object
- Daytona::ComputerUse::Mouse
- 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:) ⇒ 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.
Constructor Details
#initialize(sandbox_id:, toolbox_api:) ⇒ Mouse
Returns a new instance of Mouse.
14 15 16 17 |
# File 'lib/daytona/computer_use.rb', line 14 def initialize(sandbox_id:, toolbox_api:) @sandbox_id = sandbox_id @toolbox_api = toolbox_api end |
Instance Attribute Details
#sandbox_id ⇒ String (readonly)
Returns The ID of the sandbox.
7 8 9 |
# File 'lib/daytona/computer_use.rb', line 7 def sandbox_id @sandbox_id end |
#toolbox_api ⇒ DaytonaToolboxApiClient::ComputerUseApi (readonly)
Returns API client for sandbox operations.
10 11 12 |
# File 'lib/daytona/computer_use.rb', line 10 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.
68 69 70 71 72 73 |
# File 'lib/daytona/computer_use.rb', line 68 def click(x:, y:, button: 'left', double: false) # rubocop:disable Naming/MethodParameterName 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.
88 89 90 91 92 93 |
# File 'lib/daytona/computer_use.rb', line 88 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.
43 44 45 46 47 48 |
# File 'lib/daytona/computer_use.rb', line 43 def move(x:, y:) # rubocop:disable Naming/MethodParameterName 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.
27 28 29 30 31 |
# File 'lib/daytona/computer_use.rb', line 27 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.
110 111 112 113 114 115 116 |
# File 'lib/daytona/computer_use.rb', line 110 def scroll(x:, y:, direction:, amount: 1) # rubocop:disable Naming/MethodParameterName 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 |