Module: Rukuli::Clickable

Included in:
Region
Defined in:
lib/rukuli/clickable.rb

Instance Method Summary collapse

Instance Method Details

#click(*args) ⇒ Object

Public: Performs a single click on an image match or point (x, y)

args - String representing filename of image to find and click args - Fixnum, Fixnum representing x and y coordinates within a Region (0,0) is the top left

Examples

region.click('smile.png')
region.click(123, 432)

Returns nothing


19
20
21
22
23
24
25
# File 'lib/rukuli/clickable.rb', line 19

def click(*args)
  case args.length
    when 1 then click_image(args[0])
    when 2 then click_point(args[0], args[1])
    else raise ArgumentError
  end
end

#click_and_hold(seconds = 1, *args) ⇒ Object

Public: Performs a click and hold on an image match or point (x, y)

args - String representing filename of image to find and click args - Fixnum, Fixnum representing x and y coordinates within a Region (0,0) is the top left seconds - Fixnum representing the number of seconds to hold down before releasing

Examples

region.click_and_hold('smile.png', 2)
region.click_and_hold(123, 432, 2)

Returns nothing


83
84
85
86
87
88
89
# File 'lib/rukuli/clickable.rb', line 83

def click_and_hold(seconds = 1, *args)
  case args.length
    when 1 then click_image_and_hold(args[0], seconds)
    when 2 then click_point_and_hold(args[0], args[1], seconds)
    else raise ArgumentError
  end
end

#double_click(*args) ⇒ Object

Public: Performs a double click on an image match or point (x, y)

args - String representing filename of image to find and click args - Fixnum, Fixnum representing x and y coordinates within a Region (0,0) is the top left

Examples

region.double_click('smile.png')
region.double_click(123, 432)

Returns nothing


39
40
41
42
43
44
45
# File 'lib/rukuli/clickable.rb', line 39

def double_click(*args)
  case args.length
    when 1 then click_image(args[0], true)
    when 2 then click_point(args[0], args[1], true)
    else raise ArgumentError
  end
end

#drag_drop(start_x, start_y, end_x, end_y) ⇒ Object

Public: Performs a mouse down, drag, and mouse up

start_x - Fixnum representing the x of the mouse down start_y - Fixnum representing the y of the mouse down end_x - Fixnum representing the x of the mouse up end_y - Fixnum representing the y of the mouse up

Examples

region.drag_drop(20, 12, 23, 44)

Returns nothing


103
104
105
106
107
108
# File 'lib/rukuli/clickable.rb', line 103

def drag_drop(start_x, start_y, end_x, end_y)
  @java_obj.dragDrop(
    offset_location(start_x, start_y),
    offset_location(end_x, end_y)
  )
end

#hover(*args) ⇒ Object

Public: Performs a hover on an image match or point (x, y)

args - String representing filename of image to find and hover args - Fixnum, Fixnum representing x and y coordinates within a Region (0,0) is the top left

Examples

region.hover('smile.png')
region.hover(123, 432)

Returns nothing


148
149
150
151
152
153
154
# File 'lib/rukuli/clickable.rb', line 148

def hover(*args)
  case args.length
    when 1 then hover_image(args[0])
    when 2 then hover_point(args[0], args[1])
    else raise ArgumentError
  end
end

#right_click(*args) ⇒ Object

Public: Performs a right click on an image match or point (x, y)

args - String representing filename of image to find and click args - Fixnum, Fixnum representing x and y coordinates within a Region (0,0) is the top left

Examples

region.right_click('smile.png')
region.right_click(123, 432)

Returns nothing


59
60
61
62
63
64
65
66
67
# File 'lib/rukuli/clickable.rb', line 59

def right_click(*args)
  case args.length
    when 1 then @java_obj.rightClick(args[0], 0)
    when 2 then @java_obj.rightClick(offset_location(args[0], args[1]))
    else raise ArgumentError
  end
  rescue NativeException => e
    raise_exception e, args[0]
end

#wheel_down(steps = 1) ⇒ Object

Public: Simulates turning of the mouse wheel down

steps - Fixnum representing the number of steps to turn the mouse wheel

Examples

region.wheel_down(10)

Returns nothing


132
133
134
# File 'lib/rukuli/clickable.rb', line 132

def wheel_down(steps = 1)
  @java_obj.wheel(1, steps)
end

#wheel_up(steps = 1) ⇒ Object

Public: Simulates turning of the mouse wheel up

steps - Fixnum representing the number of steps to turn the mouse wheel

Examples

region.wheel_up(10)

Returns nothing


119
120
121
# File 'lib/rukuli/clickable.rb', line 119

def wheel_up(steps = 1)
  @java_obj.wheel(-1, steps)
end