Class: OmniAI::Tools::Computer::BaseDriver
- Inherits:
-
Object
- Object
- OmniAI::Tools::Computer::BaseDriver
- Defined in:
- lib/omniai/tools/computer/base_driver.rb
Overview
A tool for interacting with a computer. Be careful with using as it can perform actions on your computer!
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_MOUSE_BUTTON =
"left"
- DEFAULT_DISPLAY_SCALE =
2
Instance Attribute Summary collapse
-
#display_height ⇒ Object
Returns the value of attribute display_height.
-
#display_number ⇒ Object
Returns the value of attribute display_number.
-
#display_width ⇒ Object
Returns the value of attribute display_width.
Instance Method Summary collapse
- #hold_key(text:, duration:) ⇒ Object
-
#initialize(display_width:, display_height:, display_number:) ⇒ BaseDriver
constructor
A new instance of BaseDriver.
- #key(text:) ⇒ Object
- #mouse_click(coordinate:, button:) ⇒ Object
- #mouse_double_click(coordinate:, button:) ⇒ Object
- #mouse_down(coordinate:, button:) ⇒ Object
- #mouse_drag(coordinate:, button: DEFAULT_MOUSE_BUTTON) ⇒ Object
- #mouse_move(coordinate:) ⇒ Object
- #mouse_position ⇒ Hash<{ x: Integer, y: Integer }>
- #mouse_triple_click(coordinate:, button:) ⇒ Object
- #mouse_up(coordinate:, button:) ⇒ Object
- #screenshot {|file| ... } ⇒ Object
- #scroll(amount:, direction:) ⇒ Object
- #type(text:) ⇒ Object
- #wait(duration:) ⇒ Object
Constructor Details
#initialize(display_width:, display_height:, display_number:) ⇒ BaseDriver
Returns a new instance of BaseDriver.
86 87 88 89 90 91 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 86 def initialize(display_width:, display_height:, display_number:) @display_width = display_width @display_height = display_height @display_number = display_number end |
Instance Attribute Details
#display_height ⇒ Object
Returns the value of attribute display_height.
77 78 79 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 77 def display_height @display_height end |
#display_number ⇒ Object
Returns the value of attribute display_number.
81 82 83 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 81 def display_number @display_number end |
#display_width ⇒ Object
Returns the value of attribute display_width.
73 74 75 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 73 def display_width @display_width end |
Instance Method Details
#hold_key(text:, duration:) ⇒ Object
100 101 102 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 100 def hold_key(text:, duration:) raise NotImplementedError, "#{self.class.name}##{__method__} undefined" end |
#key(text:) ⇒ Object
94 95 96 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 94 def key(text:) raise NotImplementedError, "#{self.class.name}##{__method__} undefined" end |
#mouse_click(coordinate:, button:) ⇒ Object
117 118 119 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 117 def mouse_click(coordinate:, button:) raise NotImplementedError, "#{self.class.name}##{__method__} undefined" end |
#mouse_double_click(coordinate:, button:) ⇒ Object
143 144 145 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 143 def mouse_double_click(coordinate:, button:) 2.times { mouse_click(coordinate:, button:) } end |
#mouse_down(coordinate:, button:) ⇒ Object
123 124 125 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 123 def mouse_down(coordinate:, button:) raise NotImplementedError, "#{self.class.name}##{__method__} undefined" end |
#mouse_drag(coordinate:, button: DEFAULT_MOUSE_BUTTON) ⇒ Object
135 136 137 138 139 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 135 def mouse_drag(coordinate:, button: DEFAULT_MOUSE_BUTTON) mouse_down(coordinate: mouse_position, button:) mouse_move(coordinate:, button:) mouse_up(coordinate:, button:) end |
#mouse_move(coordinate:) ⇒ Object
111 112 113 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 111 def mouse_move(coordinate:) raise NotImplementedError, "#{self.class.name}##{__method__} undefined" end |
#mouse_position ⇒ Hash<{ x: Integer, y: Integer }>
105 106 107 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 105 def mouse_position raise NotImplementedError, "#{self.class.name}##{__method__} undefined" end |
#mouse_triple_click(coordinate:, button:) ⇒ Object
149 150 151 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 149 def mouse_triple_click(coordinate:, button:) 3.times { mouse_click(coordinate:, button:) } end |
#mouse_up(coordinate:, button:) ⇒ Object
129 130 131 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 129 def mouse_up(coordinate:, button:) raise NotImplementedError, "#{self.class.name}##{__method__} undefined" end |
#screenshot {|file| ... } ⇒ Object
166 167 168 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 166 def screenshot raise NotImplementedError, "#{self.class.name}##{__method__} undefined" end |
#scroll(amount:, direction:) ⇒ Object
160 161 162 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 160 def scroll(amount:, direction:) raise NotImplementedError, "#{self.class.name}##{__method__} undefined" end |
#type(text:) ⇒ Object
154 155 156 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 154 def type(text:) raise NotImplementedError, "#{self.class.name}##{__method__} undefined" end |
#wait(duration:) ⇒ Object
171 172 173 |
# File 'lib/omniai/tools/computer/base_driver.rb', line 171 def wait(duration:) Kernel.sleep(duration) end |