Class: Deskbot::Screen
- Inherits:
-
Object
- Object
- Deskbot::Screen
- Defined in:
- lib/deskbot/screen.rb
Instance Method Summary collapse
- #alert(message) ⇒ Object
-
#area_visible?(x:, y:, width:, height:) ⇒ Boolean
rubocop:disable Naming/MethodParameterName.
- #capture ⇒ Object
-
#capture_area(x:, y:, width:, height:) ⇒ Object
rubocop:disable Naming/MethodParameterName.
- #click(button = "left", delay_ms: nil) ⇒ Object
-
#color_at(x, y) ⇒ Object
rubocop:disable Naming/MethodParameterName.
-
#initialize(provider) ⇒ Screen
constructor
This is the API for any provider.
- #mouse_location ⇒ Object
-
#move_mouse(x, y) ⇒ Object
rubocop:disable Naming/MethodParameterName.
-
#point_visible?(x, y) ⇒ Boolean
rubocop:disable Naming/MethodParameterName.
- #scale ⇒ Object
- #scroll(direction = "up", clicks: 1) ⇒ Object
- #size ⇒ Object
-
#smooth_move_mouse(x, y, duration: 1) ⇒ Object
rubocop:disable Naming/MethodParameterName.
- #tap_key(key, flags: [], delay_ms: 0.0, modifier_delay_ms: 0.0) ⇒ Object
- #toggle_key(key, down: true, flags: [], modifier_delay_ms: 0.0) ⇒ Object
- #toggle_mouse(button = "left", down: true) ⇒ Object
- #type(text, flags: [], wpm: 60.0, noise: 0.0) ⇒ Object
Constructor Details
#initialize(provider) ⇒ Screen
This is the API for any provider
7 8 9 |
# File 'lib/deskbot/screen.rb', line 7 def initialize(provider) @provider = provider end |
Instance Method Details
#alert(message) ⇒ Object
11 12 13 |
# File 'lib/deskbot/screen.rb', line 11 def alert() @provider.alert(Types::String[]) end |
#area_visible?(x:, y:, width:, height:) ⇒ Boolean
rubocop:disable Naming/MethodParameterName
106 107 108 109 110 111 112 113 |
# File 'lib/deskbot/screen.rb', line 106 def area_visible?(x:, y:, width:, height:) # rubocop:disable Naming/MethodParameterName @provider.is_area_visible( Types::Coercible::Float[x], Types::Coercible::Float[y], Types::Coercible::Float[width], Types::Coercible::Float[height] ) end |
#capture ⇒ Object
115 116 117 118 |
# File 'lib/deskbot/screen.rb', line 115 def capture bitmap = @provider.capture_screen Deskbot::Bitmap.new(bitmap) end |
#capture_area(x:, y:, width:, height:) ⇒ Object
rubocop:disable Naming/MethodParameterName
120 121 122 123 124 125 126 127 128 129 |
# File 'lib/deskbot/screen.rb', line 120 def capture_area(x:, y:, width:, height:) # rubocop:disable Naming/MethodParameterName bitmap = @provider.capture_screen_area( Types::Coercible::Float[x], Types::Coercible::Float[y], Types::Coercible::Float[width], Types::Coercible::Float[height] ) Deskbot::Bitmap.new(bitmap) end |
#click(button = "left", delay_ms: nil) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/deskbot/screen.rb', line 68 def click( = "left", delay_ms: nil) @provider.click( Types::Button[], Types::Float.optional[delay_ms] ) end |
#color_at(x, y) ⇒ Object
rubocop:disable Naming/MethodParameterName
82 83 84 85 86 87 88 89 |
# File 'lib/deskbot/screen.rb', line 82 def color_at(x, y) # rubocop:disable Naming/MethodParameterName red, green, blue, alpha = @provider.color_at( Types::Coercible::Float[x], Types::Coercible::Float[y] ) Color.new(red:, green:, blue:, alpha:) end |
#mouse_location ⇒ Object
42 43 44 |
# File 'lib/deskbot/screen.rb', line 42 def mouse_location Point.new(@provider.mouse_location) end |
#move_mouse(x, y) ⇒ Object
rubocop:disable Naming/MethodParameterName
46 47 48 49 50 51 |
# File 'lib/deskbot/screen.rb', line 46 def move_mouse(x, y) # rubocop:disable Naming/MethodParameterName @provider.move_mouse( Types::Coercible::Float[x], Types::Coercible::Float[y] ) end |
#point_visible?(x, y) ⇒ Boolean
rubocop:disable Naming/MethodParameterName
99 100 101 102 103 104 |
# File 'lib/deskbot/screen.rb', line 99 def point_visible?(x, y) # rubocop:disable Naming/MethodParameterName @provider.is_point_visible( Types::Coercible::Float[x], Types::Coercible::Float[y] ) end |
#scale ⇒ Object
95 96 97 |
# File 'lib/deskbot/screen.rb', line 95 def scale @provider.screen_scale end |
#scroll(direction = "up", clicks: 1) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/deskbot/screen.rb', line 75 def scroll(direction = "up", clicks: 1) @provider.scroll( Types::ScrollDirection[direction], Types::Integer[clicks] ) end |
#size ⇒ Object
91 92 93 |
# File 'lib/deskbot/screen.rb', line 91 def size Size.new(@provider.screen_size) end |
#smooth_move_mouse(x, y, duration: 1) ⇒ Object
rubocop:disable Naming/MethodParameterName
53 54 55 56 57 58 59 |
# File 'lib/deskbot/screen.rb', line 53 def smooth_move_mouse(x, y, duration: 1) # rubocop:disable Naming/MethodParameterName @provider.smooth_move_mouse( Types::Coercible::Float[x], Types::Coercible::Float[y], Types::Coercible::Float[duration] ) end |
#tap_key(key, flags: [], delay_ms: 0.0, modifier_delay_ms: 0.0) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/deskbot/screen.rb', line 33 def tap_key(key, flags: [], delay_ms: 0.0, modifier_delay_ms: 0.0) @provider.tap_key( Types::Character[key], Types::Flags[flags], Types::Float[delay_ms], Types::Float[modifier_delay_ms] ) end |
#toggle_key(key, down: true, flags: [], modifier_delay_ms: 0.0) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/deskbot/screen.rb', line 24 def toggle_key(key, down: true, flags: [], modifier_delay_ms: 0.0) @provider.toggle_key( Types::Character[key], Types::Bool[down], Types::Flags[flags], Types::Float[modifier_delay_ms] ) end |