Module: Sikuli::Clickable

Included in:
Region
Defined in:
lib/sikuli/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/sikuli/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



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

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/sikuli/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



81
82
83
84
85
86
87
# File 'lib/sikuli/clickable.rb', line 81

def drag_drop(start_x, start_y, end_x, end_y)
  @java_obj.dragDrop(
    org.sikuli.script::Location.new(start_x, start_y).offset(x(), y()),
    org.sikuli.script::Location.new(end_x, end_y).offset(x(), y()),
    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



111
112
113
# File 'lib/sikuli/clickable.rb', line 111

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



98
99
100
# File 'lib/sikuli/clickable.rb', line 98

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