Class: RuMouse

Inherits:
Object
  • Object
show all
Defined in:
lib/win32.rb,
lib/darwin.rb,
lib/rumouse.rb

Instance Method Summary collapse

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, button = 1, n = 1
  n.times do 
    press x, y, button
    release x, y, button
  end
end

#move(x, y) ⇒ Object

Raises:

  • (NotImplementedError)


26
27
28
# File 'lib/win32.rb', line 26

def move x, y
  User32::SetCursorPos x, y
end

#positionObject

Raises:

  • (NotImplementedError)


42
43
44
45
46
# File 'lib/win32.rb', line 42

def position
  point = User32::Point.new
  User32::GetCursorPos point
  { x: point[:x], y: point[:y] }
end

#press(x, y, button = 1) ⇒ Object

Raises:

  • (NotImplementedError)


30
31
32
33
34
# File 'lib/win32.rb', line 30

def press x, y, button = 1
  User32::mouse_event User32::MOUSEEVENTF_ABSOLUTE | button_code(button, true),
                      x, y,
                      0, nil
end

#release(x, y, button = 1) ⇒ Object

Raises:

  • (NotImplementedError)


36
37
38
39
40
# File 'lib/win32.rb', line 36

def release x, y, button = 1
  User32::mouse_event User32::MOUSEEVENTF_ABSOLUTE | button_code(button, false),
                      x, y,
                      0, nil
end

#screen_sizeObject

Raises:

  • (NotImplementedError)


48
49
50
51
# File 'lib/win32.rb', line 48

def screen_size
  { x: User32::GetSystemMetrics(0),
    y: User32::GetSystemMetrics(1) }
end