Class: RuMouse
- Inherits:
-
Object
- Object
- RuMouse
- Defined in:
- lib/win32.rb,
lib/darwin.rb,
lib/rumouse.rb
Instance Method Summary collapse
- #click(x, y, button = 1, n = 1) ⇒ Object
- #move(x, y) ⇒ Object
- #position ⇒ Object
- #press(x, y, button = 1) ⇒ Object
- #release(x, y, button = 1) ⇒ Object
- #screen_size ⇒ Object
Instance Method Details
#click(x, y, button = 1, n = 1) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rumouse.rb', line 12 def click x, y, = 1, n = 1 n.times do press x, y, release x, y, end end |
#move(x, y) ⇒ Object
26 27 28 |
# File 'lib/win32.rb', line 26 def move x, y User32::SetCursorPos x, y end |
#position ⇒ Object
44 45 46 47 48 |
# File 'lib/win32.rb', line 44 def position point = User32::Point.new User32::GetCursorPos point { x: point[:x], y: point[:y] } end |
#press(x, y, button = 1) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/win32.rb', line 30 def press x, y, = 1 move x, y User32::mouse_event User32::MOUSEEVENTF_ABSOLUTE | (, true), x, y, 0, nil end |
#release(x, y, button = 1) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/win32.rb', line 37 def release x, y, = 1 move x, y User32::mouse_event User32::MOUSEEVENTF_ABSOLUTE | (, false), x, y, 0, nil end |
#screen_size ⇒ Object
50 51 52 53 |
# File 'lib/win32.rb', line 50 def screen_size { x: User32::GetSystemMetrics(0), y: User32::GetSystemMetrics(1) } end |