lib/mac-robot.rb in mac-robot-0.0.2 vs lib/mac-robot.rb in mac-robot-0.1.0

- old
+ new

@@ -12,10 +12,11 @@ def initialize @x = 0 @y = 0 @state = :mouse_up + @dispatcher = EventDispatcher.new end def mouse_press(button = :left) mouse_event(button, :mouse_down) @state = :mouse_down @@ -31,13 +32,24 @@ @y = y mouse_event(:left, :mouse_move) end + def key_press(keycode) + keyboard_event(keycode, 1) + end + + def key_release(keycode) + keyboard_event(keycode, 0) + end + private def mouse_event(button, type) - dispatcher = EventDispatcher.new - dispatcher.dispatchMouseEvent(@x, @y, BUTTONS[button], type) + @dispatcher.dispatchMouseEvent(@x, @y, BUTTONS[button], type) + end + + def keyboard_event(keycode, keydown) + @dispatcher.dispatchKeyboardEvent(keycode, keydown) end end end