class RuMouse

Public Instance Methods

click(x, y, button = 1, n = 1) click to toggle source
# File lib/rumouse.rb, line 12
def click x, y, button = 1, n = 1
  n.times do 
    press x, y, button
    release x, y, button
  end
end
move(x, y) click to toggle source
# File lib/rumouse.rb, line 19
def move x, y
  raise NotImplementedError
end
position() click to toggle source
# File lib/rumouse.rb, line 23
def position
  raise NotImplementedError
end
press(x, y, button = 1) click to toggle source
# File lib/rumouse.rb, line 4
def press x, y, button = 1
  raise NotImplementedError
end
release(x, y, button = 1) click to toggle source
# File lib/rumouse.rb, line 8
def release x, y, button = 1
  raise NotImplementedError
end
screen_size() click to toggle source
# File lib/rumouse.rb, line 27
def screen_size
  raise NotImplementedError
end

Private Instance Methods

button_code(id, state) click to toggle source
# File lib/rumouse/win32.rb, line 57
def button_code id, state
  if    id == 1 and state then User32::MOUSEEVENTF_LEFTDOWN
  elsif id == 2 and state then User32::MOUSEEVENTF_RIGHTDOWN
  elsif id == 1 and not state then User32::MOUSEEVENTF_LEFTUP
  elsif id == 2 and not state then User32::MOUSEEVENTF_RIGHTUP
  else 0 end
end
mouse_event(x, y, type, button) click to toggle source
# File lib/rumouse/darwin.rb, line 94
def mouse_event x, y, type, button
  coord = CGEvent::CGPoint.new
  coord[:x] = x
  coord[:y] = y
  event = CGEvent::CGEventCreateMouseEvent(nil, type, coord, button)
  CGEvent::CGEventPost(:kCGHIDEventTap, event)
  CGEvent::CFRelease(event)
end