Class: Mousetools
- Inherits:
-
Object
- Object
- Mousetools
- Defined in:
- lib/mousetools.rb
Instance Attribute Summary collapse
-
#current_coordinates ⇒ Object
Returns the value of attribute current_coordinates.
Instance Method Summary collapse
- #key_down(virtual_key, modifier_key_1 = nil, modifier_key_2 = nil) ⇒ Object
- #key_up(virtual_key) ⇒ Object
- #left_mouse_down(x = nil, y = nil, modifier_key_1 = nil, modifier_key_2 = nil) ⇒ Object
- #left_mouse_drag(x, y, modifier_key_1 = nil, modifier_key_2 = nil) ⇒ Object
- #left_mouse_up(x = nil, y = nil) ⇒ Object
- #move_cursor(x, y) ⇒ Object
- #right_mouse_down(x = nil, y = nil, modifier_key_1 = nil, modifier_key_2 = nil) ⇒ Object
- #right_mouse_drag(x, y, modifier_key_1 = nil, modifier_key_2 = nil) ⇒ Object
- #right_mouse_up(x = nil, y = nil) ⇒ Object
Instance Attribute Details
#current_coordinates ⇒ Object
Returns the value of attribute current_coordinates.
6 7 8 |
# File 'lib/mousetools.rb', line 6 def current_coordinates @current_coordinates end |
Instance Method Details
#key_down(virtual_key, modifier_key_1 = nil, modifier_key_2 = nil) ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/mousetools.rb', line 36 def key_down(virtual_key, modifier_key_1 = nil, modifier_key_2 = nil) if (modifier_key_1.nil? && modifier_key_2.nil?) post_keyboard_event(virtual_key, true) elsif (!modifier_key_1.nil? && modifier_key_2.nil?) post_keyboard_event(virtual_key, true, modifier_key_1) else post_keyboard_event(virtual_key, true, modifier_key_1, modifier_key_2) end end |
#key_up(virtual_key) ⇒ Object
46 47 48 |
# File 'lib/mousetools.rb', line 46 def key_up(virtual_key) post_keyboard_event(virtual_key, false) end |
#left_mouse_down(x = nil, y = nil, modifier_key_1 = nil, modifier_key_2 = nil) ⇒ Object
8 9 10 |
# File 'lib/mousetools.rb', line 8 def left_mouse_down(x = nil, y = nil, modifier_key_1 = nil, modifier_key_2 = nil) post_mouse_event(x, y, :kCGEventLeftMouseDown, :kCGMouseButtonLeft, modifier_key_1, modifier_key_2) end |
#left_mouse_drag(x, y, modifier_key_1 = nil, modifier_key_2 = nil) ⇒ Object
28 29 30 |
# File 'lib/mousetools.rb', line 28 def left_mouse_drag(x, y, modifier_key_1 = nil, modifier_key_2 = nil) post_mouse_event(x, y, :kCGEventLeftMouseDragged, :kCGMouseButtonLeft, modifier_key_1, modifier_key_2) end |
#left_mouse_up(x = nil, y = nil) ⇒ Object
12 13 14 |
# File 'lib/mousetools.rb', line 12 def left_mouse_up(x = nil, y = nil) post_mouse_event(x, y, :kCGEventLeftMouseUp, :kCGMouseButtonLeft) end |
#move_cursor(x, y) ⇒ Object
24 25 26 |
# File 'lib/mousetools.rb', line 24 def move_cursor(x, y) post_mouse_event(x, y, :kCGEventMouseMoved, :kCGMouseButtonLeft) end |
#right_mouse_down(x = nil, y = nil, modifier_key_1 = nil, modifier_key_2 = nil) ⇒ Object
16 17 18 |
# File 'lib/mousetools.rb', line 16 def right_mouse_down(x = nil, y = nil, modifier_key_1 = nil, modifier_key_2 = nil) post_mouse_event(x, y, :kCGEventRightMouseDown, :kCGMouseButtonRight, modifier_key_1, modifier_key_2) end |
#right_mouse_drag(x, y, modifier_key_1 = nil, modifier_key_2 = nil) ⇒ Object
32 33 34 |
# File 'lib/mousetools.rb', line 32 def right_mouse_drag(x, y, modifier_key_1 = nil, modifier_key_2 = nil) post_mouse_event(x, y, :kCGEventRightMouseDragged, :kCGMouseButtonRight, modifier_key_1, modifier_key_2) end |
#right_mouse_up(x = nil, y = nil) ⇒ Object
20 21 22 |
# File 'lib/mousetools.rb', line 20 def right_mouse_up(x = nil, y = nil) post_mouse_event(x, y, :kCGEventRightMouseUp, :kCGMouseButtonRight) end |