class Samscript::Mouse

Public Class Methods

click(button = :left) click to toggle source
# File lib/samscript/mouse.rb, line 34
def self.click button = :left
  masks = { left:  InputEvent::BUTTON1_MASK,
            right: InputEvent::BUTTON2_MASK }
  mask = masks[button]

  robot.mouse_press mask
  robot.mouse_release mask
end
position(params = {}) click to toggle source
# File lib/samscript/mouse.rb, line 14
def self.position params = {}
  as = params[:as] || :point
  point = MouseInfo.get_pointer_info.get_location
  vector = Vector[point.get_x, point.get_y]

  case as
  when :point
    return point
  when :vector
    return vector
  end
end
position=(point) click to toggle source
# File lib/samscript/mouse.rb, line 27
def self.position= point
  x, y = point[0], point[1] if point.is_a? Vector
  x, y = point.get_x, point.get_y if point.is_a? Point

  robot.mouse_move(x, y)
end
robot() click to toggle source
# File lib/samscript/mouse.rb, line 10
def self.robot
  @robot ||= Robot.new
end