class Robobot::Mouse
Public Class Methods
new(window = nil)
click to toggle source
Initialize mouse
# File lib/robobot/mouse.rb, line 10 def initialize window = nil @window = window end
Public Instance Methods
click(button = "1")
click to toggle source
Click
Buttons:
1 = Left 2 = Middle 3 = Right 4 = Wheel up 5 = Wheel down
# File lib/robobot/mouse.rb, line 33 def click button = "1" cmd "click #{button}" end
down(button = "1")
click to toggle source
Mouse
down (see Click)
# File lib/robobot/mouse.rb, line 38 def down button = "1" cmd = "mousedown #{button}" end
location()
click to toggle source
Get location
# File lib/robobot/mouse.rb, line 48 def location location = `xdotool getmouselocation --shell`.split("\n") return { :x => location[0].split("=")[1], :y => location[1].split("=")[1], :screen => location[2].split("=")[1], :window => location[3].split("=")[1] } end
move(x,y)
click to toggle source
Move mouse to x,y
# File lib/robobot/mouse.rb, line 15 def move x,y cmd "mousemove --sync #{x} #{y}" end
move_relative(x,y)
click to toggle source
Move relative to current position
# File lib/robobot/mouse.rb, line 20 def move_relative x,y cmd "mousemove_relative --sync #{x} #{y}" end
up(button = "1")
click to toggle source
Mouse
up (see Click)
# File lib/robobot/mouse.rb, line 43 def up button = "1" cmd = "mousedown #{button}" end
Private Instance Methods
cmd(command)
click to toggle source
Command generator (add window if set)
# File lib/robobot/mouse.rb, line 61 def cmd command command = command.split(" ",2) cmd = "xdotool #{command[0]}" cmd += " --window #{@window.id}" if @window cmd += " #{command[1]}" puts "#{cmd}" `#{cmd}` end