Class: RAutomation::Adapter::Win32::Mouse

Inherits:
Object
  • Object
show all
Defined in:
lib/rautomation/adapter/win_32/mouse.rb

Instance Method Summary collapse

Constructor Details

#initialize(window) ⇒ Mouse

Returns a new instance of Mouse.



5
6
7
# File 'lib/rautomation/adapter/win_32/mouse.rb', line 5

def initialize(window)
  @window = window
end

Instance Method Details

#click



22
23
24
# File 'lib/rautomation/adapter/win_32/mouse.rb', line 22

def click
  send_input down_event, up_event
end

#move(coords = {})



9
10
11
12
13
14
15
16
# File 'lib/rautomation/adapter/win_32/mouse.rb', line 9

def move(coords={})
  @last_position = coords = (@last_position || position).merge(coords)

  until position[:x] == coords[:x] && position[:y] == coords[:y]
    @window.activate
    Functions.set_cursor_pos coords[:x], coords[:y]
  end
end

#position



18
19
20
# File 'lib/rautomation/adapter/win_32/mouse.rb', line 18

def position
  Functions.get_cursor_pos
end

#press



26
27
28
# File 'lib/rautomation/adapter/win_32/mouse.rb', line 26

def press
  send_input down_event, down_event
end

#release



30
31
32
# File 'lib/rautomation/adapter/win_32/mouse.rb', line 30

def release
  send_input up_event, up_event
end