class XDo::Mouse
The mouse state for a libxdo context.
Attributes
xdo[RW]
The XDo
context that produced the window.
Public Class Methods
new(xdo)
click to toggle source
Creates a mouse state wrapper for an XDo
context.
This constructor is called internally by XDo#mouse and client code should not need to call it directly.
Args:
xdo:: the XDo wrapping a libxdo context
# File lib/x_do/mouse.rb, line 13 def initialize(xdo) @xdo = xdo @_xdo_pointer = xdo._pointer end
Public Instance Methods
click(button)
click to toggle source
Clicks a mouse button.
# File lib/x_do/mouse.rb, line 70 def click(button) XDo::FFILib.xdo_click_window @_xdo_pointer, 0, button end
location()
click to toggle source
- x, y, screen
-
array of mouse coordinates.
# File lib/x_do/mouse.rb, line 22 def location x_pointer = FFI::MemoryPointer.new :int, 1 y_pointer = FFI::MemoryPointer.new :int, 1 screen_pointer = FFI::MemoryPointer.new :int, 1 XDo::FFILib.xdo_get_mouse_location @_xdo_pointer, x_pointer, y_pointer, screen_pointer [x_pointer.read_int, y_pointer.read_int, screen_pointer.read_int] end
move(x, y, screen)
click to toggle source
Moves the mouse to a new position.
# File lib/x_do/mouse.rb, line 32 def move(x, y, screen) old_location = self.location move_async x, y, screen unless old_location[0, 2] == [x, y] wait_for_move_from old_location[0], old_location[1] end end
move_async(x, y, screen)
click to toggle source
Queues a mouse move request to the X server.
# File lib/x_do/mouse.rb, line 41 def move_async(x, y, screen) XDo::FFILib.xdo_move_mouse @_xdo_pointer, x, y, screen end
move_relative(dx, dy)
click to toggle source
Moves the mouse relatively to its current position.
# File lib/x_do/mouse.rb, line 46 def move_relative(dx, dy) old_location = self.location move_relative_async dx, dy unless dx == 0 && dy == 0 wait_for_move_from old_location[0], old_location[1] end end
move_relative_async(dx, dy)
click to toggle source
Queues a mouse move request to the X server.
# File lib/x_do/mouse.rb, line 55 def move_relative_async(dx, dy) XDo::FFILib.xdo_move_mouse_relative @_xdo_pointer, dx, dy end
press(button)
click to toggle source
Presses a mouse button.
# File lib/x_do/mouse.rb, line 75 def press(button) XDo::FFILib.xdo_mousedown @_xdo_pointer, 0, button end
release(button)
click to toggle source
Releases a mouse button.
# File lib/x_do/mouse.rb, line 80 def release(button) XDo::FFILib.xdo_mouseup @_xdo_pointer, 0, button end
wait_for_move_from(x, y)
click to toggle source
Blocks until the mouse moves away from a position on screen.
# File lib/x_do/mouse.rb, line 60 def wait_for_move_from(x, y) XDo::FFILib.xdo_wait_for_mouse_move_from @_xdo_pointer, x, y end
wait_for_move_to(x, y)
click to toggle source
Blocks until the mouse moves to a position on screen.
# File lib/x_do/mouse.rb, line 65 def wait_for_move_to(x, y) XDo::FFILib.xdo_wait_for_mouse_move_to @_xdo_pointer, x, y end