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)


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

Raises:

  • (NotImplementedError)


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

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

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

Raises:

  • (NotImplementedError)


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

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

#screen_sizeObject

Raises:

  • (NotImplementedError)


50
51
52
53
# File 'lib/win32.rb', line 50

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